From 6e32315ba37592eae9d16310d48ce4dbd4a45c5e Mon Sep 17 00:00:00 2001 From: Chih-Chung Chang Date: Tue, 17 Apr 2012 12:56:08 +0800 Subject: Slower scrolling for fling in filmstrip mode. Also don't animate scale for the first image size. Change-Id: I6a71c00e813bd203e9f454bc9a776eadec06fd78 --- .../android/gallery3d/ui/PositionController.java | 26 +++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'src/com/android/gallery3d/ui/PositionController.java') diff --git a/src/com/android/gallery3d/ui/PositionController.java b/src/com/android/gallery3d/ui/PositionController.java index 3774cce1c..6650d246c 100644 --- a/src/com/android/gallery3d/ui/PositionController.java +++ b/src/com/android/gallery3d/ui/PositionController.java @@ -19,7 +19,7 @@ package com.android.gallery3d.ui; import android.content.Context; import android.graphics.Rect; import android.util.Log; -import android.widget.Scroller; +import android.widget.OverScroller; import com.android.gallery3d.common.Utils; import com.android.gallery3d.util.GalleryUtils; @@ -101,7 +101,7 @@ class PositionController { private FlingScroller mPageScroller; // This is used by the fling animation (film mode). - private Scroller mFilmScroller; + private OverScroller mFilmScroller; // The bound of the stable region that the focused box can stay, see the // comments above calculateStableBound() for details. @@ -146,7 +146,7 @@ class PositionController { public PositionController(Context context, Listener listener) { mListener = listener; mPageScroller = new FlingScroller(); - mFilmScroller = new Scroller(context); + mFilmScroller = new OverScroller(context); // Initialize the areas. initPlatform(); @@ -194,9 +194,11 @@ class PositionController { private void setBoxSize(int i, int width, int height, boolean isViewSize) { Box b = mBoxes.get(i); + boolean wasViewSize = b.mUseViewSize; + + // If we already have an image size, we don't want to use the view size. + if (!wasViewSize && isViewSize) return; - // If we already have image size, we don't want to use the view size. - if (isViewSize && !b.mUseViewSize) return; b.mUseViewSize = isViewSize; if (width == b.mImageW && height == b.mImageH) { @@ -207,9 +209,17 @@ class PositionController { float ratio = Math.min( (float) b.mImageW / width, (float) b.mImageH / height); - b.mCurrentScale *= ratio; - b.mFromScale *= ratio; - b.mToScale *= ratio; + // If this is the first time we receive an image size, we change the + // scale directly. Otherwise adjust the scales by a ratio, and snapback + // will animate the scale into the min/max bounds if necessary. + if (wasViewSize && !isViewSize) { + b.mCurrentScale = getMinimalScale(width, height); + b.mAnimationStartTime = NO_ANIMATION; + } else { + b.mCurrentScale *= ratio; + b.mFromScale *= ratio; + b.mToScale *= ratio; + } b.mImageW = width; b.mImageH = height; -- cgit v1.2.3