From 9d5b488abeb6acbf5135340d016994af97baeff9 Mon Sep 17 00:00:00 2001 From: Adam Powell Date: Tue, 2 Mar 2010 17:09:38 -0800 Subject: [PATCH] Added Scroller compatibility methods to OverScroller --- core/java/android/widget/OverScroller.java | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/core/java/android/widget/OverScroller.java b/core/java/android/widget/OverScroller.java index b11caa1c6635a..1730a68ae31ca 100644 --- a/core/java/android/widget/OverScroller.java +++ b/core/java/android/widget/OverScroller.java @@ -394,4 +394,44 @@ public class OverScroller { public float getCurrVelocity() { return mCurrScroller.getCurrVelocity(); } + + /** + * Extend the scroll animation. This allows a running animation to scroll + * further and longer, when used with {@link #setFinalX(int)} or {@link #setFinalY(int)}. + * + * @param extend Additional time to scroll in milliseconds. + * @see #setFinalX(int) + * @see #setFinalY(int) + */ + public void extendDuration(int extend) { + if (mScrollMode == MODE_DEFAULT) { + mDefaultScroller.extendDuration(extend); + } + } + + /** + * Sets the final position (X) for this scroller. + * + * @param newX The new X offset as an absolute distance from the origin. + * @see #extendDuration(int) + * @see #setFinalY(int) + */ + public void setFinalX(int newX) { + if (mScrollMode == MODE_DEFAULT) { + mDefaultScroller.setFinalX(newX); + } + } + + /** + * Sets the final position (Y) for this scroller. + * + * @param newY The new Y offset as an absolute distance from the origin. + * @see #extendDuration(int) + * @see #setFinalX(int) + */ + public void setFinalY(int newY) { + if (mScrollMode == MODE_DEFAULT) { + mDefaultScroller.setFinalY(newY); + } + } }