From e25ebbdafa68ada7058075abfb3c17b72849115c Mon Sep 17 00:00:00 2001 From: TebbeUbben Date: Thu, 7 Jun 2018 23:23:10 +0200 Subject: [PATCH] Protection against callback looping --- .../plugins/ConfigBuilder/ConfigBuilderFragment.java | 10 +++------- app/src/main/res/layout/configbuilder_fragment.xml | 9 +++++++++ app/src/main/res/values/strings.xml | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) 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 b4971f4d7a..1bc05da5b4 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 @@ -112,6 +112,7 @@ public class ConfigBuilderFragment extends SubscriberFragment { public void onDestroyView() { super.onDestroyView(); for (PluginView pluginView : pluginViews) pluginView.unbind(); + pluginViews.clear(); } @Override @@ -203,7 +204,6 @@ public class ConfigBuilderFragment extends SubscriberFragment { private Unbinder unbinder; private PluginBase plugin; - private boolean updating = false; LinearLayout baseView; @BindView(R.id.plugin_enabled_exclusive) @@ -231,7 +231,6 @@ public class ConfigBuilderFragment extends SubscriberFragment { } public void update() { - updating = true; enabledExclusive.setVisibility(areMultipleSelectionsAllowed(plugin.getType()) ? View.GONE : View.VISIBLE); enabledInclusive.setVisibility(areMultipleSelectionsAllowed(plugin.getType()) ? View.VISIBLE : View.GONE); enabledExclusive.setChecked(plugin.isEnabled(plugin.getType())); @@ -248,21 +247,18 @@ public class ConfigBuilderFragment extends SubscriberFragment { pluginVisibility.setVisibility(plugin.hasFragment() ? View.VISIBLE : View.INVISIBLE); pluginVisibility.setEnabled(!(plugin.pluginDescription.neverVisible || plugin.pluginDescription.alwayVisible) && plugin.isEnabled(plugin.getType())); pluginVisibility.setChecked(plugin.isFragmentVisible()); - updating = false; } - @OnCheckedChanged(R.id.plugin_visibility) + @OnClick(R.id.plugin_visibility) void onVisibilityChanged() { - if (updating) return; plugin.setFragmentVisible(plugin.getType(), pluginVisibility.isChecked()); ConfigBuilderPlugin.getPlugin().storeSettings("CheckedCheckboxVisible"); MainApp.bus().post(new EventRefreshGui()); ConfigBuilderPlugin.getPlugin().logPluginStatus(); } - @OnCheckedChanged({R.id.plugin_enabled_exclusive, R.id.plugin_enabled_inclusive}) + @OnClick({R.id.plugin_enabled_exclusive, R.id.plugin_enabled_inclusive}) void onEnabledChanged() { - if (updating) return; boolean enabled = enabledExclusive.getVisibility() == View.VISIBLE ? enabledExclusive.isChecked() : enabledInclusive.isChecked(); plugin.setPluginEnabled(plugin.getType(), enabled); plugin.setFragmentVisible(plugin.getType(), enabled); diff --git a/app/src/main/res/layout/configbuilder_fragment.xml b/app/src/main/res/layout/configbuilder_fragment.xml index 4b4cbad62c..e02b30b2c8 100644 --- a/app/src/main/res/layout/configbuilder_fragment.xml +++ b/app/src/main/res/layout/configbuilder_fragment.xml @@ -64,6 +64,7 @@ android:orientation="vertical" /> @@ -104,6 +105,7 @@ android:orientation="vertical" /> @@ -144,6 +146,7 @@ android:orientation="vertical" /> @@ -184,6 +187,7 @@ android:orientation="vertical" /> @@ -224,6 +228,7 @@ android:orientation="vertical" /> @@ -264,6 +269,7 @@ android:orientation="vertical" /> @@ -304,6 +310,7 @@ android:orientation="vertical" /> @@ -344,6 +351,7 @@ android:orientation="vertical" /> @@ -384,6 +392,7 @@ android:orientation="vertical" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fda09189d1..fb4a4b7e45 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -99,7 +99,7 @@ Loop Loop - Use this to activate AndroidAPS\\' loop integration. + Use this to activate AndroidAPS\' loop integration. APS After processed constraints Temp basal set by pump