1/*
2 * Copyright (C) 2015 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.view;
19
20import android.util.Log;
21import android.view.View;
22import android.view.ViewParent;
23
24class ViewParentCompatLollipop {
25    private static final String TAG = "ViewParentCompat";
26
27    public static boolean onStartNestedScroll(ViewParent parent, View child, View target,
28            int nestedScrollAxes) {
29        try {
30            return parent.onStartNestedScroll(child, target, nestedScrollAxes);
31        } catch (AbstractMethodError e) {
32            Log.e(TAG, "ViewParent " + parent + " does not implement interface " +
33                    "method onStartNestedScroll", e);
34            return false;
35        }
36    }
37
38    public static void onNestedScrollAccepted(ViewParent parent, View child, View target,
39            int nestedScrollAxes) {
40        try {
41            parent.onNestedScrollAccepted(child, target, nestedScrollAxes);
42        } catch (AbstractMethodError e) {
43            Log.e(TAG, "ViewParent " + parent + " does not implement interface " +
44                    "method onNestedScrollAccepted", e);
45        }
46    }
47
48    public static void onStopNestedScroll(ViewParent parent, View target) {
49        try {
50            parent.onStopNestedScroll(target);
51        } catch (AbstractMethodError e) {
52            Log.e(TAG, "ViewParent " + parent + " does not implement interface " +
53                    "method onStopNestedScroll", e);
54        }
55    }
56
57    public static void onNestedScroll(ViewParent parent, View target, int dxConsumed,
58            int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
59        try {
60            parent.onNestedScroll(target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
61        } catch (AbstractMethodError e) {
62            Log.e(TAG, "ViewParent " + parent + " does not implement interface " +
63                    "method onNestedScroll", e);
64        }
65    }
66
67    public static void onNestedPreScroll(ViewParent parent, View target, int dx, int dy,
68            int[] consumed) {
69        try {
70            parent.onNestedPreScroll(target, dx, dy, consumed);
71        } catch (AbstractMethodError e) {
72            Log.e(TAG, "ViewParent " + parent + " does not implement interface " +
73                    "method onNestedPreScroll", e);
74        }
75    }
76
77    public static boolean onNestedFling(ViewParent parent, View target, float velocityX,
78            float velocityY, boolean consumed) {
79        try {
80            return parent.onNestedFling(target, velocityX, velocityY, consumed);
81        } catch (AbstractMethodError e) {
82            Log.e(TAG, "ViewParent " + parent + " does not implement interface " +
83                    "method onNestedFling", e);
84            return false;
85        }
86    }
87
88    public static boolean onNestedPreFling(ViewParent parent, View target, float velocityX,
89            float velocityY) {
90        try {
91            return parent.onNestedPreFling(target, velocityX, velocityY);
92        } catch (AbstractMethodError e) {
93            Log.e(TAG, "ViewParent " + parent + " does not implement interface " +
94                    "method onNestedPreFling", e);
95            return false;
96        }
97    }
98}
99