1/*
2 * Copyright (C) 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17
18package android.support.v4.widget;
19
20import android.content.Context;
21import android.view.animation.Interpolator;
22import android.widget.OverScroller;
23
24class ScrollerCompatGingerbread {
25    public static Object createScroller(Context context, Interpolator interpolator) {
26        return interpolator != null ?
27                new OverScroller(context, interpolator) : new OverScroller(context);
28    }
29
30    public static boolean isFinished(Object scroller) {
31        return ((OverScroller) scroller).isFinished();
32    }
33
34    public static int getCurrX(Object scroller) {
35        return ((OverScroller) scroller).getCurrX();
36    }
37
38    public static int getCurrY(Object scroller) {
39        return ((OverScroller) scroller).getCurrY();
40    }
41
42    public static boolean computeScrollOffset(Object scroller) {
43        return ((OverScroller) scroller).computeScrollOffset();
44    }
45
46    public static void startScroll(Object scroller, int startX, int startY, int dx, int dy) {
47        ((OverScroller) scroller).startScroll(startX, startY, dx, dy);
48    }
49
50    public static void startScroll(Object scroller, int startX, int startY, int dx, int dy,
51            int duration) {
52        ((OverScroller) scroller).startScroll(startX, startY, dx, dy, duration);
53    }
54
55    public static void fling(Object scroller, int startX, int startY, int velX, int velY,
56            int minX, int maxX, int minY, int maxY) {
57        ((OverScroller) scroller).fling(startX, startY, velX, velY, minX, maxX, minY, maxY);
58    }
59
60    public static void fling(Object scroller, int startX, int startY, int velX, int velY,
61            int minX, int maxX, int minY, int maxY, int overX, int overY) {
62        ((OverScroller) scroller).fling(startX, startY, velX, velY,
63                minX, maxX, minY, maxY, overX, overY);
64    }
65
66    public static void abortAnimation(Object scroller) {
67        ((OverScroller) scroller).abortAnimation();
68    }
69
70    public static void notifyHorizontalEdgeReached(Object scroller, int startX, int finalX,
71            int overX) {
72        ((OverScroller) scroller).notifyHorizontalEdgeReached(startX, finalX, overX);
73    }
74
75    public static void notifyVerticalEdgeReached(Object scroller, int startY, int finalY, int overY) {
76        ((OverScroller) scroller).notifyVerticalEdgeReached(startY, finalY, overY);
77    }
78
79    public static boolean isOverScrolled(Object scroller) {
80        return ((OverScroller) scroller).isOverScrolled();
81    }
82
83    public static int getFinalX(Object scroller) {
84        return ((OverScroller) scroller).getFinalX();
85    }
86
87    public static int getFinalY(Object scroller) {
88        return ((OverScroller) scroller).getFinalY();
89    }
90
91    public static boolean springBack(Object scroller, int startX, int startY, int minX, int maxX,
92            int minY, int maxY) {
93        return ((OverScroller) scroller).springBack(startX, startY, minX, maxX, minY, maxY);
94    }
95}
96