dismiss bolus progress via events

This commit is contained in:
AdrianLxM 2017-02-20 14:49:38 +01:00
parent 686e16de8d
commit 98edfc57e0
5 changed files with 42 additions and 14 deletions

View file

@ -52,6 +52,7 @@ import info.nightscout.androidaps.plugins.OpenAPSMA.DetermineBasalResultMA;
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog;
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressHelperActivity;
import info.nightscout.androidaps.plugins.Overview.Notification;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogressIfRunning;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.NSClientInternal.data.DbLogger;
@ -448,13 +449,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
BolusProgressDialog.bolusEnded = true;
if (bolusProgressDialog != null && BolusProgressDialog.running) {
try {
bolusProgressDialog.dismiss();
} catch (Exception e) {
e.printStackTrace(); // TODO: handle this better
}
}
MainApp.bus().post(new EventDismissBolusprogressIfRunning(result));
if (result.success) {
Treatment t = new Treatment();
@ -501,13 +496,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
BolusProgressDialog.bolusEnded = true;
if (bolusProgressDialog != null && BolusProgressDialog.running) {
try {
bolusProgressDialog.dismiss();
} catch (Exception e) {
e.printStackTrace(); // TODO: handle this better
}
}
MainApp.bus().post(new EventDismissBolusprogressIfRunning(result));
if (Config.logCongigBuilderActions)
log.debug("deliverTreatment insulin: " + insulin + " carbs: " + carbs + " success: " + result.success + " enacted: " + result.enacted + " bolusDelivered: " + result.bolusDelivered);

View file

@ -20,6 +20,7 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventPumpStatusChanged;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogressIfRunning;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
import info.nightscout.androidaps.plugins.DanaR.events.EventDanaRBolusStart;
@ -127,6 +128,13 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
started = true;
}
@Subscribe
public void onStatusEvent(final EventDismissBolusprogressIfRunning ev) {
if(BolusProgressDialog.running){
dismiss();
}
}
@Subscribe
public void onStatusEvent(final EventPumpStatusChanged c) {

View file

@ -0,0 +1,15 @@
package info.nightscout.androidaps.plugins.Overview.events;
import info.nightscout.androidaps.data.PumpEnactResult;
/**
* Created by adrian on 20/02/17.
*/
public class EventDismissBolusprogressIfRunning {
public final PumpEnactResult result;
public EventDismissBolusprogressIfRunning(PumpEnactResult result) {
this.result = result;
}
}

View file

@ -17,6 +17,7 @@ import info.nightscout.androidaps.events.EventTreatmentChange;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.Loop.events.EventNewOpenLoopNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogressIfRunning;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
import info.nightscout.androidaps.plugins.Wear.wearintegration.WatchUpdaterService;
import info.nightscout.utils.ToastUtils;
@ -177,6 +178,20 @@ public class WearPlugin implements PluginBase {
}
@Subscribe
public void onStatusEvent(final EventDismissBolusprogressIfRunning ev) {
String status;
if(ev.result.success){
status = MainApp.sResources.getString(R.string.success);
} else {
status = MainApp.sResources.getString(R.string.nosuccess);
}
Intent intent = new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_SEND_BOLUSPROGRESS);
intent.putExtra("progresspercent", 100);
intent.putExtra("progressstatus", status);
ctx.startService(intent);
}
public void requestActionConfirmation(String title, String message, String actionstring){
Intent intent = new Intent(ctx, WatchUpdaterService.class).setAction(WatchUpdaterService.ACTION_SEND_ACTIONCONFIRMATIONREQUEST);

View file

@ -540,4 +540,5 @@
<string name="wear_settings">Wear settings</string>
<string name="wear_detailedIOB_title">Show detailed IOB</string>
<string name="wear_detailedIOB_summary">Break down IOB into bolus and basal IOB on the watchface</string>
<string name="nosuccess">not successful - please check phone</string>
</resources>