Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 08190bbb authored by Fabrice Di Meglio's avatar Fabrice Di Meglio
Browse files

Fix bug #15016050 Stability: ISE in Settings: Cannot add twice the same OnSwitchChangeListener

- add/remove the OnSwitchChangeListener into onResume/onPause

Change-Id: Idb1ac3997a2dbc0ca387ed67bbbbcc1a431d8642
parent 3f7e0571
Loading
Loading
Loading
Loading
+11 −13
Original line number Diff line number Diff line
@@ -387,19 +387,6 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
            mEnabledSwitch.setEnabled(false);
            return;
        }
        mSwitchBar.addOnSwitchChangeListener(this);
    }

    @Override
    public void onStart() {
        super.onStart();
        mSwitchBar.show();
    }

    @Override
    public void onStop() {
        super.onStop();
        mSwitchBar.hide();
    }

    private boolean removePreferenceForProduction(Preference preference) {
@@ -464,6 +451,17 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
            mEnabledSwitch.setChecked(mLastEnabledState);
            setPrefsEnabledState(mLastEnabledState);
        }

        mSwitchBar.addOnSwitchChangeListener(this);
        mSwitchBar.show();
    }

    @Override
    public void onPause() {
        super.onPause();

        mSwitchBar.removeOnSwitchChangeListener(this);
        mSwitchBar.hide();
    }

    void updateCheckBox(CheckBoxPreference checkBox, boolean value) {