Unregister shared preferences properly

This commit is contained in:
Milos Kozak 2020-03-06 19:13:33 +01:00
parent 15ffb5b596
commit ac70c89eee

View file

@ -112,6 +112,13 @@ class MyPreferenceFragment : PreferenceFragmentCompat(), OnSharedPreferenceChang
outState.putInt("id", pluginId) outState.putInt("id", pluginId)
} }
override fun onDestroy() {
super.onDestroy()
PreferenceManager
.getDefaultSharedPreferences(context)
.unregisterOnSharedPreferenceChangeListener(this)
}
private fun addPreferencesFromResourceIfEnabled(p: PluginBase?, rootKey: String?, enabled: Boolean) { private fun addPreferencesFromResourceIfEnabled(p: PluginBase?, rootKey: String?, enabled: Boolean) {
if (enabled) addPreferencesFromResourceIfEnabled(p, rootKey) if (enabled) addPreferencesFromResourceIfEnabled(p, rootKey)
} }