summaryrefslogtreecommitdiffstats
path: root/core/java/android/widget
diff options
context:
space:
mode:
authorCary Clark <cary@android.com>2009-08-31 16:08:42 -0400
committerCary Clark <cary@android.com>2009-09-01 09:34:21 -0400
commit278ce05b52a47a09d2177435b533f4ecb1b9c4da (patch)
tree25f1f58767a31abc8ca65fe67eb9ff5e6f3d34e1 /core/java/android/widget
parent05c9ed9ce1d920c322ee1431cfed64541f0acf3c (diff)
downloadframeworks_base-278ce05b52a47a09d2177435b533f4ecb1b9c4da.zip
frameworks_base-278ce05b52a47a09d2177435b533f4ecb1b9c4da.tar.gz
frameworks_base-278ce05b52a47a09d2177435b533f4ecb1b9c4da.tar.bz2
accelerate consecutive flings
Use the fact that the scroller keeps track of the current velocity to accelerate subsequent flings. The current velocity is added to the new velocity if the flings are in the same general direction and if the fling animation hasn't been aborted. This makes it easier to move to the top or bottom of very large pages (either in overview mode or reading mode) by taking consecutive flings as a cue from the user that they want to page faster. The user can stop the fling with any action as before. fixes http://b/issue?id=2066090
Diffstat (limited to 'core/java/android/widget')
-rw-r--r--core/java/android/widget/Scroller.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/core/java/android/widget/Scroller.java b/core/java/android/widget/Scroller.java
index 381641f..11dab02 100644
--- a/core/java/android/widget/Scroller.java
+++ b/core/java/android/widget/Scroller.java
@@ -133,6 +133,17 @@ public class Scroller {
}
/**
+ * @hide
+ * Returns the current velocity.
+ *
+ * @return The original velocity less the deceleration. Result may be
+ * negative.
+ */
+ public float getCurrVelocity() {
+ return mVelocity - mDeceleration * timePassed() / 2000.0f;
+ }
+
+ /**
* Returns the start X offset in the scroll.
*
* @return The start X offset as an absolute distance from the origin.