JakeWharton/u2020

Debug drawer widgets should be updated onResume to keep in sync with SharedPreferences

Closed this issue · 5 comments

If you go to a second activity (ensuring that the previous activity is not destroyed), and change a setting in the debug drawer (such as latency), then go back to the first activity, the UI widgets in the debug drawer get out of sync with the preferences that back them since the widgets are only initialized in onCreate().

I've worked around this in my application by removing the @singleton annotations from the DebugAppContainer class and the module that provides it, and adding a second method bind() so the interface for AppContainer looks like this:

ViewGroup get(Activity activity);
void bind(Activity activity);

Then I call bind() in onResume of my activity.

This adds a fair amount of complexity but is kind of necessary.

Please let me know if you're interested in a PR.

None of our apps have more than one activity.
On Sep 27, 2014 11:01 PM, "Jacob Tabak" notifications@github.com wrote:

If you go to a second activity (ensuring that the previous activity is not
destroyed), and change a setting in the debug drawer (such as latency),
then go back to the first activity, the UI widgets in the debug drawer get
out of sync with the preferences that back them since the widgets only
initialized in onCreate().

I've worked around this in my application by removing the @singleton
https://github.com/Singleton annotations from the DebugAppContainer
class and the module that provides it, and adding a second method bind()
so the interface for AppContainer looks like this:

ViewGroup get(Activity activity);void bind(Activity activity);

Then I call bind() in onResume of my activity.

This adds a fair amount of complexity but is kind of necessary.

Please let me know if you're interested in a PR.


Reply to this email directly or view it on GitHub
#35.

That's fair, but I imagine many people who will learn from this app will use more than one activity.

I have no interest in implementing this. If you or anyone else wants to
submit a PR that isn't unreasonable I'll merge.
On Sep 27, 2014 11:07 PM, "Jacob Tabak" notifications@github.com wrote:

That's fair, but I imagine many people who will learn from this app will
use more than one activity.


Reply to this email directly or view it on GitHub
#35 (comment).

A better abstraction would be Observable preferences.

We're adding observable preferences. Started in #116 and see also JakeWharton/RxBinding#8.