temp fix of bolus progress crash

This commit is contained in:
Milos Kozak 2016-08-18 09:10:32 +02:00
parent 38ee1402a4
commit 08d940b2fb
2 changed files with 10 additions and 5 deletions

View file

@ -351,9 +351,9 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
PumpEnactResult result = activePump.deliverTreatment(insulin, carbs, context); PumpEnactResult result = activePump.deliverTreatment(insulin, carbs, context);
bolusProgressDialog.bolusEnded = true; BolusProgressDialog.bolusEnded = true;
if (bolusProgressDialog != null && bolusProgressDialog.running) { if (bolusProgressDialog != null && BolusProgressDialog.running) {
try { try {
bolusProgressDialog.dismiss(); bolusProgressDialog.dismiss();
} catch (Exception e) { } catch (Exception e) {
@ -393,9 +393,9 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
PumpEnactResult result = activePump.deliverTreatment(insulin, carbs, context); PumpEnactResult result = activePump.deliverTreatment(insulin, carbs, context);
bolusProgressDialog.bolusEnded = true; BolusProgressDialog.bolusEnded = true;
if (bolusProgressDialog != null && bolusProgressDialog.running) { if (bolusProgressDialog != null && BolusProgressDialog.running) {
try { try {
bolusProgressDialog.dismiss(); bolusProgressDialog.dismiss();
} catch (Exception e) { } catch (Exception e) {

View file

@ -146,13 +146,18 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }
BolusProgressDialog.bolusEnded = true;
Activity activity = getActivity(); Activity activity = getActivity();
if (activity != null) { if (activity != null) {
activity.runOnUiThread( activity.runOnUiThread(
new Runnable() { new Runnable() {
@Override @Override
public void run() { public void run() {
dismiss(); try {
dismiss();
} catch (Exception e) {
e.printStackTrace(); // TODO: do this better way
}
} }
}); });
} }