Work with custom SharedPreferences implementation (#571)
Summary: see https://github.com/facebook/flipper/issues/450 If we want to control a custom SharedPreferences, we can create a Class as SharedPreferencesDescriptor's Subclass, override the getSharedPreferences() function to return a custom SharedPreferences instance. ## Changelog add getSharedPreferences() function in SharedPreferencesDescriptor Class Pull Request resolved: https://github.com/facebook/flipper/pull/571 Test Plan: No Reviewed By: jknoxville Differential Revision: D17738675 Pulled By: passy fbshipit-source-id: d227e7d6461194f7a01ae7b2ba53434dd71fc0d2
This commit is contained in:
committed by
Facebook Github Bot
parent
8f719b17e3
commit
86eb24b02c
@@ -101,8 +101,7 @@ public class SharedPreferencesFlipperPlugin implements FlipperPlugin {
|
|||||||
}
|
}
|
||||||
mSharedPreferences = new HashMap<>(descriptors.size());
|
mSharedPreferences = new HashMap<>(descriptors.size());
|
||||||
for (SharedPreferencesDescriptor descriptor : descriptors) {
|
for (SharedPreferencesDescriptor descriptor : descriptors) {
|
||||||
SharedPreferences preferences =
|
SharedPreferences preferences = descriptor.getSharedPreferences(context);
|
||||||
context.getSharedPreferences(descriptor.name, descriptor.mode);
|
|
||||||
preferences.registerOnSharedPreferenceChangeListener(onSharedPreferenceChangeListener);
|
preferences.registerOnSharedPreferenceChangeListener(onSharedPreferenceChangeListener);
|
||||||
mSharedPreferences.put(preferences, descriptor);
|
mSharedPreferences.put(preferences, descriptor);
|
||||||
}
|
}
|
||||||
@@ -252,5 +251,9 @@ public class SharedPreferencesFlipperPlugin implements FlipperPlugin {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SharedPreferences getSharedPreferences(Context context) {
|
||||||
|
return context.getSharedPreferences(name, mode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user