From ab63c2fb48b1133ec7e347d7c7078cf9df5ea476 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 27 Jun 2017 10:00:22 +0200 Subject: [PATCH 1/2] better check for app initialization --- .../androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java | 2 ++ .../plugins/IobCobCalculator/IobCobCalculatorPlugin.java | 2 ++ 2 files changed, 4 insertions(+) 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 6a18084b5e..c444603090 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 @@ -1013,6 +1013,8 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain } public Profile getProfile(long time) { + if (activeTreatments == null) + return null; //app not initialized //log.debug("Profile for: " + new Date(time).toLocaleString() + " : " + getProfileName(time)); ProfileSwitch profileSwitch = getProfileSwitchFromHistory(time); if (profileSwitch != null) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java index 26bfd6741c..da7668776a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java @@ -303,6 +303,8 @@ public class IobCobCalculatorPlugin implements PluginBase { public void calculateSensitivityData() { if (MainApp.getConfigBuilder() == null) return; // app still initializing + if (MainApp.getConfigBuilder().getProfile() == null) + return; // app still initializing //log.debug("Locking calculateSensitivityData"); synchronized (dataLock) { From 42b42a90eb8cbbc0ebd5c126b4b2c75a328efc40 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 27 Jun 2017 11:01:38 +0200 Subject: [PATCH 2/2] another check for null --- .../plugins/IobCobCalculator/IobCobCalculatorPlugin.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java index da7668776a..6b26cc00a4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java @@ -619,6 +619,8 @@ public class IobCobCalculatorPlugin implements PluginBase { if (MainApp.getConfigBuilder() == null) return; // app still initializing Profile profile = MainApp.getConfigBuilder().getProfile(); + if (profile == null) + return; // app still initializing dia = profile.getDia(); if (ev == null) { // on init no need of reset return;