diff options
author | Domingos Lopes <domingos86lopes+github@gmail.com> | 2016-07-03 18:03:19 -0400 |
---|---|---|
committer | Domingos Lopes <domingos86lopes+github@gmail.com> | 2016-07-03 18:03:19 -0400 |
commit | fc364c7dfee489b3174a92e5cbf31b99de8a04c5 (patch) | |
tree | 0505bb96b660a6247c4dcb937c51563bee08ebd8 /core/src | |
parent | 21a7ef168f3777b6cddcca8be817d27911476448 (diff) | |
download | AntennaPod-fc364c7dfee489b3174a92e5cbf31b99de8a04c5.zip |
convert gpodder last sync attempt listener to OnSharedPreferenceChangeListener
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/preferences/GpodnetPreferences.java | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/preferences/GpodnetPreferences.java b/core/src/main/java/de/danoeh/antennapod/core/preferences/GpodnetPreferences.java index 0062647ed..f14c9e36c 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/preferences/GpodnetPreferences.java +++ b/core/src/main/java/de/danoeh/antennapod/core/preferences/GpodnetPreferences.java @@ -62,14 +62,22 @@ public class GpodnetPreferences { private static boolean lastSyncAttemptResult; - private static Runnable syncAttemptListener; - private static boolean preferencesLoaded = false; private static SharedPreferences getPreferences() { return ClientConfig.applicationCallbacks.getApplicationInstance().getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE); } + public static void registerOnSharedPreferenceChangeListener( + SharedPreferences.OnSharedPreferenceChangeListener listener) { + getPreferences().registerOnSharedPreferenceChangeListener(listener); + } + + public static void unregisterOnSharedPreferenceChangeListener( + SharedPreferences.OnSharedPreferenceChangeListener listener) { + getPreferences().unregisterOnSharedPreferenceChangeListener(listener); + } + private static synchronized void ensurePreferencesLoaded() { if (!preferencesLoaded) { SharedPreferences prefs = getPreferences(); @@ -178,9 +186,6 @@ public class GpodnetPreferences { GpodnetPreferences.lastSyncAttemptTimestamp = timestamp; writePreference(PREF_LAST_SYNC_ATTEMPT_RESULT, result); writePreference(PREF_LAST_SYNC_ATTEMPT_TIMESTAMP, timestamp); - if (timestamp != 0 && syncAttemptListener != null) { - syncAttemptListener.run(); - } } public static String getHostname() { @@ -309,10 +314,6 @@ public class GpodnetPreferences { UserPreferences.setGpodnetNotificationsEnabled(); } - public static void setSyncAttemptListener(Runnable listener) { - syncAttemptListener = listener; - } - private static Set<String> readListFromString(String s) { Set<String> result = new HashSet<>(); for (String item : s.split(" ")) { |