Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: adblockplussbrowser/src/main/java/org/adblockplus/sbrowser/contentblocker/util/SharedPrefsUtils.java

Issue 29674689: Issue 6289 - Fix OnSharedPreferenceChangeListener (Closed)
Patch Set: Created Jan. 19, 2018, 2:36 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « adblockplussbrowser/src/main/java/org/adblockplus/sbrowser/contentblocker/MainPreferences.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: adblockplussbrowser/src/main/java/org/adblockplus/sbrowser/contentblocker/util/SharedPrefsUtils.java
===================================================================
--- a/adblockplussbrowser/src/main/java/org/adblockplus/sbrowser/contentblocker/util/SharedPrefsUtils.java
+++ b/adblockplussbrowser/src/main/java/org/adblockplus/sbrowser/contentblocker/util/SharedPrefsUtils.java
@@ -100,68 +100,35 @@ public class SharedPrefsUtils
{
return defValues;
}
}
public static void registerOnSharedPreferenceChangeListener(Context context,
OnSharedPreferenceChangeListener listener)
{
- getDefaultSharedPreferences(context).registerOnSharedPreferenceChangeListener(
- new OnSharedPreferenceChangeListenerWrapper(listener)
- );
+ getDefaultSharedPreferences(context).registerOnSharedPreferenceChangeListener(listener);
}
public static void unregisterOnSharedPreferenceChangeListener(Context context,
OnSharedPreferenceChangeListener listener)
{
- getDefaultSharedPreferences(context).unregisterOnSharedPreferenceChangeListener(
- new OnSharedPreferenceChangeListenerWrapper(listener)
- );
+ getDefaultSharedPreferences(context).unregisterOnSharedPreferenceChangeListener(listener);
}
private static SharedPreferences getDefaultSharedPreferences(Context context)
{
return PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
}
- private static class OnSharedPreferenceChangeListenerWrapper
+ public abstract static class OnSharedPreferenceChangeListener
anton 2018/01/22 05:41:13 are you sure that it's better to use class hierarc
diegocarloslima 2018/01/22 11:09:26 With an interface, we cannot make onSharedPreferen
implements SharedPreferences.OnSharedPreferenceChangeListener
{
- private final OnSharedPreferenceChangeListener listener;
-
- OnSharedPreferenceChangeListenerWrapper(OnSharedPreferenceChangeListener listener) {
- this.listener = listener;
- }
-
@Override
- public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key)
+ public final void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key)
{
- this.listener.onSharedPreferenceChanged(key);
+ this.onSharedPreferenceChanged(key);
}
- @Override
- public boolean equals(Object obj)
- {
- if (this == obj)
- {
- return true;
- }
- else if (obj instanceof OnSharedPreferenceChangeListenerWrapper)
- {
- return this.listener.equals(((OnSharedPreferenceChangeListenerWrapper) obj).listener);
- }
- return false;
- }
-
- @Override
- public int hashCode()
- {
- return this.listener.hashCode();
- }
- }
-
- public interface OnSharedPreferenceChangeListener
- {
- void onSharedPreferenceChanged(String key);
+ protected abstract void onSharedPreferenceChanged(String key);
}
}
« no previous file with comments | « adblockplussbrowser/src/main/java/org/adblockplus/sbrowser/contentblocker/MainPreferences.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld