From 480b832efe82ffcfdeb715ab216ed903059e6d27 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Wed, 18 Jan 2017 16:48:45 +0100 Subject: [PATCH] temptarget zero-duration cleanup --- .../plugins/Careportal/Dialogs/NewNSTreatmentDialog.java | 3 +++ .../plugins/TempTargetRange/TempTargetRangeFragment.java | 3 +++ .../plugins/TempTargetRange/TempTargetRangePlugin.java | 1 - 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java index 20229af0f0..00de620ba1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java @@ -624,6 +624,9 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick if(tempTarget.duration != 0) { tempTarget.low = NSProfile.toMgdl(data.getDouble("targetBottom"), MainApp.getConfigBuilder().getActiveProfile().getProfile().getUnits()); tempTarget.high = NSProfile.toMgdl(data.getDouble("targetTop"), MainApp.getConfigBuilder().getActiveProfile().getProfile().getUnits()); + } else { + tempTarget.low = 0; + tempTarget.high = 0; } tempTarget.setTimeIndex(tempTarget.getTimeIndex()); Dao dao = MainApp.getDbHelper().getDaoTempTargets(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/TempTargetRange/TempTargetRangeFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/TempTargetRange/TempTargetRangeFragment.java index e5d16aa909..070e0dd6ab 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/TempTargetRange/TempTargetRangeFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/TempTargetRange/TempTargetRangeFragment.java @@ -84,6 +84,9 @@ public class TempTargetRangeFragment extends Fragment implements View.OnClickLis if (tempTarget.isInProgress()) holder.dateLinearLayout.setBackgroundColor(MainApp.instance().getResources().getColor(R.color.colorInProgress)); else if (tempTarget.duration == 0){ + holder.low.setText(""); + holder.high.setText(""); + holder.duration.setText(R.string.cancel); holder.dateLinearLayout.setBackgroundColor(MainApp.instance().getResources().getColor(R.color.notificationUrgent)); } else diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/TempTargetRange/TempTargetRangePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/TempTargetRange/TempTargetRangePlugin.java index bad15d0c55..177ed8d9fe 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/TempTargetRange/TempTargetRangePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/TempTargetRange/TempTargetRangePlugin.java @@ -91,7 +91,6 @@ public class TempTargetRangePlugin implements PluginBase { @Nullable public TempTarget getTempTargetInProgress(long time) { - // for (int i = tempTargets.size() - 1; i >= 0; i--) { for (int i = 0; i < tempTargets.size(); i++) { // a zero-duration temp target will cancel all prior targets if (tempTargets.get(i).duration == 0) return null;