зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1257934 - Make the GeckoPreferences pref handler a static class; r=sebastian
The pref handler class in GeckoPreferences doesn't need a reference back to GeckoPreferences, so it's better to make it a static class rather than a (non-static) anonymous inner class, in order to avoid leaking the GeckoPreferences instance inadvertently. To avoid confusion, the patch also renames the class to "PrefCallbacks", because GeckoPreferences already has an unrelated interface named "PrefHandler".
This commit is contained in:
Родитель
126366bd4a
Коммит
dfd67cc6c8
|
@ -1453,16 +1453,19 @@ OnSharedPreferenceChangeListener
|
|||
}
|
||||
|
||||
// Initialize preferences by requesting the preference values from Gecko
|
||||
private PrefsHelper.PrefHandler getGeckoPreferences(final PreferenceGroup screen,
|
||||
ArrayList<String> prefs) {
|
||||
private static class PrefCallbacks extends PrefsHelper.PrefHandlerBase {
|
||||
private final PreferenceGroup screen;
|
||||
|
||||
public PrefCallbacks(final PreferenceGroup screen) {
|
||||
this.screen = screen;
|
||||
}
|
||||
|
||||
final PrefsHelper.PrefHandler prefHandler = new PrefsHelper.PrefHandlerBase() {
|
||||
private Preference getField(String prefName) {
|
||||
return screen.findPreference(prefName);
|
||||
}
|
||||
|
||||
// Handle v14 TwoStatePreference with backwards compatibility.
|
||||
class CheckBoxPrefSetter {
|
||||
private static class CheckBoxPrefSetter {
|
||||
public void setBooleanPref(Preference preference, boolean value) {
|
||||
if ((preference instanceof CheckBoxPreference) &&
|
||||
((CheckBoxPreference) preference).isChecked() != value) {
|
||||
|
@ -1471,7 +1474,7 @@ OnSharedPreferenceChangeListener
|
|||
}
|
||||
}
|
||||
|
||||
class TwoStatePrefSetter extends CheckBoxPrefSetter {
|
||||
private static class TwoStatePrefSetter extends CheckBoxPrefSetter {
|
||||
@Override
|
||||
public void setBooleanPref(Preference preference, boolean value) {
|
||||
if ((preference instanceof TwoStatePreference) &&
|
||||
|
@ -1547,7 +1550,11 @@ OnSharedPreferenceChangeListener
|
|||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private PrefsHelper.PrefHandler getGeckoPreferences(final PreferenceGroup screen,
|
||||
ArrayList<String> prefs) {
|
||||
final PrefsHelper.PrefHandler prefHandler = new PrefCallbacks(screen);
|
||||
final String[] prefNames = prefs.toArray(new String[prefs.size()]);
|
||||
PrefsHelper.addObserver(prefNames, prefHandler);
|
||||
return prefHandler;
|
||||
|
|
Загрузка…
Ссылка в новой задаче