From fba3016912be114bab822d9dc3c6e206ed6a9207 Mon Sep 17 00:00:00 2001 From: Erik Johansson Date: Thu, 22 Feb 2018 21:07:37 +0100 Subject: [PATCH] Add missing listener unregister Also don't call getContext() directly as that requries newer API version. --- .../openscale/gui/preferences/MeasurementPreferences.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/android_app/app/src/main/java/com/health/openscale/gui/preferences/MeasurementPreferences.java b/android_app/app/src/main/java/com/health/openscale/gui/preferences/MeasurementPreferences.java index 6b815249..1fe5b0c7 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/preferences/MeasurementPreferences.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/preferences/MeasurementPreferences.java @@ -213,12 +213,18 @@ public class MeasurementPreferences extends PreferenceFragment implements Shared getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this); } + @Override + public void onPause() { + getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this); + super.onPause(); + } + @Override public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { updatePrefSummary(findPreference(key)); if (!key.equals(MeasurementView.PREF_MEASUREMENT_ORDER)) { measurementOrderCategory.removeAll(); - updateMeasurementOrderScreen(getContext(), measurementOrderCategory); + updateMeasurementOrderScreen(getActivity().getApplicationContext(), measurementOrderCategory); } }