Commit Graph

3 Commits

Author SHA1 Message Date
Conor O'Donnell
d45bc14cce Keep strong reference to OnSharedPreferenceChangeListener (#131)
Summary:
A strong reference to the listener should be kept when calling `registerOnSharedPreferenceChangeListener`, otherwise the listener can get garbage-collected and stop working.

Mentioned in the Android SDK docs [here](https://developer.android.com/reference/android/content/SharedPreferences.html#registerOnSharedPreferenceChangeListener(android.content.SharedPreferences.OnSharedPreferenceChangeListener)):

> Caution: The preference manager does not currently store a strong reference to the listener. You must store a strong reference to the listener, or it will be susceptible to garbage collection. We recommend you keep a reference to the listener in the instance data of an object that will exist as long as you need the listener.
Closes https://github.com/facebook/Sonar/pull/131

Differential Revision: D8751484

Pulled By: xiphirx

fbshipit-source-id: e46715d637c89491770c266fc22c27db41beb042
2018-07-06 13:03:44 -07:00
Hilal Alsibai
ceb16db812 Make the shared preferences plugin more flexible
Summary:
You don't necessarily need / have your shared preferences defined in a file that is your package
name. This adds the ability to pass in the name + mode you need to read the correct shared
preferences file.

Reviewed By: sjkirby

Differential Revision: D8661573

fbshipit-source-id: 49e57b0371228eca7fc4f06e8ba65ff8cc059b11
2018-07-02 11:05:14 -07:00
Daniel Büchele
fbbf8cf16b Initial commit 🎉
fbshipit-source-id: b6fc29740c6875d2e78953b8a7123890a67930f2
Co-authored-by: Sebastian McKenzie <sebmck@fb.com>
Co-authored-by: John Knox <jknox@fb.com>
Co-authored-by: Emil Sjölander <emilsj@fb.com>
Co-authored-by: Pritesh Nandgaonkar <prit91@fb.com>
2018-06-01 11:03:58 +01:00