diff --git a/.gitignore b/.gitignore index c6cbe56..5f94008 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,7 @@ *.iml .gradle /local.properties -/.idea/workspace.xml -/.idea/libraries +/.idea .DS_Store /build /captures diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index 96cc43e..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml deleted file mode 100644 index e7bedf3..0000000 --- a/.idea/copyright/profiles_settings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index 97626ba..0000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml deleted file mode 100644 index fc8049c..0000000 --- a/.idea/gradle.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 5d19981..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 52176cb..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 7f68460..0000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/library/build.gradle b/library/build.gradle index b221b8d..3b27449 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -20,7 +20,7 @@ android { } dependencies { - compile 'com.google.code.gson:gson:2.6.2' + compile 'com.google.code.gson:gson:2.7' } publish { diff --git a/library/src/main/java/com/shawnlin/preferencesmanager/PreferencesManager.java b/library/src/main/java/com/shawnlin/preferencesmanager/PreferencesManager.java index 08e5a15..c708114 100644 --- a/library/src/main/java/com/shawnlin/preferencesmanager/PreferencesManager.java +++ b/library/src/main/java/com/shawnlin/preferencesmanager/PreferencesManager.java @@ -344,4 +344,26 @@ public static void clear() { mSharedPreferences.edit().clear().apply(); } + /** + * Registers a callback to be invoked when a change happens to a preference. + * @param listener The callback that will run. + */ + public static void registerOnChangeListener(SharedPreferences.OnSharedPreferenceChangeListener listener) { + if (mSharedPreferences == null) { + return; + } + mSharedPreferences.registerOnSharedPreferenceChangeListener(listener); + } + + /** + * Unregisters a previous callback. + * @param listener The callback that should be unregistered. + */ + public static void unregisterOnChangeListener(SharedPreferences.OnSharedPreferenceChangeListener listener) { + if (mSharedPreferences == null) { + return; + } + mSharedPreferences.unregisterOnSharedPreferenceChangeListener(listener); + } + }