From df3dff194064499e079f1c53732fab10381e5051 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 19 Jun 2017 22:32:54 +0200 Subject: [PATCH 1/3] revert magic constant --- .../androidaps/plugins/Overview/OverviewFragment.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java index 3b0ba86782..26feb54704 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java @@ -1163,12 +1163,12 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, predHours = Math.min(2, predHours); predHours = Math.max(0, predHours); hoursToFetch = rangeToDisplay - predHours; - toTime = calendar.getTimeInMillis() + 60000; // little bit more to avoid wrong rounding + toTime = calendar.getTimeInMillis() + 100000; // little bit more to avoid wrong rounding - Graphview specific fromTime = toTime - hoursToFetch * 60 * 60 * 1000L; endTime = toTime + predHours * 60 * 60 * 1000L; } else { hoursToFetch = rangeToDisplay; - toTime = calendar.getTimeInMillis() + 600000; // little bit more to avoid wrong rounding + toTime = calendar.getTimeInMillis() + 100000; // little bit more to avoid wrong rounding - Graphview specific fromTime = toTime - hoursToFetch * 60 * 60 * 1000L; endTime = toTime; } From b18573385957ebc19cc5e75465b8358435ae62bf Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 19 Jun 2017 22:55:56 +0200 Subject: [PATCH 2/3] more checks for null --- .../plugins/ConfigBuilder/ConfigBuilderPlugin.java | 2 +- .../nightscout/androidaps/plugins/Loop/LoopPlugin.java | 6 ++++++ .../androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java | 7 +++++++ .../androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java | 7 +++++++ .../PersistentNotificationPlugin.java | 3 +++ 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java index 01b483c116..6a18084b5e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java @@ -1018,7 +1018,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain if (profileSwitch != null) { if (profileSwitch.profileJson != null) { return profileSwitch.getProfileObject(); - } else { + } else if (activeProfile.getProfile() != null){ Profile profile = activeProfile.getProfile().getSpecificProfile(profileSwitch.profileName); if (profile != null) return profile; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java index 0639036d10..d3f59de5ad 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java @@ -234,6 +234,12 @@ public class LoopPlugin implements PluginBase { return; } + if (configBuilder.getProfile() == null) { + log.debug(MainApp.sResources.getString(R.string.noprofileselected)); + MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.noprofileselected))); + return; + } + // Check if pump info is loaded if (configBuilder.getBaseBasalRate() < 0.01d) return; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java index df0c293d80..f7adaef6a8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java @@ -135,6 +135,13 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface { Profile profile = MainApp.getConfigBuilder().getProfile(); PumpInterface pump = MainApp.getConfigBuilder(); + if (profile == null) { + MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.instance().getString(R.string.noprofileselected))); + if (Config.logAPSResult) + log.debug(MainApp.instance().getString(R.string.noprofileselected)); + return; + } + if (!isEnabled(PluginBase.APS)) { MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.instance().getString(R.string.openapsma_disabled))); if (Config.logAPSResult) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java index caa6765aca..fe2b017133 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java @@ -133,6 +133,13 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface { Profile profile = MainApp.getConfigBuilder().getProfile(); PumpInterface pump = MainApp.getConfigBuilder(); + if (profile == null) { + MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.instance().getString(R.string.noprofileselected))); + if (Config.logAPSResult) + log.debug(MainApp.instance().getString(R.string.noprofileselected)); + return; + } + if (!isEnabled(PluginBase.APS)) { MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.instance().getString(R.string.openapsma_disabled))); if (Config.logAPSResult) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java index 10ebb71848..5723a7d480 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java @@ -115,6 +115,9 @@ public class PersistentNotificationPlugin implements PluginBase { String line1 = ctx.getString(R.string.noprofile); + + if (MainApp.getConfigBuilder().getActiveProfileInterface() == null) + return; String units = MainApp.getConfigBuilder().getProfileUnits(); From 745f9270eeb113598851b6613058b92c3c194009 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 19 Jun 2017 23:08:56 +0200 Subject: [PATCH 3/3] one more null check --- .../Persistentnotification/PersistentNotificationPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java index 5723a7d480..e64e3375e2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java @@ -116,7 +116,7 @@ public class PersistentNotificationPlugin implements PluginBase { String line1 = ctx.getString(R.string.noprofile); - if (MainApp.getConfigBuilder().getActiveProfileInterface() == null) + if (MainApp.getConfigBuilder().getActiveProfileInterface() == null || MainApp.getConfigBuilder().getProfile() == null) return; String units = MainApp.getConfigBuilder().getProfileUnits();