diff options
author | d34d <clark@cyngn.com> | 2016-01-12 16:58:02 -0800 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyngn.com> | 2016-01-18 17:33:37 +0000 |
commit | d530b3c1edc0cabf879ea4824fb10d5abfdf422c (patch) | |
tree | 5ce6f68bb92b422fcd88fdb2a156ff1f38b20693 /src | |
parent | 094d1fbe3c02edeb239f456bc2b9ca6f1a70cbf1 (diff) | |
download | packages_apps_ThemeChooser-d530b3c1edc0cabf879ea4824fb10d5abfdf422c.zip packages_apps_ThemeChooser-d530b3c1edc0cabf879ea4824fb10d5abfdf422c.tar.gz packages_apps_ThemeChooser-d530b3c1edc0cabf879ea4824fb10d5abfdf422c.tar.bz2 |
Register/Unregister observer on window visibility change
If the ThemeChooser is in a paused state, the ThemeObserver in the
component selector will still fire off when a theme is added or
removed. This causes an NPE when the loader is restarted.
This patch unregisters the content observer when the window is no
longer visible and then re-registers it once the window is visible
again.
Change-Id: I628b269eb95a7fb521470ff3b33845086ee30461
TICKET: CHOOSER-108
Diffstat (limited to 'src')
-rw-r--r-- | src/com/cyngn/theme/chooser/ComponentSelector.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/com/cyngn/theme/chooser/ComponentSelector.java b/src/com/cyngn/theme/chooser/ComponentSelector.java index 5c59b31..f3f4af2 100644 --- a/src/com/cyngn/theme/chooser/ComponentSelector.java +++ b/src/com/cyngn/theme/chooser/ComponentSelector.java @@ -197,6 +197,19 @@ public class ComponentSelector extends LinearLayout mThemesObserver.unregister(); } + @Override + protected void onWindowVisibilityChanged(int visibility) { + super.onWindowVisibilityChanged(visibility); + // Window visibility transitions as follows + // VISIBLE -> INVISIBLE -> GONE + // GONE -> INVISIBLE -> VISIBLE + if (visibility == View.GONE) { + mThemesObserver.unregister(); + } else if (visibility == View.VISIBLE) { + mThemesObserver.register(); + } + } + public void setComponentType(String component) { setComponentType(component, null, DEFAULT_COMPONENT_ID); } |