From 6374c51a89678ae02c9bf4dccc17e4aeca6301c5 Mon Sep 17 00:00:00 2001 From: Joe Onorato Date: Wed, 6 Jan 2010 20:42:25 -0800 Subject: Fix bug 2337808 - zoom state gets out of sync when the surface disappears --- src/com/android/launcher2/AllAppsView.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/com/android/launcher2/AllAppsView.java') diff --git a/src/com/android/launcher2/AllAppsView.java b/src/com/android/launcher2/AllAppsView.java index 4e1d3a138..1d21da892 100644 --- a/src/com/android/launcher2/AllAppsView.java +++ b/src/com/android/launcher2/AllAppsView.java @@ -114,8 +114,10 @@ public class AllAppsView extends RSSurfaceView private boolean mShouldGainFocus; + private boolean mHaveSurface = false; private boolean mZoomDirty = false; private boolean mAnimateNextZoom; + private float mNextZoom; private float mZoom; private float mPosX; private float mVelocity; @@ -191,6 +193,10 @@ public class AllAppsView extends RSSurfaceView super.surfaceDestroyed(holder); // Without this, we leak mMessageCallback which leaks the context. mRS.mMessageCallback = null; + // We may lose any callbacks that are pending, so make sure that we re-sync that + // on the next surfaceChanged. + mZoomDirty = true; + mHaveSurface = false; } @Override @@ -199,6 +205,8 @@ public class AllAppsView extends RSSurfaceView super.surfaceChanged(holder, format, w, h); + mHaveSurface = true; + if (mRollo == null) { mRollo = new RolloRS(); mRollo.init(getResources(), w, h); @@ -633,10 +641,13 @@ public class AllAppsView extends RSSurfaceView */ public void zoom(float zoom, boolean animate) { cancelLongPress(); - if (mRollo == null) { + mNextZoom = zoom; + mAnimateNextZoom = animate; + // if we do setZoom while we don't have a surface, we won't + // get the callbacks that actually set mZoom. + if (mRollo == null || !mHaveSurface) { mZoomDirty = true; mZoom = zoom; - mAnimateNextZoom = animate; return; } else { mRollo.setZoom(zoom, animate); @@ -1040,7 +1051,7 @@ public class AllAppsView extends RSSurfaceView void dirtyCheck() { if (mZoomDirty) { - setZoom(mZoom, mAnimateNextZoom); + setZoom(mNextZoom, mAnimateNextZoom); } } -- cgit v1.2.3