Merge pull request #1000 from MilosKozak/bolusprogress-dismiss

IDEA: dismiss bolus progress dialog when Queue is empty
This commit is contained in:
AdrianLxM 2018-05-04 19:03:11 +02:00 committed by GitHub
commit f511b9ed39
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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){