UI log category, BolusProgressDialog detailed log

This commit is contained in:
Milos Kozak 2018-08-03 12:32:10 +02:00
parent 580e05e8eb
commit 8cc7fb03d1
2 changed files with 29 additions and 4 deletions

View file

@ -94,6 +94,7 @@ public class L {
public static final String APS = "APS"; public static final String APS = "APS";
public static final String PROFILE = "PROFILE"; public static final String PROFILE = "PROFILE";
public static final String CONFIGBUILDER = "CONFIGBUILDER"; public static final String CONFIGBUILDER = "CONFIGBUILDER";
public static final String UI = "UI";
private static void initialize() { private static void initialize() {
logElements = new ArrayList<>(); logElements = new ArrayList<>();
@ -116,6 +117,7 @@ public class L {
logElements.add(new LogElement(PUMPBTCOMM, false)); logElements.add(new LogElement(PUMPBTCOMM, false));
logElements.add(new LogElement(PUMPCOMM, true)); logElements.add(new LogElement(PUMPCOMM, true));
logElements.add(new LogElement(PUMPQUEUE, true)); logElements.add(new LogElement(PUMPQUEUE, true));
logElements.add(new LogElement(UI, true));
} }
} }

View file

@ -20,12 +20,13 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.logging.L;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogressIfRunning; import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogressIfRunning;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
public class BolusProgressDialog extends DialogFragment implements View.OnClickListener { public class BolusProgressDialog extends DialogFragment implements View.OnClickListener {
private static Logger log = LoggerFactory.getLogger(BolusProgressDialog.class); private static Logger log = LoggerFactory.getLogger(L.UI);
Button stopButton; Button stopButton;
TextView statusView; TextView statusView;
TextView stopPressedView; TextView stopPressedView;
@ -70,7 +71,9 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
if(!ConfigBuilderPlugin.getCommandQueue().bolusInQueue()) { if (L.isEnabled(L.UI))
log.debug("onResume");
if (!ConfigBuilderPlugin.getCommandQueue().bolusInQueue()) {
bolusEnded = true; bolusEnded = true;
} }
if (bolusEnded) { if (bolusEnded) {
@ -80,17 +83,22 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
MainApp.subscribe(this); MainApp.subscribe(this);
running = true; running = true;
if (L.isEnabled(L.UI))
log.debug("onResume running");
} }
} }
@Override @Override
public void dismiss() { public void dismiss() {
if (L.isEnabled(L.UI))
log.debug("dismiss");
try { try {
super.dismiss(); super.dismiss();
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
// dialog not running yet. onResume will try again. Set bolusEnded to make extra // dialog not running yet. onResume will try again. Set bolusEnded to make extra
// sure onResume will catch this // sure onResume will catch this
bolusEnded = true; bolusEnded = true;
log.error("Unhandled exception", e);
} }
if (helperActivity != null) { if (helperActivity != null) {
helperActivity.finish(); helperActivity.finish();
@ -102,13 +110,16 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
super.onPause(); super.onPause();
MainApp.unsubscribe(this); MainApp.unsubscribe(this);
running = false; running = false;
if (L.isEnabled(L.UI))
log.debug("onPause");
} }
@Override @Override
public void onClick(View view) { public void onClick(View view) {
switch (view.getId()) { switch (view.getId()) {
case R.id.overview_bolusprogress_stop: case R.id.overview_bolusprogress_stop:
log.debug("Stop bolus delivery button pressed"); if (L.isEnabled(L.UI))
log.debug("Stop bolus delivery button pressed");
stopPressed = true; stopPressed = true;
stopPressedView.setVisibility(View.VISIBLE); stopPressedView.setVisibility(View.VISIBLE);
stopButton.setVisibility(View.INVISIBLE); stopButton.setVisibility(View.INVISIBLE);
@ -122,7 +133,8 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
Activity activity = getActivity(); Activity activity = getActivity();
if (activity != null) { if (activity != null) {
activity.runOnUiThread(() -> { activity.runOnUiThread(() -> {
log.debug("Status: " + ev.status + " Percent: " + ev.percent); if (L.isEnabled(L.UI))
log.debug("Status: " + ev.status + " Percent: " + ev.percent);
statusView.setText(ev.status); statusView.setText(ev.status);
progressBar.setProgress(ev.percent); progressBar.setProgress(ev.percent);
if (ev.percent == 100) { if (ev.percent == 100) {
@ -135,6 +147,8 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
@Subscribe @Subscribe
public void onStatusEvent(final EventDismissBolusprogressIfRunning ev) { public void onStatusEvent(final EventDismissBolusprogressIfRunning ev) {
if (L.isEnabled(L.UI))
log.debug("EventDismissBolusprogressIfRunning");
if (BolusProgressDialog.running) { if (BolusProgressDialog.running) {
dismiss(); dismiss();
} }
@ -142,6 +156,8 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
@Subscribe @Subscribe
public void onStatusEvent(final EventPumpStatusChanged c) { public void onStatusEvent(final EventPumpStatusChanged c) {
if (L.isEnabled(L.UI))
log.debug("EventPumpStatusChanged");
Activity activity = getActivity(); Activity activity = getActivity();
if (activity != null) { if (activity != null) {
activity.runOnUiThread(() -> statusView.setText(c.textStatus())); activity.runOnUiThread(() -> statusView.setText(c.textStatus()));
@ -149,18 +165,25 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
} }
private void scheduleDismiss() { private void scheduleDismiss() {
if (L.isEnabled(L.UI))
log.debug("scheduleDismiss");
Thread t = new Thread(() -> { Thread t = new Thread(() -> {
SystemClock.sleep(5000); SystemClock.sleep(5000);
BolusProgressDialog.bolusEnded = true; BolusProgressDialog.bolusEnded = true;
Activity activity = getActivity(); Activity activity = getActivity();
if (activity != null) { if (activity != null) {
activity.runOnUiThread(() -> { activity.runOnUiThread(() -> {
if (L.isEnabled(L.UI))
log.debug("executing");
try { try {
dismiss(); dismiss();
} catch (Exception e) { } catch (Exception e) {
log.error("Unhandled exception", e); log.error("Unhandled exception", e);
} }
}); });
} else {
if (L.isEnabled(L.UI))
log.debug("activity == null");
} }
}); });
t.start(); t.start();