more progress dialog tweaking

This commit is contained in:
Milos Kozak 2016-08-14 20:19:47 +02:00
parent e95650d54d
commit bb041b1c06
2 changed files with 14 additions and 2 deletions

View file

@ -390,8 +390,14 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
PumpEnactResult result = activePump.deliverTreatment(insulin, carbs, context); PumpEnactResult result = activePump.deliverTreatment(insulin, carbs, context);
if (bolusProgressDialog != null) { bolusProgressDialog.bolusEnded = true;
bolusProgressDialog.dismiss();
if (bolusProgressDialog != null && bolusProgressDialog.running) {
try {
bolusProgressDialog.dismiss();
} catch (Exception e) {
e.printStackTrace(); // TODO: handle this better
}
} }
if (Config.logCongigBuilderActions) if (Config.logCongigBuilderActions)

View file

@ -31,6 +31,8 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
ProgressBar progressBar; ProgressBar progressBar;
static double amount; static double amount;
public static boolean bolusEnded = false;
public static boolean running = true;
boolean started = false; boolean started = false;
@ -40,6 +42,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
public BolusProgressDialog(double amount) { public BolusProgressDialog(double amount) {
this.amount = amount; this.amount = amount;
bolusEnded = false;
} }
@Override @Override
@ -63,12 +66,15 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
MainApp.bus().register(this); MainApp.bus().register(this);
running = true;
if (bolusEnded) dismiss();
} }
@Override @Override
public void onPause() { public void onPause() {
super.onPause(); super.onPause();
MainApp.bus().unregister(this); MainApp.bus().unregister(this);
running = false;
} }
@Override @Override