Merge pull request #539 from jotomo/queue-bolus-constraints

Apply bolus constraint before issuing the bolus
This commit is contained in:
Milos Kozak 2017-12-20 13:25:02 +01:00 committed by GitHub
commit eb34345ee2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -153,6 +153,10 @@ public class CommandQueue {
// remove all unfinished boluses // remove all unfinished boluses
removeAll(Command.CommandType.BOLUS); removeAll(Command.CommandType.BOLUS);
// apply constraints
detailedBolusInfo.insulin = MainApp.getConfigBuilder().applyBolusConstraints(detailedBolusInfo.insulin);
detailedBolusInfo.carbs = MainApp.getConfigBuilder().applyCarbsConstraints((int) detailedBolusInfo.carbs);
// add new command to queue // add new command to queue
add(new CommandBolus(detailedBolusInfo, callback)); add(new CommandBolus(detailedBolusInfo, callback));
@ -162,12 +166,8 @@ public class CommandQueue {
MainApp.bus().post(new EventBolusRequested(detailedBolusInfo.insulin)); MainApp.bus().post(new EventBolusRequested(detailedBolusInfo.insulin));
// Bring up bolus progress dialog // Bring up bolus progress dialog
detailedBolusInfo.insulin = MainApp.getConfigBuilder().applyBolusConstraints(detailedBolusInfo.insulin);
detailedBolusInfo.carbs = MainApp.getConfigBuilder().applyCarbsConstraints((int) detailedBolusInfo.carbs);
BolusProgressDialog bolusProgressDialog = null;
if (detailedBolusInfo.context != null) { if (detailedBolusInfo.context != null) {
bolusProgressDialog = new BolusProgressDialog(); BolusProgressDialog bolusProgressDialog = new BolusProgressDialog();
bolusProgressDialog.setInsulin(detailedBolusInfo.insulin); bolusProgressDialog.setInsulin(detailedBolusInfo.insulin);
bolusProgressDialog.show(((AppCompatActivity) detailedBolusInfo.context).getSupportFragmentManager(), "BolusProgress"); bolusProgressDialog.show(((AppCompatActivity) detailedBolusInfo.context).getSupportFragmentManager(), "BolusProgress");
} else { } else {