diff options
author | Bobby Georgescu <georgescu@google.com> | 2012-10-17 14:50:47 -0700 |
---|---|---|
committer | Bobby Georgescu <georgescu@google.com> | 2012-10-17 17:14:22 -0700 |
commit | 4831c7494373c360062a7becac820eba3bc39287 (patch) | |
tree | fe63ed1fa41f35d8ecf630d65f7ce440ed91dbe4 /src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java | |
parent | 43b906d81caa4379eae1a1643194c8b3d34b1ad5 (diff) | |
download | android_packages_apps_Gallery2-4831c7494373c360062a7becac820eba3bc39287.tar.gz android_packages_apps_Gallery2-4831c7494373c360062a7becac820eba3bc39287.tar.bz2 android_packages_apps_Gallery2-4831c7494373c360062a7becac820eba3bc39287.zip |
Big refactor, additions to state transition animations
Bug: 7362944
Refactored a lot of the state transitions code, adding
support for definable transition animations and defining
distinct outgoing and incoming animations.
Change-Id: I31a69057ea1b72dd3185cec656e59b11fdb528c1
Diffstat (limited to 'src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java')
-rw-r--r-- | src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java b/src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java index 5152fc9bb..36e7f4b82 100644 --- a/src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java +++ b/src/com/android/gallery3d/ui/PreparePageFadeoutTexture.java @@ -6,7 +6,7 @@ import com.android.gallery3d.app.AbstractGalleryActivity; import com.android.gallery3d.ui.GLRoot.OnGLIdleListener; public class PreparePageFadeoutTexture implements OnGLIdleListener { - private static final long TIMEOUT = 500; + private static final long TIMEOUT = 200; public static final String KEY_FADE_TEXTURE = "fade_texture"; private RawTexture mTexture; @@ -15,10 +15,20 @@ public class PreparePageFadeoutTexture implements OnGLIdleListener { private GLView mRootPane; public PreparePageFadeoutTexture(GLView rootPane) { - mTexture = new RawTexture(rootPane.getWidth(), rootPane.getHeight(), true); + int w = rootPane.getWidth(); + int h = rootPane.getHeight(); + if (w == 0 || h == 0) { + mCancelled = true; + return; + } + mTexture = new RawTexture(w, h, true); mRootPane = rootPane; } + public boolean isCancelled() { + return mCancelled; + } + public synchronized RawTexture get() { if (mCancelled) { return null; @@ -32,25 +42,26 @@ public class PreparePageFadeoutTexture implements OnGLIdleListener { @Override public boolean onGLIdle(GLCanvas canvas, boolean renderRequested) { - if(!mCancelled) { + if (!mCancelled) { + try { canvas.beginRenderTarget(mTexture); mRootPane.render(canvas); canvas.endRenderTarget(); - } else { + } catch (RuntimeException e) { mTexture = null; } - mResultReady.open(); - return false; + } else { + mTexture = null; + } + mResultReady.open(); + return false; } - public static boolean prepareFadeOutTexture(AbstractGalleryActivity activity, + public static void prepareFadeOutTexture(AbstractGalleryActivity activity, GLView rootPane) { - if (rootPane.getWidth() == 0 || rootPane.getHeight() == 0) { - // The view hasn't been measured yet, just abort the animation - return false; - } - GLRoot root = activity.getGLRoot(); PreparePageFadeoutTexture task = new PreparePageFadeoutTexture(rootPane); + if (task.isCancelled()) return; + GLRoot root = activity.getGLRoot(); RawTexture texture = null; root.unlockRenderThread(); try { @@ -61,9 +72,8 @@ public class PreparePageFadeoutTexture implements OnGLIdleListener { } if (texture == null) { - return false; + return; } activity.getTransitionStore().put(KEY_FADE_TEXTURE, texture); - return true; } } |