From b18573385957ebc19cc5e75465b8358435ae62bf Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 19 Jun 2017 22:55:56 +0200 Subject: [PATCH] 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();