1/*
2 * Copyright (C) 2011 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 */
16package android.support.v4.widget;
17
18import android.content.Context;
19import android.graphics.Canvas;
20import android.widget.EdgeEffect;
21
22/**
23 * Stub implementation that contains a real EdgeEffect on ICS.
24 *
25 * This class is an implementation detail for EdgeEffectCompat
26 * and should not be used directly.
27 */
28class EdgeEffectCompatIcs {
29    public static Object newEdgeEffect(Context context) {
30        return new EdgeEffect(context);
31    }
32
33    public static void setSize(Object edgeEffect, int width, int height) {
34        ((EdgeEffect) edgeEffect).setSize(width, height);
35    }
36
37    public static boolean isFinished(Object edgeEffect) {
38        return ((EdgeEffect) edgeEffect).isFinished();
39    }
40
41    public static void finish(Object edgeEffect) {
42        ((EdgeEffect) edgeEffect).finish();
43    }
44
45    public static boolean onPull(Object edgeEffect, float deltaDistance) {
46        ((EdgeEffect) edgeEffect).onPull(deltaDistance);
47        return true;
48    }
49
50    public static boolean onRelease(Object edgeEffect) {
51        EdgeEffect eff = (EdgeEffect) edgeEffect;
52        eff.onRelease();
53        return eff.isFinished();
54    }
55
56    public static boolean onAbsorb(Object edgeEffect, int velocity) {
57        ((EdgeEffect) edgeEffect).onAbsorb(velocity);
58        return true;
59    }
60
61    public static boolean draw(Object edgeEffect, Canvas canvas) {
62        return ((EdgeEffect) edgeEffect).draw(canvas);
63    }
64}