dismiss bolus progress dialog when Queue is empty

This commit is contained in:
AdrianLxM 2018-05-04 12:23:51 +02:00
parent f7532b31be
commit 5c8e99b191
2 changed files with 14 additions and 1 deletions

View file

@ -70,6 +70,9 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
@Override
public void onResume() {
super.onResume();
if(!ConfigBuilderPlugin.getCommandQueue().bolusInQueue()) {
bolusEnded = true;
}
if (bolusEnded) {
dismiss();
} else {

View file

@ -162,8 +162,18 @@ public class CommandQueue {
tempCommandQueue.readStatus(reason, callback);
}
public synchronized boolean bolusInQueue(){
if(isRunning(Command.CommandType.BOLUS)) return true;
for (int i = 0; i < queue.size(); i++) {
if (queue.get(i).commandType == Command.CommandType.BOLUS) {
return true;
}
}
return false;
}
// returns true if command is queued
public boolean bolus(DetailedBolusInfo detailedBolusInfo, Callback callback) {
public synchronized boolean bolus(DetailedBolusInfo detailedBolusInfo, Callback callback) {
Command.CommandType type = detailedBolusInfo.isSMB ? Command.CommandType.SMB_BOLUS : Command.CommandType.BOLUS;
if(type.equals(Command.CommandType.BOLUS) && detailedBolusInfo.carbs > 0 && detailedBolusInfo.insulin == 0){