1346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell/* 2346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * Copyright (C) 2012 The Android Open Source Project 3346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * 4346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * Licensed under the Apache License, Version 2.0 (the "License"); 5346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * you may not use this file except in compliance with the License. 6346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * You may obtain a copy of the License at 7346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * 8346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * http://www.apache.org/licenses/LICENSE-2.0 9346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * 10346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * Unless required by applicable law or agreed to in writing, software 11346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * distributed under the License is distributed on an "AS IS" BASIS, 12346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * See the License for the specific language governing permissions and 14346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * limitations under the License. 15346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell */ 16346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell 17346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powellpackage android.support.v4.widget; 18346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell 19346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powellimport android.content.Context; 20c56ba65d20be8742ff717907a3a2cd81dd0e5f3cAdam Powellimport android.view.animation.Interpolator; 21f185f104c4786740765e549d535f9ba1052f96ccKirill Grouchnikovimport android.widget.OverScroller; 22346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell 23346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell/** 24346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * Provides access to new {@link android.widget.Scroller Scroller} APIs when available. 25346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * 26346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * <p>This class provides a platform version-independent mechanism for obeying the 27346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * current device's preferred scroll physics and fling behavior. It offers a subset of 28346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * the APIs from Scroller or OverScroller.</p> 293035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * 303035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * @deprecated Use {@link OverScroller} directly. 31346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell */ 323035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas@Deprecated 33c5847d13e40f5d52459f5c0dab32dc08f1a9a683Chris Banespublic final class ScrollerCompat { 34f185f104c4786740765e549d535f9ba1052f96ccKirill Grouchnikov OverScroller mScroller; 35b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell 363035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas /** 373035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * @deprecated Use {@link OverScroller} constructor directly. 383035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas */ 393035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas @Deprecated 40c56ba65d20be8742ff717907a3a2cd81dd0e5f3cAdam Powell public static ScrollerCompat create(Context context) { 41c56ba65d20be8742ff717907a3a2cd81dd0e5f3cAdam Powell return create(context, null); 42c56ba65d20be8742ff717907a3a2cd81dd0e5f3cAdam Powell } 43c56ba65d20be8742ff717907a3a2cd81dd0e5f3cAdam Powell 443035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas /** 453035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * @deprecated Use {@link OverScroller} constructor directly. 463035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas */ 473035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas @Deprecated 48c56ba65d20be8742ff717907a3a2cd81dd0e5f3cAdam Powell public static ScrollerCompat create(Context context, Interpolator interpolator) { 493035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas return new ScrollerCompat(context, interpolator); 504ad0efc06631e6e35d8ced424c36438bf5827569Yigit Boyar } 514ad0efc06631e6e35d8ced424c36438bf5827569Yigit Boyar 524ad0efc06631e6e35d8ced424c36438bf5827569Yigit Boyar /** 538998fbc569aa0f17166db7fd425d59efac9f2600Aurimas Liutikas * Package protected constructor that allows to specify if API version is newer than ICS. 548998fbc569aa0f17166db7fd425d59efac9f2600Aurimas Liutikas * It is useful for unit testing. 554ad0efc06631e6e35d8ced424c36438bf5827569Yigit Boyar */ 563035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas ScrollerCompat(Context context, Interpolator interpolator) { 57f185f104c4786740765e549d535f9ba1052f96ccKirill Grouchnikov mScroller = interpolator != null ? 58f185f104c4786740765e549d535f9ba1052f96ccKirill Grouchnikov new OverScroller(context, interpolator) : new OverScroller(context); 59346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell } 60346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell 61346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell /** 62346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * Returns whether the scroller has finished scrolling. 63346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * 64346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * @return True if the scroller has finished scrolling, false otherwise. 653035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * 663035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * @deprecated Use {@link OverScroller#isFinished()} directly. 67346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell */ 683035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas @Deprecated 69346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell public boolean isFinished() { 70f185f104c4786740765e549d535f9ba1052f96ccKirill Grouchnikov return mScroller.isFinished(); 71346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell } 72346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell 73346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell /** 74346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * Returns the current X offset in the scroll. 75346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * 76346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * @return The new X offset as an absolute distance from the origin. 773035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * 783035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * @deprecated Use {@link OverScroller#getCurrX()} directly. 79346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell */ 803035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas @Deprecated 81346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell public int getCurrX() { 82f185f104c4786740765e549d535f9ba1052f96ccKirill Grouchnikov return mScroller.getCurrX(); 83346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell } 84346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell 85346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell /** 86346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * Returns the current Y offset in the scroll. 87346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * 88346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * @return The new Y offset as an absolute distance from the origin. 893035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * 903035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * @deprecated Use {@link OverScroller#getCurrY()} directly. 91346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell */ 923035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas @Deprecated 93346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell public int getCurrY() { 94f185f104c4786740765e549d535f9ba1052f96ccKirill Grouchnikov return mScroller.getCurrY(); 95346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell } 96346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell 97346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell /** 986580cf4b7e74a2a017ed95b0dc50155b9995edebAdam Powell * @return The final X position for the scroll in progress, if known. 993035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * 1003035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * @deprecated Use {@link OverScroller#getFinalX()} directly. 1016580cf4b7e74a2a017ed95b0dc50155b9995edebAdam Powell */ 1023035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas @Deprecated 1036580cf4b7e74a2a017ed95b0dc50155b9995edebAdam Powell public int getFinalX() { 104f185f104c4786740765e549d535f9ba1052f96ccKirill Grouchnikov return mScroller.getFinalX(); 1056580cf4b7e74a2a017ed95b0dc50155b9995edebAdam Powell } 1066580cf4b7e74a2a017ed95b0dc50155b9995edebAdam Powell 1076580cf4b7e74a2a017ed95b0dc50155b9995edebAdam Powell /** 1086580cf4b7e74a2a017ed95b0dc50155b9995edebAdam Powell * @return The final Y position for the scroll in progress, if known. 1093035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * 1103035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * @deprecated Use {@link OverScroller#getFinalY()} directly. 1116580cf4b7e74a2a017ed95b0dc50155b9995edebAdam Powell */ 1123035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas @Deprecated 1136580cf4b7e74a2a017ed95b0dc50155b9995edebAdam Powell public int getFinalY() { 114f185f104c4786740765e549d535f9ba1052f96ccKirill Grouchnikov return mScroller.getFinalY(); 1156580cf4b7e74a2a017ed95b0dc50155b9995edebAdam Powell } 1166580cf4b7e74a2a017ed95b0dc50155b9995edebAdam Powell 1176580cf4b7e74a2a017ed95b0dc50155b9995edebAdam Powell /** 118b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * Returns the current velocity on platform versions that support it. 119346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * 1203035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * <p> This method should only be used as input for nonessential visual effects such as 1213035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * {@link EdgeEffectCompat}.</p> 122346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * 123346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * @return The original velocity less the deceleration. Result may be 124346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * negative. 1253035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * 1263035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * @deprecated Use {@link OverScroller#getCurrVelocity()} directly. 127346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell */ 1283035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas @Deprecated 129346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell public float getCurrVelocity() { 1303035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas return mScroller.getCurrVelocity(); 131346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell } 132346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell 133346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell /** 134346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * Call this when you want to know the new location. If it returns true, 135346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * the animation is not yet finished. loc will be altered to provide the 136346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * new location. 1373035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * 1383035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * @deprecated Use {@link OverScroller#computeScrollOffset()} directly. 139346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell */ 1403035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas @Deprecated 141346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell public boolean computeScrollOffset() { 142f185f104c4786740765e549d535f9ba1052f96ccKirill Grouchnikov return mScroller.computeScrollOffset(); 143346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell } 144346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell 145346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell /** 146346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * Start scrolling by providing a starting point and the distance to travel. 147346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * The scroll will use the default value of 250 milliseconds for the 148346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * duration. 149346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * 150346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * @param startX Starting horizontal scroll offset in pixels. Positive 151346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * numbers will scroll the content to the left. 152346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * @param startY Starting vertical scroll offset in pixels. Positive numbers 153346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * will scroll the content up. 154346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * @param dx Horizontal distance to travel. Positive numbers will scroll the 155346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * content to the left. 156346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * @param dy Vertical distance to travel. Positive numbers will scroll the 157346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * content up. 1583035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * 1593035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * @deprecated Use {@link OverScroller#getCurrX()} directly. 160346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell */ 1613035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas @Deprecated 162346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell public void startScroll(int startX, int startY, int dx, int dy) { 163f185f104c4786740765e549d535f9ba1052f96ccKirill Grouchnikov mScroller.startScroll(startX, startY, dx, dy); 164346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell } 165346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell 166346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell /** 167346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * Start scrolling by providing a starting point and the distance to travel. 168346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * 169346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * @param startX Starting horizontal scroll offset in pixels. Positive 170346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * numbers will scroll the content to the left. 171346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * @param startY Starting vertical scroll offset in pixels. Positive numbers 172346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * will scroll the content up. 173346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * @param dx Horizontal distance to travel. Positive numbers will scroll the 174346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * content to the left. 175346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * @param dy Vertical distance to travel. Positive numbers will scroll the 176346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * content up. 177346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * @param duration Duration of the scroll in milliseconds. 1783035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * 1793035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * @deprecated Use {@link OverScroller#startScroll(int, int, int, int, int)} directly. 180346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell */ 1813035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas @Deprecated 182346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell public void startScroll(int startX, int startY, int dx, int dy, int duration) { 183f185f104c4786740765e549d535f9ba1052f96ccKirill Grouchnikov mScroller.startScroll(startX, startY, dx, dy, duration); 184346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell } 185346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell 186346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell /** 187346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * Start scrolling based on a fling gesture. The distance travelled will 188346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * depend on the initial velocity of the fling. 189346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * 190346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * @param startX Starting point of the scroll (X) 191346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * @param startY Starting point of the scroll (Y) 192346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * @param velocityX Initial velocity of the fling (X) measured in pixels per 193346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * second. 194346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * @param velocityY Initial velocity of the fling (Y) measured in pixels per 195346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * second 196346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * @param minX Minimum X value. The scroller will not scroll past this 197346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * point. 198346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * @param maxX Maximum X value. The scroller will not scroll past this 199346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * point. 200346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * @param minY Minimum Y value. The scroller will not scroll past this 201346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * point. 202346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * @param maxY Maximum Y value. The scroller will not scroll past this 203346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell * point. 2043035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * 2053035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * @deprecated Use {@link OverScroller#fling(int, int, int, int, int, int, int, int)} directly. 206346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell */ 2073035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas @Deprecated 208346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell public void fling(int startX, int startY, int velocityX, int velocityY, 209346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell int minX, int maxX, int minY, int maxY) { 210f185f104c4786740765e549d535f9ba1052f96ccKirill Grouchnikov mScroller.fling(startX, startY, velocityX, velocityY, minX, maxX, minY, maxY); 211346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell } 212346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell 213346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell /** 214b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * Start scrolling based on a fling gesture. The distance travelled will 215b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * depend on the initial velocity of the fling. 216b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * 217b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * @param startX Starting point of the scroll (X) 218b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * @param startY Starting point of the scroll (Y) 219b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * @param velocityX Initial velocity of the fling (X) measured in pixels per 220b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * second. 221b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * @param velocityY Initial velocity of the fling (Y) measured in pixels per 222b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * second 223b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * @param minX Minimum X value. The scroller will not scroll past this 224b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * point. 225b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * @param maxX Maximum X value. The scroller will not scroll past this 226b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * point. 227b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * @param minY Minimum Y value. The scroller will not scroll past this 228b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * point. 229b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * @param maxY Maximum Y value. The scroller will not scroll past this 230b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * point. 231b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * @param overX Overfling range. If > 0, horizontal overfling in either 232b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * direction will be possible. 233b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * @param overY Overfling range. If > 0, vertical overfling in either 234b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * direction will be possible. 2353035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * 2363035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * @deprecated Use {@link OverScroller#fling(int, int, int, int, int, int, int, int, int, int)} 2373035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * directly. 238b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell */ 2393035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas @Deprecated 240b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell public void fling(int startX, int startY, int velocityX, int velocityY, 241b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell int minX, int maxX, int minY, int maxY, int overX, int overY) { 242f185f104c4786740765e549d535f9ba1052f96ccKirill Grouchnikov mScroller.fling(startX, startY, velocityX, velocityY, 243b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell minX, maxX, minY, maxY, overX, overY); 244b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell } 245b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell 246b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell /** 24700db92e217c3bc08acd09143cac8e3d3b0d0e813Chris Banes * Call this when you want to 'spring back' into a valid coordinate range. 24800db92e217c3bc08acd09143cac8e3d3b0d0e813Chris Banes * 24900db92e217c3bc08acd09143cac8e3d3b0d0e813Chris Banes * @param startX Starting X coordinate 25000db92e217c3bc08acd09143cac8e3d3b0d0e813Chris Banes * @param startY Starting Y coordinate 25100db92e217c3bc08acd09143cac8e3d3b0d0e813Chris Banes * @param minX Minimum valid X value 25200db92e217c3bc08acd09143cac8e3d3b0d0e813Chris Banes * @param maxX Maximum valid X value 25300db92e217c3bc08acd09143cac8e3d3b0d0e813Chris Banes * @param minY Minimum valid Y value 2548c05e5f52fbc790b745e768398d9e69d6b9d9ee1Chris Banes * @param maxY Maximum valid Y value 25500db92e217c3bc08acd09143cac8e3d3b0d0e813Chris Banes * @return true if a springback was initiated, false if startX and startY were 25600db92e217c3bc08acd09143cac8e3d3b0d0e813Chris Banes * already within the valid range. 2573035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * 2583035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * @deprecated Use {@link OverScroller#springBack(int, int, int, int, int, int)} directly. 25900db92e217c3bc08acd09143cac8e3d3b0d0e813Chris Banes */ 2603035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas @Deprecated 26100db92e217c3bc08acd09143cac8e3d3b0d0e813Chris Banes public boolean springBack(int startX, int startY, int minX, int maxX, int minY, int maxY) { 262f185f104c4786740765e549d535f9ba1052f96ccKirill Grouchnikov return mScroller.springBack(startX, startY, minX, maxX, minY, maxY); 26300db92e217c3bc08acd09143cac8e3d3b0d0e813Chris Banes } 26400db92e217c3bc08acd09143cac8e3d3b0d0e813Chris Banes 26500db92e217c3bc08acd09143cac8e3d3b0d0e813Chris Banes /** 266b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * Stops the animation. Aborting the animation causes the scroller to move to the final x and y 267b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * position. 2683035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * 2693035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * @deprecated Use {@link OverScroller#abortAnimation()} directly. 270346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell */ 2713035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas @Deprecated 272346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell public void abortAnimation() { 273f185f104c4786740765e549d535f9ba1052f96ccKirill Grouchnikov mScroller.abortAnimation(); 274b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell } 275b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell 276b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell 277b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell /** 278b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * Notify the scroller that we've reached a horizontal boundary. 279b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * Normally the information to handle this will already be known 280b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * when the animation is started, such as in a call to one of the 281b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * fling functions. However there are cases where this cannot be known 282b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * in advance. This function will transition the current motion and 283b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * animate from startX to finalX as appropriate. 284b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * 285b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * @param startX Starting/current X position 286b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * @param finalX Desired final X position 287b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * @param overX Magnitude of overscroll allowed. This should be the maximum 288b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * desired distance from finalX. Absolute value - must be positive. 2893035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * 2903035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * @deprecated Use {@link OverScroller#notifyHorizontalEdgeReached(int, int, int)} directly. 291b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell */ 2923035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas @Deprecated 293b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell public void notifyHorizontalEdgeReached(int startX, int finalX, int overX) { 294f185f104c4786740765e549d535f9ba1052f96ccKirill Grouchnikov mScroller.notifyHorizontalEdgeReached(startX, finalX, overX); 295b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell } 296b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell 297b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell /** 298b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * Notify the scroller that we've reached a vertical boundary. 299b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * Normally the information to handle this will already be known 300b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * when the animation is started, such as in a call to one of the 301b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * fling functions. However there are cases where this cannot be known 302b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * in advance. This function will animate a parabolic motion from 303b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * startY to finalY. 304b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * 305b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * @param startY Starting/current Y position 306b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * @param finalY Desired final Y position 307b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * @param overY Magnitude of overscroll allowed. This should be the maximum 308b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * desired distance from finalY. Absolute value - must be positive. 3093035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * 3103035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * @deprecated Use {@link OverScroller#notifyVerticalEdgeReached(int, int, int)} directly. 311b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell */ 3123035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas @Deprecated 313b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell public void notifyVerticalEdgeReached(int startY, int finalY, int overY) { 314f185f104c4786740765e549d535f9ba1052f96ccKirill Grouchnikov mScroller.notifyVerticalEdgeReached(startY, finalY, overY); 315b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell } 316b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell 317b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell /** 318b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * Returns whether the current Scroller is currently returning to a valid position. 319b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * Valid bounds were provided by the 320b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * {@link #fling(int, int, int, int, int, int, int, int, int, int)} method. 321b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * 322b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * One should check this value before calling 323b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * {@link #startScroll(int, int, int, int)} as the interpolation currently in progress 324b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * to restore a valid position will then be stopped. The caller has to take into account 325b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * the fact that the started scroll will start from an overscrolled position. 326b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * 327b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * @return true when the current position is overscrolled and in the process of 328b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell * interpolating back to a valid value. 3293035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * 3303035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas * @deprecated Use {@link OverScroller#isOverScrolled()} directly. 331b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell */ 3323035be16658d7652fdc472f971c81d8f7ffb60fdAurimas Liutikas @Deprecated 333b9e34c7d443082d5ee2b90a0e6788523d8df0df1Adam Powell public boolean isOverScrolled() { 334f185f104c4786740765e549d535f9ba1052f96ccKirill Grouchnikov return mScroller.isOverScrolled(); 335346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell } 336346e2f2390f0d743fd10e7d01a015df6b32292cdAdam Powell} 337