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); |
} |
} |