ViewCompat.java revision ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbd
1bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell/*
2bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell * Copyright (C) 2011 The Android Open Source Project
3bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell *
4bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell * Licensed under the Apache License, Version 2.0 (the "License");
5bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell * you may not use this file except in compliance with the License.
6bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell * You may obtain a copy of the License at
7bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell *
8bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell *      http://www.apache.org/licenses/LICENSE-2.0
9bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell *
10bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell * Unless required by applicable law or agreed to in writing, software
11bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell * distributed under the License is distributed on an "AS IS" BASIS,
12bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell * See the License for the specific language governing permissions and
14bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell * limitations under the License.
15bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell */
16bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
17bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powellpackage android.support.v4.view;
18bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
190574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganovimport android.graphics.Rect;
209648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganovimport android.support.v4.view.accessibility.AccessibilityNodeInfoCompat;
21bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powellimport android.view.View;
229648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganovimport android.view.accessibility.AccessibilityEvent;
23bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
24bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell/**
250574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * Helper for accessing features in {@link View} introduced after API
260574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * level 4 in a backwards compatible fashion.
27bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell */
28bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powellpublic class ViewCompat {
29560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    /**
30560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     * Always allow a user to over-scroll this view, provided it is a
31560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     * view that can scroll.
32560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     */
33560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    public static final int OVER_SCROLL_ALWAYS = 0;
34560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
35560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    /**
36560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     * Allow a user to over-scroll this view only if the content is large
37560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     * enough to meaningfully scroll, provided it is a view that can scroll.
38560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     */
39560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    public static final int OVER_SCROLL_IF_CONTENT_SCROLLS = 1;
40560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
41560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    /**
42560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     * Never allow a user to over-scroll this view.
43560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell     */
44560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    public static final int OVER_SCROLL_NEVER = 2;
45560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
46ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    private static final long FAKE_FRAME_TIME = 10;
47ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
48bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    interface ViewCompatImpl {
49bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollHorizontally(View v, int direction);
50bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollVertically(View v, int direction);
51560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public int getOverScrollMode(View v);
52560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public void setOverScrollMode(View v, int mode);
539648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityEvent(View v, AccessibilityEvent event);
549648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onPopulateAccessibilityEvent(View v, AccessibilityEvent event);
559648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info);
569648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate);
57c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public boolean hasTransientState(View view);
58c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public void setHasTransientState(View view, boolean hasTransientState);
59ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view);
60ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view, int left, int top, int right, int bottom);
61ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimation(View view, Runnable action);
62ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimationDelayed(View view, Runnable action, long delayMillis);
63bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
64bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
65bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    static class BaseViewCompatImpl implements ViewCompatImpl {
66bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollHorizontally(View v, int direction) {
67bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            return false;
68bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
69bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollVertically(View v, int direction) {
70bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            return false;
71bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
72560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public int getOverScrollMode(View v) {
73560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            return OVER_SCROLL_NEVER;
74560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        }
75560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public void setOverScrollMode(View v, int mode) {
76560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            // Do nothing; API doesn't exist
77560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        }
789648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate) {
799648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            // Do nothing; API doesn't exist
809648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
819648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onPopulateAccessibilityEvent(View v, AccessibilityEvent event) {
829648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            // Do nothing; API doesn't exist
839648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
849648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityEvent(View v, AccessibilityEvent event) {
859648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov         // Do nothing; API doesn't exist
869648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
879648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info) {
889648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            // Do nothing; API doesn't exist
899648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
90c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public boolean hasTransientState(View view) {
91c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            // A view can't have transient state if transient state wasn't supported.
92c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            return false;
93c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        }
94c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public void setHasTransientState(View view, boolean hasTransientState) {
95c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            // Do nothing; API doesn't exist
96c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        }
97ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view) {
98ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            view.postInvalidateDelayed(getFrameTime());
99ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
100ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view, int left, int top, int right, int bottom) {
101ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            view.postInvalidateDelayed(getFrameTime(), left, top, right, bottom);
102ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
103ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimation(View view, Runnable action) {
104ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            view.postDelayed(action, getFrameTime());
105ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
106ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimationDelayed(View view, Runnable action, long delayMillis) {
107ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            view.postDelayed(action, getFrameTime() + delayMillis);
108ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
109ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        long getFrameTime() {
110ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            return FAKE_FRAME_TIME;
111ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
112bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
113bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
114560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    static class GBViewCompatImpl extends BaseViewCompatImpl {
1159648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
116560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public int getOverScrollMode(View v) {
117560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            return ViewCompatGingerbread.getOverScrollMode(v);
118560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        }
1199648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
120560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        public void setOverScrollMode(View v, int mode) {
121560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            ViewCompatGingerbread.setOverScrollMode(v, mode);
122560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        }
123560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    }
124560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
125ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    static class HCViewCompatImpl extends GBViewCompatImpl {
126ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        long getFrameTime() {
127ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            return ViewCompatHC.getFrameTime();
128ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
129ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
130ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
131ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    static class ICSViewCompatImpl extends HCViewCompatImpl {
1329648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
133bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollHorizontally(View v, int direction) {
134bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            return ViewCompatICS.canScrollHorizontally(v, direction);
135bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
1369648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
137bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        public boolean canScrollVertically(View v, int direction) {
138bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            return ViewCompatICS.canScrollVertically(v, direction);
139bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
1409648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
1419648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onPopulateAccessibilityEvent(View v, AccessibilityEvent event) {
1429648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            ViewCompatICS.onPopulateAccessibilityEvent(v, event);
1439648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
1449648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
1459648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityEvent(View v, AccessibilityEvent event) {
1469648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            ViewCompatICS.onInitializeAccessibilityEvent(v, event);
1479648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
1489648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
1499648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info) {
150956b013dfda37760b0232ed6d448900a546d2903Svetoslav Ganov            ViewCompatICS.onInitializeAccessibilityNodeInfo(v, info.getInfo());
1519648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
1529648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        @Override
1539648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        public void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate) {
1549648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov            ViewCompatICS.setAccessibilityDelegate(v, delegate.getBridge());
1559648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        }
156bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
157bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
158c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    static class JBViewCompatImpl extends ICSViewCompatImpl {
159c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        @Override
160c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public boolean hasTransientState(View view) {
161c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            return ViewCompatJB.hasTransientState(view);
162c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        }
163c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        @Override
164c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        public void setHasTransientState(View view, boolean hasTransientState) {
165c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            ViewCompatJB.setHasTransientState(view, hasTransientState);
166c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        }
167ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        @Override
168ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view) {
169ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            ViewCompatJB.postInvalidateOnAnimation(view);
170ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
171ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        @Override
172ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postInvalidateOnAnimation(View view, int left, int top, int right, int bottom) {
173ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            ViewCompatJB.postInvalidateOnAnimation(view, left, top, right, bottom);
174ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
175ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        @Override
176ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimation(View view, Runnable action) {
177ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            ViewCompatJB.postOnAnimation(view, action);
178ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
179ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        @Override
180ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        public void postOnAnimationDelayed(View view, Runnable action, long delayMillis) {
181ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            ViewCompatJB.postOnAnimationDelayed(view, action, delayMillis);
182ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        }
183c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    }
184c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell
185bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    static final ViewCompatImpl IMPL;
186bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    static {
187560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        final int version = android.os.Build.VERSION.SDK_INT;
188c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        if (version >= 16 || android.os.Build.VERSION.CODENAME.equals("JellyBean")) {
189c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell            IMPL = new JBViewCompatImpl();
190c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        } else if (version >= 14) {
191bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            IMPL = new ICSViewCompatImpl();
192ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        } else if (version >= 11) {
193ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            IMPL = new HCViewCompatImpl();
194560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        } else if (version >= 9) {
195560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell            IMPL = new GBViewCompatImpl();
196bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        } else {
197bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell            IMPL = new BaseViewCompatImpl();
198bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        }
199bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
200bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
2010574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
2020574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Check if this view can be scrolled horizontally in a certain direction.
2030574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
2040574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
2050574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param direction Negative to check scrolling left, positive to check scrolling right.
2060574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @return true if this view can be scrolled in the specified direction, false otherwise.
2070574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
208bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    public static boolean canScrollHorizontally(View v, int direction) {
209bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        return IMPL.canScrollHorizontally(v, direction);
210bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
211bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell
2120574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
2130574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Check if this view can be scrolled vertically in a certain direction.
2140574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
2150574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
2160574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param direction Negative to check scrolling up, positive to check scrolling down.
2170574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @return true if this view can be scrolled in the specified direction, false otherwise.
2180574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
219bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    public static boolean canScrollVertically(View v, int direction) {
220bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell        return IMPL.canScrollVertically(v, direction);
221bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell    }
222560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
2230574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
2240574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Returns the over-scroll mode for this view. The result will be
2250574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * one of {@link #OVER_SCROLL_ALWAYS} (default), {@link #OVER_SCROLL_IF_CONTENT_SCROLLS}
2260574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * (allow over-scrolling only if the view content is larger than the container),
2270574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * or {@link #OVER_SCROLL_NEVER}.
2280574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
2290574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
2300574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @return This view's over-scroll mode.
2310574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
232560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    public static int getOverScrollMode(View v) {
233560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell        return IMPL.getOverScrollMode(v);
234560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    }
235560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell
2360574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
2370574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Set the over-scroll mode for this view. Valid over-scroll modes are
2380574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link #OVER_SCROLL_ALWAYS} (default), {@link #OVER_SCROLL_IF_CONTENT_SCROLLS}
2390574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * (allow over-scrolling only if the view content is larger than the container),
2400574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * or {@link #OVER_SCROLL_NEVER}.
2410574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
2420574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Setting the over-scroll mode of a view will have an effect only if the
2430574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * view is capable of scrolling.
2440574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
2450574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
2460574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param overScrollMode The new over-scroll mode for this view.
2470574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
2480574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    public static void setOverScrollMode(View v, int overScrollMode) {
2490574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov        IMPL.setOverScrollMode(v, overScrollMode);
250560114f591be31d0fb73c26a1ee1cc0a15184abaAdam Powell    }
2519648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov
2520574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
2530574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Called from {@link View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)}
2540574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * giving a chance to this View to populate the accessibility event with its
2550574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * text content. While this method is free to modify event
2560574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * attributes other than text content, doing so should normally be performed in
2570574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link View#onInitializeAccessibilityEvent(AccessibilityEvent)}.
2580574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
2590574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Example: Adding formatted date string to an accessibility event in addition
2600574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *          to the text added by the super implementation:
2610574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <pre> public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
2620574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     super.onPopulateAccessibilityEvent(event);
2630574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     final int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_WEEKDAY;
2640574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     String selectedDateUtterance = DateUtils.formatDateTime(mContext,
2650574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *         mCurrentDate.getTimeInMillis(), flags);
2660574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     event.getText().add(selectedDateUtterance);
2670574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * }</pre>
2680574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
2690574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * If an {@link android.view.View.AccessibilityDelegate} has been specified via calling
2700574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link View#setAccessibilityDelegate(android.view.View.AccessibilityDelegate)} its
2710574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link android.view.View.AccessibilityDelegate#onPopulateAccessibilityEvent(View,
2720574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *  AccessibilityEvent)}
2730574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * is responsible for handling this call.
2740574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
2750574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p class="note"><strong>Note:</strong> Always call the super implementation before adding
2760574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * information to the event, in case the default implementation has basic information to add.
2770574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
2780574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
2790574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
2800574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param event The accessibility event which to populate.
2810574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
2820574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see View#sendAccessibilityEvent(int)
2830574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)
2840574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
2859648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    public static void onPopulateAccessibilityEvent(View v, AccessibilityEvent event) {
2869648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        IMPL.onPopulateAccessibilityEvent(v, event);
2879648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    }
2889648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov
2890574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
2900574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Initializes an {@link AccessibilityEvent} with information about
2910574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * this View which is the event source. In other words, the source of
2920574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * an accessibility event is the view whose state change triggered firing
2930574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * the event.
2940574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
2950574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Example: Setting the password property of an event in addition
2960574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *          to properties set by the super implementation:
2970574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <pre> public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
2980574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     super.onInitializeAccessibilityEvent(event);
2990574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *     event.setPassword(true);
3000574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * }</pre>
3010574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
3020574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * If an {@link android.view.View.AccessibilityDelegate} has been specified via calling
3030574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link View#setAccessibilityDelegate(android.view.View.AccessibilityDelegate)} its
3040574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link android.view.View.AccessibilityDelegate#onInitializeAccessibilityEvent(View,
3050574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *  AccessibilityEvent)}
3060574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * is responsible for handling this call.
3070574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
3080574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p class="note"><strong>Note:</strong> Always call the super implementation before adding
3090574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * information to the event, in case the default implementation has basic information to add.
3100574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
3110574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
3120574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
3130574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param event The event to initialize.
3140574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
3150574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see View#sendAccessibilityEvent(int)
3160574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see View#dispatchPopulateAccessibilityEvent(AccessibilityEvent)
3170574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
3189648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    public static void onInitializeAccessibilityEvent(View v, AccessibilityEvent event) {
3199648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        IMPL.onInitializeAccessibilityEvent(v, event);
3209648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    }
3219648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov
3220574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
3230574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Initializes an {@link android.view.accessibility.AccessibilityNodeInfo} with information
3240574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * about this view. The base implementation sets:
3250574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <ul>
3260574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setParent(View)},</li>
3270574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setBoundsInParent(Rect)},</li>
3280574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setBoundsInScreen(Rect)},</li>
3290574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setPackageName(CharSequence)},</li>
3300574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setClassName(CharSequence)},</li>
3310574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setContentDescription(CharSequence)},</li>
3320574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setEnabled(boolean)},</li>
3330574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setClickable(boolean)},</li>
3340574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setFocusable(boolean)},</li>
3350574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setFocused(boolean)},</li>
3360574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setLongClickable(boolean)},</li>
3370574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <li>{@link android.view.accessibility.AccessibilityNodeInfo#setSelected(boolean)},</li>
3380574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </ul>
3390574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
3400574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Subclasses should override this method, call the super implementation,
3410574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * and set additional attributes.
3420574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
3430574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * <p>
3440574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * If an {@link android.view.View.AccessibilityDelegate} has been specified via calling
3450574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link View#setAccessibilityDelegate(android.view.View.AccessibilityDelegate)} its
3460574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link android.view.View.AccessibilityDelegate#onInitializeAccessibilityNodeInfo(View,
3470574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *  android.view.accessibility.AccessibilityNodeInfo)}
3480574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * is responsible for handling this call.
3490574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * </p>
3500574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
3510574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
3520574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param info The instance to initialize.
3530574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
3549648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    public static void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfoCompat info) {
3559648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        IMPL.onInitializeAccessibilityNodeInfo(v, info);
3569648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    }
3579648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov
3580574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov    /**
3590574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * Sets a delegate for implementing accessibility support via compositon as
3600574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * opposed to inheritance. The delegate's primary use is for implementing
3610574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * backwards compatible widgets. For more details see
3620574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * {@link android.view.View.AccessibilityDelegate}.
3630574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
3640574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param v The View against which to invoke the method.
3650574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @param delegate The delegate instance.
3660574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     *
3670574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     * @see android.view.View.AccessibilityDelegate
3680574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov     */
3699648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    public static void setAccessibilityDelegate(View v, AccessibilityDelegateCompat delegate) {
3709648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov        IMPL.setAccessibilityDelegate(v, delegate);
3719648c538bac4f04145c118cc41168d1d7a536312Svetoslav Ganov    }
372c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell
373c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    /**
374c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * Indicates whether the view is currently tracking transient state that the
375c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * app should not need to concern itself with saving and restoring, but that
376c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * the framework should take special note to preserve when possible.
377c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     *
378c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * @param view View to check for transient state
379c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * @return true if the view has transient state
380c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     */
381c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    public static boolean hasTransientState(View view) {
382c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        return IMPL.hasTransientState(view);
383c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    }
384c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell
385c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    /**
386c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * Set whether this view is currently tracking transient state that the
387c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * framework should attempt to preserve when possible.
388c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     *
389c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * @param view View tracking transient state
390c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     * @param hasTransientState true if this view has transient state
391c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell     */
392c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    public static void setHasTransientState(View view, boolean hasTransientState) {
393c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell        IMPL.setHasTransientState(view, hasTransientState);
394c95beb648f59c89c6bd7b0eed0a8b266a1b287e2Adam Powell    }
395ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
396ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    /**
397ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>Cause an invalidate to happen on the next animation time step, typically the
398ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * next display frame.</p>
399ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
400ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>This method can be invoked from outside of the UI thread
401ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * only when this View is attached to a window.</p>
402ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
403ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param view View to invalidate
404ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     */
405ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    public static void postInvalidateOnAnimation(View view) {
406ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        IMPL.postInvalidateOnAnimation(view);
407ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
408ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
409ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    /**
410ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>Cause an invalidate of the specified area to happen on the next animation
411ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * time step, typically the next display frame.</p>
412ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
413ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>This method can be invoked from outside of the UI thread
414ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * only when this View is attached to a window.</p>
415ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
416ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param view View to invalidate
417ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param left The left coordinate of the rectangle to invalidate.
418ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param top The top coordinate of the rectangle to invalidate.
419ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param right The right coordinate of the rectangle to invalidate.
420ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param bottom The bottom coordinate of the rectangle to invalidate.
421ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     */
422ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    public static void postInvalidateOnAnimation(View view, int left, int top,
423ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell            int right, int bottom) {
424ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        IMPL.postInvalidateOnAnimation(view, left, top, right, bottom);
425ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
426ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
427ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    /**
428ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>Causes the Runnable to execute on the next animation time step.
429ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * The runnable will be run on the user interface thread.</p>
430ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
431ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>This method can be invoked from outside of the UI thread
432ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * only when this View is attached to a window.</p>
433ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
434ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param view View to post this Runnable to
435ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param action The Runnable that will be executed.
436ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     */
437ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    public static void postOnAnimation(View view, Runnable action) {
438ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        IMPL.postOnAnimation(view, action);
439ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
440ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell
441ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    /**
442ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>Causes the Runnable to execute on the next animation time step,
443ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * after the specified amount of time elapses.
444ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * The runnable will be run on the user interface thread.</p>
445ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
446ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * <p>This method can be invoked from outside of the UI thread
447ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * only when this View is attached to a window.</p>
448ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *
449ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param view The view to post this Runnable to
450ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param action The Runnable that will be executed.
451ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     * @param delayMillis The delay (in milliseconds) until the Runnable
452ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     *        will be executed.
453ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell     */
454ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    public static void postOnAnimationDelayed(View view, Runnable action, long delayMillis) {
455ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell        IMPL.postOnAnimationDelayed(view, action, delayMillis);
456ec03704fbb4f0217d4c274d1c6cf56e6ea4dcfbdAdam Powell    }
457bc889e39e279fcf8c3d35fc11d8052c002eddf38Adam Powell}
458