From 22e90743aabfd181035776b84e42e99e64729555 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Wed, 2 May 2018 21:24:06 +0200 Subject: [PATCH] Fix #939. --- .../Overview/Dialogs/BolusProgressDialog.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) 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 fbd4e0ece7..192746f54b 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 @@ -70,16 +70,25 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL @Override public void onResume() { super.onResume(); - if (getDialog() != null) - getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); - MainApp.bus().register(this); - running = true; - if (bolusEnded) dismiss(); + if (bolusEnded) { + dismiss(); + } else { + if (getDialog() != null) + getDialog().getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + MainApp.bus().register(this); + running = true; + } } @Override public void dismiss() { - super.dismiss(); + try { + super.dismiss(); + } catch (IllegalStateException e) { + // dialog not running yet. onResume will try again. Set bolusEnded to make extra + // sure onResume will catch this + bolusEnded = true; + } if (helperActivity != null) { helperActivity.finish(); }