summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/ui/PositionController.java
diff options
context:
space:
mode:
authorChih-Chung Chang <chihchung@google.com>2012-04-17 12:56:08 +0800
committerChih-Chung Chang <chihchung@google.com>2012-04-17 12:56:08 +0800
commit6e32315ba37592eae9d16310d48ce4dbd4a45c5e (patch)
tree260f3da6e3d396de48f052ac4e4dd74168f191db /src/com/android/gallery3d/ui/PositionController.java
parent0fd46993facd2d2ac80eab64e4f0f8c8e79350dc (diff)
downloadandroid_packages_apps_Snap-6e32315ba37592eae9d16310d48ce4dbd4a45c5e.tar.gz
android_packages_apps_Snap-6e32315ba37592eae9d16310d48ce4dbd4a45c5e.tar.bz2
android_packages_apps_Snap-6e32315ba37592eae9d16310d48ce4dbd4a45c5e.zip
Slower scrolling for fling in filmstrip mode.
Also don't animate scale for the first image size. Change-Id: I6a71c00e813bd203e9f454bc9a776eadec06fd78
Diffstat (limited to 'src/com/android/gallery3d/ui/PositionController.java')
-rw-r--r--src/com/android/gallery3d/ui/PositionController.java26
1 files changed, 18 insertions, 8 deletions
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;