From 51e0774021bd439023377eff26e1da53b707ead4 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 25 Mar 2018 15:02:51 +0200 Subject: [PATCH] prevent creating careportal event of the same time --- .../plugins/Careportal/Dialogs/NewNSTreatmentDialog.java | 8 +++++++- 1 file changed, 7 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 d6e66b40ba..b383dd1519 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 @@ -109,6 +109,8 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick Date eventTime; + private static Integer seconds = null; + public void setOptions(OptionsToShow options, int event) { this.options = options; this.event = MainApp.sResources.getString(event); @@ -116,6 +118,10 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick public NewNSTreatmentDialog() { super(); + + if (seconds == null) { + seconds = new Double(Math.random() * 59).intValue(); + } } @Override @@ -443,7 +449,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick public void onTimeSet(RadialPickerLayout view, int hourOfDay, int minute, int second) { eventTime.setHours(hourOfDay); eventTime.setMinutes(minute); - eventTime.setSeconds(second); + eventTime.setSeconds(this.seconds++); // randomize seconds to prevent creating record of the same time, if user choose time manually timeButton.setText(DateUtil.timeString(eventTime)); updateBGforDateTime(); }