From 9766b4eccb79fece6a22a9719d37114c796d6c1b Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 3 Jul 2016 18:44:02 +0200 Subject: [PATCH] fix bug when app is running without loop --- .../java/info/nightscout/androidaps/Config.java | 2 +- .../ConfigBuilder/ConfigBuilderFragment.java | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/Config.java b/app/src/main/java/info/nightscout/androidaps/Config.java index 5719010eb4..c6908d2296 100644 --- a/app/src/main/java/info/nightscout/androidaps/Config.java +++ b/app/src/main/java/info/nightscout/androidaps/Config.java @@ -11,7 +11,7 @@ public class Config { public static final boolean OPENAPSMAENABLED = APS && true; public static final boolean LOOPENABLED = APS && true; public static final boolean OBJECTIVESENABLED = APS && true; - public static final boolean CAREPORTALENABLED = true; + public static final boolean CAREPORTALENABLED = APS && true; public static final boolean detailedLog = true; public static final boolean logFunctionCalls = true; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderFragment.java index b6ea975a67..f0f95348cf 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderFragment.java @@ -616,11 +616,13 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI break; case PluginBase.LOOP: activeLoop = (LoopFragment) getTheOneEnabledInArray(pluginsInCategory); - if (Config.logConfigBuilder) - log.debug("Selected loop interface: " + activeLoop.getName()); - for (PluginBase p : pluginsInCategory) { - if (!p.getName().equals(activeLoop.getName())) { - p.setFragmentVisible(false); + if (activeLoop != null) { + if (Config.logConfigBuilder) + log.debug("Selected loop interface: " + activeLoop.getName()); + for (PluginBase p : pluginsInCategory) { + if (!p.getName().equals(activeLoop.getName())) { + p.setFragmentVisible(false); + } } } break; @@ -649,6 +651,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI } } + @Nullable private PluginBase getTheOneEnabledInArray(ArrayList pluginsInCategory) { PluginBase found = null; for (PluginBase p : pluginsInCategory) { @@ -661,7 +664,7 @@ public class ConfigBuilderFragment extends Fragment implements PluginBase, PumpI } } // If none enabled, enable first one - if (found == null) + if (found == null && pluginsInCategory.size() > 0) found = pluginsInCategory.get(0); return found; }