diff options
author | Bobby Georgescu <georgescu@google.com> | 2012-08-23 13:23:02 -0700 |
---|---|---|
committer | Bobby Georgescu <georgescu@google.com> | 2012-08-23 13:38:27 -0700 |
commit | c760a5c49774c90b97ae818c6ee4e14825361b4b (patch) | |
tree | a00bac4b2e31b902bf092195c7e02a506b5b35b8 /src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java | |
parent | 85ff0017174fec835e5b1e1e5b924f9aeee501e1 (diff) | |
download | android_packages_apps_Gallery2-c760a5c49774c90b97ae818c6ee4e14825361b4b.tar.gz android_packages_apps_Gallery2-c760a5c49774c90b97ae818c6ee4e14825361b4b.tar.bz2 android_packages_apps_Gallery2-c760a5c49774c90b97ae818c6ee4e14825361b4b.zip |
Fix ANRs in Gallery
Bug: 7041769
Change-Id: Idc2a266bffd0d2c641fba69cfede13e1e83f276b
Diffstat (limited to 'src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java')
-rw-r--r-- | src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java b/src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java index 475906c81..250d17a2b 100644 --- a/src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java +++ b/src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java @@ -1,10 +1,13 @@ package com.android.gallery3d.ui; +import android.os.ConditionVariable; + import com.android.gallery3d.ui.GLRoot.OnGLIdleListener; public class PreparePageFadeoutTexture implements OnGLIdleListener { + private static final long TIMEOUT = FadeTexture.DURATION; private RawTexture mTexture; - private boolean mResultReady = false; + private ConditionVariable mResultReady = new ConditionVariable(false); private GLView mRootPane; public PreparePageFadeoutTexture(int w, int h, GLView rootPane) { @@ -13,14 +16,11 @@ public class PreparePageFadeoutTexture implements OnGLIdleListener { } public synchronized RawTexture get() { - try { - while (!mResultReady) { - wait(); - } - } catch (InterruptedException e) { - // Since this is just used for a transition, not that important + if (mResultReady.block(TIMEOUT)) { + return mTexture; + } else { + return null; } - return mTexture; } @Override @@ -28,10 +28,7 @@ public class PreparePageFadeoutTexture implements OnGLIdleListener { canvas.beginRenderTarget(mTexture); mRootPane.render(canvas); canvas.endRenderTarget(); - synchronized (this) { - mResultReady = true; - notifyAll(); - } + mResultReady.open(); return false; } } |