From bb041b1c06f5ef8adb7296a4aec69d2be66ba839 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 14 Aug 2016 20:19:47 +0200 Subject: [PATCH] more progress dialog tweaking --- .../plugins/ConfigBuilder/ConfigBuilderPlugin.java | 10 ++++++++-- .../plugins/Overview/Dialogs/BolusProgressDialog.java | 6 ++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java index df452796cf..411e50d05f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java @@ -390,8 +390,14 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain PumpEnactResult result = activePump.deliverTreatment(insulin, carbs, context); - if (bolusProgressDialog != null) { - bolusProgressDialog.dismiss(); + bolusProgressDialog.bolusEnded = true; + + if (bolusProgressDialog != null && bolusProgressDialog.running) { + try { + bolusProgressDialog.dismiss(); + } catch (Exception e) { + e.printStackTrace(); // TODO: handle this better + } } if (Config.logCongigBuilderActions) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/BolusProgressDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/BolusProgressDialog.java index a03f7f0b2f..6984397f4f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/BolusProgressDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/BolusProgressDialog.java @@ -31,6 +31,8 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL ProgressBar progressBar; static double amount; + public static boolean bolusEnded = false; + public static boolean running = true; boolean started = false; @@ -40,6 +42,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL public BolusProgressDialog(double amount) { this.amount = amount; + bolusEnded = false; } @Override @@ -63,12 +66,15 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL public void onResume() { super.onResume(); MainApp.bus().register(this); + running = true; + if (bolusEnded) dismiss(); } @Override public void onPause() { super.onPause(); MainApp.bus().unregister(this); + running = false; } @Override