Protection against callback looping

This commit is contained in:
TebbeUbben 2018-06-07 23:23:10 +02:00
parent aa86a49339
commit e25ebbdafa
3 changed files with 13 additions and 8 deletions

View file

@ -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);

View file

@ -64,6 +64,7 @@
android:orientation="vertical" />
<LinearLayout
android:layout_marginTop="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
@ -104,6 +105,7 @@
android:orientation="vertical" />
<LinearLayout
android:layout_marginTop="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
@ -144,6 +146,7 @@
android:orientation="vertical" />
<LinearLayout
android:layout_marginTop="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
@ -184,6 +187,7 @@
android:orientation="vertical" />
<LinearLayout
android:layout_marginTop="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
@ -224,6 +228,7 @@
android:orientation="vertical" />
<LinearLayout
android:layout_marginTop="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
@ -264,6 +269,7 @@
android:orientation="vertical" />
<LinearLayout
android:layout_marginTop="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
@ -304,6 +310,7 @@
android:orientation="vertical" />
<LinearLayout
android:layout_marginTop="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
@ -344,6 +351,7 @@
android:orientation="vertical" />
<LinearLayout
android:layout_marginTop="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
@ -384,6 +392,7 @@
android:orientation="vertical" />
<LinearLayout
android:layout_marginTop="16dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

View file

@ -99,7 +99,7 @@
<string name="loop">Loop</string>
<string name="configbuilder_loop">Loop</string>
<string name="configbuilder_loop_description">Use this to activate AndroidAPS\\' loop integration.</string>
<string name="configbuilder_loop_description">Use this to activate AndroidAPS\' loop integration.</string>
<string name="loop_aps_label">APS</string>
<string name="loop_constraintsprocessed_label">After processed constraints</string>
<string name="loop_tbrsetbypump_label">Temp basal set by pump</string>