From c4a5285c241d68c8606ce9a99b012226697f908f Mon Sep 17 00:00:00 2001 From: Timm Korte Date: Sat, 3 Feb 2018 11:57:12 +0100 Subject: [PATCH 1/2] update bg for treatment in the past via careportal --- .../Careportal/Dialogs/NewNSTreatmentDialog.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 58d0603301..5b94f882e6 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 @@ -29,6 +29,7 @@ import com.wdullaer.materialdatetimepicker.date.DatePickerDialog; import com.wdullaer.materialdatetimepicker.time.RadialPickerLayout; import com.wdullaer.materialdatetimepicker.time.TimePickerDialog; +import org.apache.commons.lang3.ObjectUtils; import org.json.JSONException; import org.json.JSONObject; import org.slf4j.Logger; @@ -38,6 +39,7 @@ import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; +import java.util.List; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; @@ -45,6 +47,7 @@ import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.GlucoseStatus; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.ProfileStore; +import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.db.CareportalEvent; import info.nightscout.androidaps.db.ProfileSwitch; import info.nightscout.androidaps.db.Source; @@ -407,12 +410,23 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick else layout.setVisibility(View.GONE); } + private void updateBGforDateTime() { + long millis = eventTime.getTime() - (150 * 1000L); // 2,5 * 60 * 1000 + List data = MainApp.getDbHelper().getBgreadingsDataFromTime(millis, true); + if ((data.size() > 0) && + (data.get(0).date > millis - 7 * 60 * 1000L) && + (data.get(0).date < millis + 7 * 60 * 1000L)) { + editBg.setValue(data.get(0).value); + } + } + @Override public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth) { eventTime.setYear(year - 1900); eventTime.setMonth(monthOfYear); eventTime.setDate(dayOfMonth); dateButton.setText(DateUtil.dateString(eventTime)); + updateBGforDateTime(); } @Override @@ -421,6 +435,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick eventTime.setMinutes(minute); eventTime.setSeconds(second); timeButton.setText(DateUtil.timeString(eventTime)); + updateBGforDateTime(); } From c33232108d8223bc09c8118348524d9d9e74f48d Mon Sep 17 00:00:00 2001 From: Timm Korte Date: Sat, 3 Feb 2018 14:57:36 +0100 Subject: [PATCH 2/2] remote unused import --- .../plugins/Careportal/Dialogs/NewNSTreatmentDialog.java | 1 - 1 file changed, 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 5b94f882e6..2113ee1964 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 @@ -29,7 +29,6 @@ import com.wdullaer.materialdatetimepicker.date.DatePickerDialog; import com.wdullaer.materialdatetimepicker.time.RadialPickerLayout; import com.wdullaer.materialdatetimepicker.time.TimePickerDialog; -import org.apache.commons.lang3.ObjectUtils; import org.json.JSONException; import org.json.JSONObject; import org.slf4j.Logger;