Skip to content

Commit

Permalink
✨ Add onChangeListener
Browse files Browse the repository at this point in the history
  • Loading branch information
ShawnLin013 committed Mar 19, 2017
1 parent 1814a01 commit 2ef1da5
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 135 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
/.idea
.DS_Store
/build
/captures
22 changes: 0 additions & 22 deletions .idea/compiler.xml

This file was deleted.

3 changes: 0 additions & 3 deletions .idea/copyright/profiles_settings.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/encodings.xml

This file was deleted.

27 changes: 0 additions & 27 deletions .idea/gradle.xml

This file was deleted.

46 changes: 0 additions & 46 deletions .idea/misc.xml

This file was deleted.

10 changes: 0 additions & 10 deletions .idea/modules.xml

This file was deleted.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ android {
}

dependencies {
compile 'com.google.code.gson:gson:2.6.2'
compile 'com.google.code.gson:gson:2.7'
}

publish {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}

0 comments on commit 2ef1da5

Please sign in to comment.