diff options
author | Michael Jurka <mikejurka@google.com> | 2013-04-03 16:25:02 -0700 |
---|---|---|
committer | Arne Coucheron <arco68@gmail.com> | 2013-08-12 16:55:05 +0200 |
commit | 8f25a8cafe1ac1dcfcf06e672a107a822bedfcba (patch) | |
tree | 3ed660af5ee03be34fc9f9887ce5aed695e25034 /src | |
parent | fa2a20fd163f345974478eabdc0bf48a69492aaf (diff) | |
download | android_packages_apps_Trebuchet-8f25a8cafe1ac1dcfcf06e672a107a822bedfcba.tar.gz android_packages_apps_Trebuchet-8f25a8cafe1ac1dcfcf06e672a107a822bedfcba.tar.bz2 android_packages_apps_Trebuchet-8f25a8cafe1ac1dcfcf06e672a107a822bedfcba.zip |
Fix crash in draw listener
Bug: 8528246
Change-Id: Ie3600bed58dc393fcf71f735213a32b51551b52d
Diffstat (limited to 'src')
-rw-r--r-- | src/com/cyanogenmod/trebuchet/Launcher.java | 11 | ||||
-rw-r--r-- | src/com/cyanogenmod/trebuchet/LauncherAnimUtils.java | 14 |
2 files changed, 20 insertions, 5 deletions
diff --git a/src/com/cyanogenmod/trebuchet/Launcher.java b/src/com/cyanogenmod/trebuchet/Launcher.java index 0e31d4cbf..fa5c7a809 100644 --- a/src/com/cyanogenmod/trebuchet/Launcher.java +++ b/src/com/cyanogenmod/trebuchet/Launcher.java @@ -1460,15 +1460,22 @@ public final class Launcher extends Activity // layers on all the workspace pages, so that transitioning to Launcher from other // apps is nice and speedy. observer.addOnDrawListener(new ViewTreeObserver.OnDrawListener() { + private boolean mStarted = false; public void onDraw() { + if (mStarted) return; + mStarted = true; // We delay the layer building a bit in order to give // other message processing a time to run. In particular // this avoids a delay in hiding the IME if it was // currently shown, because doing that may involve // some communication back with the app. mWorkspace.postDelayed(mBuildLayersRunnable, 500); - - observer.removeOnDrawListener(this); + final ViewTreeObserver.OnDrawListener listener = this; + mWorkspace.post(new Runnable() { + public void run() { + mWorkspace.getViewTreeObserver().removeOnDrawListener(listener); + } + }); return; } }); diff --git a/src/com/cyanogenmod/trebuchet/LauncherAnimUtils.java b/src/com/cyanogenmod/trebuchet/LauncherAnimUtils.java index c1d7290b3..76401af72 100644 --- a/src/com/cyanogenmod/trebuchet/LauncherAnimUtils.java +++ b/src/com/cyanogenmod/trebuchet/LauncherAnimUtils.java @@ -52,15 +52,23 @@ public class LauncherAnimUtils { // Helper method. Assumes a draw is pending, and that if the animation's duration is 0 // it should be cancelled public static void startAnimationAfterNextDraw(final Animator animator, final View view) { - final ViewTreeObserver observer = view.getViewTreeObserver(); - observer.addOnDrawListener(new ViewTreeObserver.OnDrawListener() { + view.getViewTreeObserver().addOnDrawListener(new ViewTreeObserver.OnDrawListener() { + private boolean mStarted = false; public void onDraw() { + if (mStarted) return; + mStarted = true; // Use this as a signal that the animation was cancelled if (animator.getDuration() == 0) { return; } animator.start(); - view.getViewTreeObserver().removeOnDrawListener(this); + + final ViewTreeObserver.OnDrawListener listener = this; + view.post(new Runnable() { + public void run() { + view.getViewTreeObserver().removeOnDrawListener(listener); + } + }); } }); } |