summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael W <baddaemon87@gmail.com>2016-10-28 13:05:22 +0200
committerMichael W <baddaemon87@gmail.com>2016-10-28 13:05:22 +0200
commit89a23e510111735e70deab0a6629acc99bf87be0 (patch)
tree9357db672c5336e50f27042cb20b370405f20443
parent56b2153bb8e407d4b1b54fd6eefcc88245838500 (diff)
downloadpackages_apps_ThemeChooser-89a23e510111735e70deab0a6629acc99bf87be0.zip
packages_apps_ThemeChooser-89a23e510111735e70deab0a6629acc99bf87be0.tar.gz
packages_apps_ThemeChooser-89a23e510111735e70deab0a6629acc99bf87be0.tar.bz2
ThemeChooser: Fix possible IllegalArgumentException
onResume will always register the listener, no matter if it's already been registered. Add a variable to track, if the listener has been registered already. Change-Id: I294c5ab1d8dd2b12ad744bc87127a38939c4e30e Reference: BugDumps 20161021-27 L#67
-rw-r--r--src/org/cyanogenmod/theme/chooser2/ThemeFragment.java15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/org/cyanogenmod/theme/chooser2/ThemeFragment.java b/src/org/cyanogenmod/theme/chooser2/ThemeFragment.java
index e4dd0fc..2fe995c 100644
--- a/src/org/cyanogenmod/theme/chooser2/ThemeFragment.java
+++ b/src/org/cyanogenmod/theme/chooser2/ThemeFragment.java
@@ -336,6 +336,8 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
protected boolean mShowLockScreenSelectorAfterContentLoaded;
+ private boolean mListenerRegistered;
+
protected enum CustomizeResetAction {
Customize,
Reset,
@@ -552,7 +554,10 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
ThemeManager tm = getThemeManager();
if (tm != null) {
if (isThemeProcessing()) {
- tm.registerProcessingListener(this);
+ if (!mListenerRegistered) {
+ tm.registerProcessingListener(this);
+ mListenerRegistered = true;
+ }
mProcessingThemeLayout.setVisibility(View.VISIBLE);
mProcessingResources = true;
} else {
@@ -568,7 +573,10 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
ThemeManager tm = getThemeManager();
if (tm != null) {
tm.removeClient(this);
- tm.unregisterProcessingListener(this);
+ if (mListenerRegistered) {
+ tm.unregisterProcessingListener(this);
+ mListenerRegistered = false;
+ }
}
}
@@ -668,8 +676,9 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
public void onFinishedProcessing(String pkgName) {
if (pkgName.equals(mPkgName) || pkgName.equals(mBaseThemePkgName)) {
ThemeManager tm = getThemeManager();
- if (tm != null) {
+ if (tm != null && mListenerRegistered) {
tm.unregisterProcessingListener(this);
+ mListenerRegistered = false;
}
}
}