summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/ui/ScrollerHelper.java
diff options
context:
space:
mode:
authorChih-Chung Chang <chihchung@google.com>2011-09-26 10:40:38 +0800
committerChih-Chung Chang <chihchung@google.com>2011-09-26 15:35:25 +0800
commitca07852ce136f83cc1badac7d8c0ce234570bca2 (patch)
treebf630d40cdfc149d96c8e62a8ded235e54fa0cfb /src/com/android/gallery3d/ui/ScrollerHelper.java
parentf02dacf2c5d46eb65a4d6b7ba7a85964b04001e2 (diff)
downloadandroid_packages_apps_Snap-ca07852ce136f83cc1badac7d8c0ce234570bca2.tar.gz
android_packages_apps_Snap-ca07852ce136f83cc1badac7d8c0ce234570bca2.tar.bz2
android_packages_apps_Snap-ca07852ce136f83cc1badac7d8c0ce234570bca2.zip
Fix 5223982: Add animation when scrolling hits the edge.
Change-Id: I3c5191af3fe44ba835ae9b22755613a933065bcd
Diffstat (limited to 'src/com/android/gallery3d/ui/ScrollerHelper.java')
-rw-r--r--src/com/android/gallery3d/ui/ScrollerHelper.java11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/com/android/gallery3d/ui/ScrollerHelper.java b/src/com/android/gallery3d/ui/ScrollerHelper.java
index 9f19cec96..84235185b 100644
--- a/src/com/android/gallery3d/ui/ScrollerHelper.java
+++ b/src/com/android/gallery3d/ui/ScrollerHelper.java
@@ -58,6 +58,10 @@ public class ScrollerHelper {
return mScroller.getCurrX();
}
+ public float getCurrVelocity() {
+ return mScroller.getCurrVelocity();
+ }
+
public void setPosition(int position) {
mScroller.startScroll(
position, 0, // startX, startY
@@ -77,7 +81,8 @@ public class ScrollerHelper {
mOverflingEnabled ? mOverflingDistance : 0, 0);
}
- public boolean startScroll(int distance, int min, int max) {
+ // Returns the distance that over the scroll limit.
+ public int startScroll(int distance, int min, int max) {
int currPosition = mScroller.getCurrX();
int finalPosition = mScroller.getFinalX();
int newPosition = Utils.clamp(finalPosition + distance, min, max);
@@ -85,9 +90,7 @@ public class ScrollerHelper {
mScroller.startScroll(
currPosition, 0, // startX, startY
newPosition - currPosition, 0, 0); // dx, dy, duration
- return true;
- } else {
- return false;
}
+ return finalPosition + distance - newPosition;
}
}