blob: 06afef27cee5ae543090606f38e8e97caabbd6e5 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2006 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
17package android.view;
18
19import android.graphics.Rect;
Adam Powellb6ab0982015-01-07 17:00:12 -080020import android.os.Bundle;
Svetoslav Ganov736c2752011-04-22 18:30:36 -070021import android.view.accessibility.AccessibilityEvent;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080022
23/**
24 * Defines the responsibilities for a class that will be a parent of a View.
25 * This is the API that a view sees when it wants to interact with its parent.
26 *
27 */
28public interface ViewParent {
29 /**
30 * Called when something has changed which has invalidated the layout of a
31 * child of this view parent. This will schedule a layout pass of the view
32 * tree.
33 */
34 public void requestLayout();
35
36 /**
37 * Indicates whether layout was requested on this view parent.
38 *
39 * @return true if layout was requested, false otherwise
40 */
41 public boolean isLayoutRequested();
42
43 /**
44 * Called when a child wants the view hierarchy to gather and report
45 * transparent regions to the window compositor. Views that "punch" holes in
46 * the view hierarchy, such as SurfaceView can use this API to improve
47 * performance of the system. When no such a view is present in the
48 * hierarchy, this optimization in unnecessary and might slightly reduce the
49 * view hierarchy performance.
50 *
51 * @param child the view requesting the transparent region computation
52 *
53 */
54 public void requestTransparentRegion(View child);
55
56 /**
57 * All or part of a child is dirty and needs to be redrawn.
58 *
59 * @param child The child which is dirty
60 * @param r The area within the child that is invalid
61 */
62 public void invalidateChild(View child, Rect r);
63
64 /**
65 * All or part of a child is dirty and needs to be redrawn.
66 *
Gilles Debunnecea45132011-11-24 02:19:27 +010067 * <p>The location array is an array of two int values which respectively
68 * define the left and the top position of the dirty child.</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080069 *
Gilles Debunnecea45132011-11-24 02:19:27 +010070 * <p>This method must return the parent of this ViewParent if the specified
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080071 * rectangle must be invalidated in the parent. If the specified rectangle
72 * does not require invalidation in the parent or if the parent does not
Gilles Debunnecea45132011-11-24 02:19:27 +010073 * exist, this method must return null.</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080074 *
Gilles Debunnecea45132011-11-24 02:19:27 +010075 * <p>When this method returns a non-null value, the location array must
76 * have been updated with the left and top coordinates of this ViewParent.</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080077 *
78 * @param location An array of 2 ints containing the left and top
79 * coordinates of the child to invalidate
80 * @param r The area within the child that is invalid
81 *
82 * @return the parent of this ViewParent or null
83 */
84 public ViewParent invalidateChildInParent(int[] location, Rect r);
85
86 /**
87 * Returns the parent if it exists, or null.
88 *
89 * @return a ViewParent or null if this ViewParent does not have a parent
90 */
91 public ViewParent getParent();
92
93 /**
94 * Called when a child of this parent wants focus
95 *
96 * @param child The child of this ViewParent that wants focus. This view
97 * will contain the focused view. It is not necessarily the view that
98 * actually has focus.
99 * @param focused The view that is a descendant of child that actually has
100 * focus
101 */
102 public void requestChildFocus(View child, View focused);
103
104 /**
105 * Tell view hierarchy that the global view attributes need to be
106 * re-evaluated.
107 *
108 * @param child View whose attributes have changed.
109 */
110 public void recomputeViewAttributes(View child);
111
112 /**
113 * Called when a child of this parent is giving up focus
114 *
115 * @param child The view that is giving up focus
116 */
117 public void clearChildFocus(View child);
118
Gilles Debunnecea45132011-11-24 02:19:27 +0100119 /**
120 * Compute the visible part of a rectangular region defined in terms of a child view's
121 * coordinates.
122 *
123 * <p>Returns the clipped visible part of the rectangle <code>r</code>, defined in the
124 * <code>child</code>'s local coordinate system. <code>r</code> is modified by this method to
125 * contain the result, expressed in the global (root) coordinate system.</p>
126 *
127 * <p>The resulting rectangle is always axis aligned. If a rotation is applied to a node in the
128 * View hierarchy, the result is the axis-aligned bounding box of the visible rectangle.</p>
129 *
130 * @param child A child View, whose rectangular visible region we want to compute
131 * @param r The input rectangle, defined in the child coordinate system. Will be overwritten to
132 * contain the resulting visible rectangle, expressed in global (root) coordinates
133 * @param offset The input coordinates of a point, defined in the child coordinate system.
134 * As with the <code>r</code> parameter, this will be overwritten to contain the global (root)
135 * coordinates of that point.
136 * A <code>null</code> value is valid (in case you are not interested in this result)
137 * @return true if the resulting rectangle is not empty, false otherwise
138 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800139 public boolean getChildVisibleRect(View child, Rect r, android.graphics.Point offset);
140
141 /**
142 * Find the nearest view in the specified direction that wants to take focus
143 *
144 * @param v The view that currently has focus
145 * @param direction One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHT
146 */
147 public View focusSearch(View v, int direction);
148
149 /**
Chet Haase0187a5d2013-04-23 06:55:04 -0700150 * Change the z order of the child so it's on top of all other children.
151 * This ordering change may affect layout, if this container
Chet Haasecb96db82013-09-04 10:21:46 -0700152 * uses an order-dependent layout scheme (e.g., LinearLayout). Prior
Chet Haasee8222dd2013-09-05 07:44:18 -0700153 * to {@link android.os.Build.VERSION_CODES#KITKAT} this
Chet Haase0187a5d2013-04-23 06:55:04 -0700154 * method should be followed by calls to {@link #requestLayout()} and
Chet Haasecb96db82013-09-04 10:21:46 -0700155 * {@link View#invalidate()} on this parent to force the parent to redraw
156 * with the new child ordering.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800157 *
Chet Haase0187a5d2013-04-23 06:55:04 -0700158 * @param child The child to bring to the top of the z order
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800159 */
160 public void bringChildToFront(View child);
161
162 /**
163 * Tells the parent that a new focusable view has become available. This is
164 * to handle transitions from the case where there are no focusable views to
165 * the case where the first focusable view appears.
166 *
167 * @param v The view that has become newly focusable
168 */
169 public void focusableViewAvailable(View v);
170
171 /**
Alan Viverette021627e2015-11-25 14:22:00 -0500172 * Shows the context menu for the specified view or its ancestors.
173 * <p>
174 * In most cases, a subclass does not need to override this. However, if
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800175 * the subclass is added directly to the window manager (for example,
176 * {@link ViewManager#addView(View, android.view.ViewGroup.LayoutParams)})
Alan Viverette021627e2015-11-25 14:22:00 -0500177 * then it should override this and show the context menu.
178 *
179 * @param originalView the source view where the context menu was first
180 * invoked
181 * @return {@code true} if the context menu was shown, {@code false}
182 * otherwise
183 * @see #showContextMenuForChild(View, float, float)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800184 */
185 public boolean showContextMenuForChild(View originalView);
186
187 /**
Alan Viverette021627e2015-11-25 14:22:00 -0500188 * Shows the context menu for the specified view or its ancestors anchored
189 * to the specified view-relative coordinate.
190 * <p>
191 * In most cases, a subclass does not need to override this. However, if
192 * the subclass is added directly to the window manager (for example,
193 * {@link ViewManager#addView(View, android.view.ViewGroup.LayoutParams)})
194 * then it should override this and show the context menu.
Adam Powell759a4c52016-02-05 15:52:02 -0800195 * <p>
196 * If a subclass overrides this method it should also override
197 * {@link #showContextMenuForChild(View)}.
Oren Blasberged391262015-09-01 12:12:51 -0700198 *
Alan Viverette021627e2015-11-25 14:22:00 -0500199 * @param originalView the source view where the context menu was first
200 * invoked
201 * @param x the X coordinate in pixels relative to the original view to
202 * which the menu should be anchored
203 * @param y the Y coordinate in pixels relative to the original view to
204 * which the menu should be anchored
205 * @return {@code true} if the context menu was shown, {@code false}
206 * otherwise
Oren Blasberged391262015-09-01 12:12:51 -0700207 */
Adam Powell759a4c52016-02-05 15:52:02 -0800208 boolean showContextMenuForChild(View originalView, float x, float y);
Oren Blasberged391262015-09-01 12:12:51 -0700209
210 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800211 * Have the parent populate the specified context menu if it has anything to
212 * add (and then recurse on its parent).
213 *
214 * @param menu The menu to populate
215 */
216 public void createContextMenu(ContextMenu menu);
217
218 /**
Clara Bayarri4423d912015-03-02 19:42:48 +0000219 * Start an action mode for the specified view with the default type
220 * {@link ActionMode#TYPE_PRIMARY}.
Gilles Debunnecea45132011-11-24 02:19:27 +0100221 *
222 * <p>In most cases, a subclass does not need to override this. However, if the
Adam Powell6e346362010-07-23 10:18:23 -0700223 * subclass is added directly to the window manager (for example,
224 * {@link ViewManager#addView(View, android.view.ViewGroup.LayoutParams)})
Gilles Debunnecea45132011-11-24 02:19:27 +0100225 * then it should override this and start the action mode.</p>
Adam Powell6e346362010-07-23 10:18:23 -0700226 *
227 * @param originalView The source view where the action mode was first invoked
228 * @param callback The callback that will handle lifecycle events for the action mode
229 * @return The new action mode if it was started, null otherwise
Clara Bayarri4423d912015-03-02 19:42:48 +0000230 *
231 * @see #startActionModeForChild(View, android.view.ActionMode.Callback, int)
Adam Powell6e346362010-07-23 10:18:23 -0700232 */
233 public ActionMode startActionModeForChild(View originalView, ActionMode.Callback callback);
234
235 /**
Clara Bayarri4423d912015-03-02 19:42:48 +0000236 * Start an action mode of a specific type for the specified view.
237 *
238 * <p>In most cases, a subclass does not need to override this. However, if the
239 * subclass is added directly to the window manager (for example,
240 * {@link ViewManager#addView(View, android.view.ViewGroup.LayoutParams)})
241 * then it should override this and start the action mode.</p>
242 *
243 * @param originalView The source view where the action mode was first invoked
244 * @param callback The callback that will handle lifecycle events for the action mode
245 * @param type One of {@link ActionMode#TYPE_PRIMARY} or {@link ActionMode#TYPE_FLOATING}.
246 * @return The new action mode if it was started, null otherwise
247 */
248 public ActionMode startActionModeForChild(
249 View originalView, ActionMode.Callback callback, int type);
250
251 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800252 * This method is called on the parent when a child's drawable state
253 * has changed.
254 *
255 * @param child The child whose drawable state has changed.
256 */
257 public void childDrawableStateChanged(View child);
Clara Bayarri4423d912015-03-02 19:42:48 +0000258
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800259 /**
260 * Called when a child does not want this parent and its ancestors to
261 * intercept touch events with
262 * {@link ViewGroup#onInterceptTouchEvent(MotionEvent)}.
Gilles Debunnecea45132011-11-24 02:19:27 +0100263 *
264 * <p>This parent should pass this call onto its parents. This parent must obey
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800265 * this request for the duration of the touch (that is, only clear the flag
Gilles Debunnecea45132011-11-24 02:19:27 +0100266 * after this parent has received an up or a cancel.</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800267 *
268 * @param disallowIntercept True if the child does not want the parent to
269 * intercept touch events.
270 */
271 public void requestDisallowInterceptTouchEvent(boolean disallowIntercept);
Yigit Boyard62d5e92016-01-19 18:56:20 -0800272
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800273 /**
274 * Called when a child of this group wants a particular rectangle to be
275 * positioned onto the screen. {@link ViewGroup}s overriding this can trust
276 * that:
277 * <ul>
278 * <li>child will be a direct child of this group</li>
Yigit Boyard62d5e92016-01-19 18:56:20 -0800279 * <li>rectangle will be in the child's content coordinates</li>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800280 * </ul>
281 *
282 * <p>{@link ViewGroup}s overriding this should uphold the contract:</p>
283 * <ul>
284 * <li>nothing will change if the rectangle is already visible</li>
285 * <li>the view port will be scrolled only just enough to make the
286 * rectangle visible</li>
287 * <ul>
288 *
289 * @param child The direct child making the request.
290 * @param rectangle The rectangle in the child's coordinates the child
291 * wishes to be on the screen.
292 * @param immediate True to forbid animated or delayed scrolling,
293 * false otherwise
294 * @return Whether the group scrolled to handle the operation
295 */
296 public boolean requestChildRectangleOnScreen(View child, Rect rectangle,
297 boolean immediate);
Svetoslav Ganov736c2752011-04-22 18:30:36 -0700298
299 /**
300 * Called by a child to request from its parent to send an {@link AccessibilityEvent}.
301 * The child has already populated a record for itself in the event and is delegating
302 * to its parent to send the event. The parent can optionally add a record for itself.
303 * <p>
304 * Note: An accessibility event is fired by an individual view which populates the
305 * event with a record for its state and requests from its parent to perform
306 * the sending. The parent can optionally add a record for itself before
307 * dispatching the request to its parent. A parent can also choose not to
308 * respect the request for sending the event. The accessibility event is sent
Gilles Debunnecea45132011-11-24 02:19:27 +0100309 * by the topmost view in the view tree.</p>
Svetoslav Ganov736c2752011-04-22 18:30:36 -0700310 *
311 * @param child The child which requests sending the event.
312 * @param event The event to be sent.
313 * @return True if the event was sent.
314 */
315 public boolean requestSendAccessibilityEvent(View child, AccessibilityEvent event);
Adam Powell539ee872012-02-03 19:00:49 -0800316
317 /**
318 * Called when a child view now has or no longer is tracking transient state.
319 *
Adam Powell0da4a282013-08-26 14:29:44 -0700320 * <p>"Transient state" is any state that a View might hold that is not expected to
321 * be reflected in the data model that the View currently presents. This state only
322 * affects the presentation to the user within the View itself, such as the current
323 * state of animations in progress or the state of a text selection operation.</p>
324 *
325 * <p>Transient state is useful for hinting to other components of the View system
326 * that a particular view is tracking something complex but encapsulated.
327 * A <code>ListView</code> for example may acknowledge that list item Views
328 * with transient state should be preserved within their position or stable item ID
329 * instead of treating that view as trivially replaceable by the backing adapter.
330 * This allows adapter implementations to be simpler instead of needing to track
331 * the state of item view animations in progress such that they could be restored
332 * in the event of an unexpected recycling and rebinding of attached item views.</p>
333 *
334 * <p>This method is called on a parent view when a child view or a view within
335 * its subtree begins or ends tracking of internal transient state.</p>
336 *
Adam Powell539ee872012-02-03 19:00:49 -0800337 * @param child Child view whose state has changed
338 * @param hasTransientState true if this child has transient state
Adam Powell539ee872012-02-03 19:00:49 -0800339 */
340 public void childHasTransientStateChanged(View child, boolean hasTransientState);
Dianne Hackborn3a3a6cf2012-03-26 10:24:04 -0700341
342 /**
343 * Ask that a new dispatch of {@link View#fitSystemWindows(Rect)
344 * View.fitSystemWindows(Rect)} be performed.
345 */
346 public void requestFitSystemWindows();
Svetoslav Ganov42138042012-03-20 11:51:39 -0700347
348 /**
349 * Gets the parent of a given View for accessibility. Since some Views are not
350 * exposed to the accessibility layer the parent for accessibility is not
351 * necessarily the direct parent of the View, rather it is a predecessor.
352 *
353 * @return The parent or <code>null</code> if no such is found.
354 */
355 public ViewParent getParentForAccessibility();
356
357 /**
Alan Viverette77e9a282013-09-12 17:16:09 -0700358 * Notifies a view parent that the accessibility state of one of its
359 * descendants has changed and that the structure of the subtree is
360 * different.
361 * @param child The direct child whose subtree has changed.
362 * @param source The descendant view that changed.
363 * @param changeType A bit mask of the types of changes that occurred. One
364 * or more of:
365 * <ul>
366 * <li>{@link AccessibilityEvent#CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION}
367 * <li>{@link AccessibilityEvent#CONTENT_CHANGE_TYPE_SUBTREE}
368 * <li>{@link AccessibilityEvent#CONTENT_CHANGE_TYPE_TEXT}
369 * <li>{@link AccessibilityEvent#CONTENT_CHANGE_TYPE_UNDEFINED}
370 * </ul>
Svetoslav Ganov42138042012-03-20 11:51:39 -0700371 */
Alan Viverette77e9a282013-09-12 17:16:09 -0700372 public void notifySubtreeAccessibilityStateChanged(View child, View source, int changeType);
Fabrice Di Meglio9dd4c5c2013-02-08 18:15:07 -0800373
374 /**
375 * Tells if this view parent can resolve the layout direction.
376 * See {@link View#setLayoutDirection(int)}
377 *
378 * @return True if this view parent can resolve the layout direction.
Fabrice Di Meglio9dd4c5c2013-02-08 18:15:07 -0800379 */
380 public boolean canResolveLayoutDirection();
381
382 /**
383 * Tells if this view parent layout direction is resolved.
384 * See {@link View#setLayoutDirection(int)}
385 *
386 * @return True if this view parent layout direction is resolved.
Fabrice Di Meglio9dd4c5c2013-02-08 18:15:07 -0800387 */
388 public boolean isLayoutDirectionResolved();
389
390 /**
391 * Return this view parent layout direction. See {@link View#getLayoutDirection()}
392 *
393 * @return {@link View#LAYOUT_DIRECTION_RTL} if the layout direction is RTL or returns
394 * {@link View#LAYOUT_DIRECTION_LTR} if the layout direction is not RTL.
Fabrice Di Meglio9dd4c5c2013-02-08 18:15:07 -0800395 */
396 public int getLayoutDirection();
397
398 /**
399 * Tells if this view parent can resolve the text direction.
400 * See {@link View#setTextDirection(int)}
401 *
402 * @return True if this view parent can resolve the text direction.
Fabrice Di Meglio9dd4c5c2013-02-08 18:15:07 -0800403 */
404 public boolean canResolveTextDirection();
405
406 /**
407 * Tells if this view parent text direction is resolved.
408 * See {@link View#setTextDirection(int)}
409 *
410 * @return True if this view parent text direction is resolved.
Fabrice Di Meglio9dd4c5c2013-02-08 18:15:07 -0800411 */
412 public boolean isTextDirectionResolved();
413
414 /**
415 * Return this view parent text direction. See {@link View#getTextDirection()}
416 *
417 * @return the resolved text direction. Returns one of:
418 *
419 * {@link View#TEXT_DIRECTION_FIRST_STRONG}
420 * {@link View#TEXT_DIRECTION_ANY_RTL},
421 * {@link View#TEXT_DIRECTION_LTR},
422 * {@link View#TEXT_DIRECTION_RTL},
423 * {@link View#TEXT_DIRECTION_LOCALE}
Fabrice Di Meglio9dd4c5c2013-02-08 18:15:07 -0800424 */
425 public int getTextDirection();
426
427 /**
428 * Tells if this view parent can resolve the text alignment.
429 * See {@link View#setTextAlignment(int)}
430 *
431 * @return True if this view parent can resolve the text alignment.
Fabrice Di Meglio9dd4c5c2013-02-08 18:15:07 -0800432 */
433 public boolean canResolveTextAlignment();
434
435 /**
436 * Tells if this view parent text alignment is resolved.
437 * See {@link View#setTextAlignment(int)}
438 *
439 * @return True if this view parent text alignment is resolved.
Fabrice Di Meglio9dd4c5c2013-02-08 18:15:07 -0800440 */
441 public boolean isTextAlignmentResolved();
442
443 /**
444 * Return this view parent text alignment. See {@link android.view.View#getTextAlignment()}
445 *
446 * @return the resolved text alignment. Returns one of:
447 *
448 * {@link View#TEXT_ALIGNMENT_GRAVITY},
449 * {@link View#TEXT_ALIGNMENT_CENTER},
450 * {@link View#TEXT_ALIGNMENT_TEXT_START},
451 * {@link View#TEXT_ALIGNMENT_TEXT_END},
452 * {@link View#TEXT_ALIGNMENT_VIEW_START},
453 * {@link View#TEXT_ALIGNMENT_VIEW_END}
Fabrice Di Meglio9dd4c5c2013-02-08 18:15:07 -0800454 */
455 public int getTextAlignment();
Adam Powell10ba2772014-04-15 09:46:51 -0700456
457 /**
458 * React to a descendant view initiating a nestable scroll operation, claiming the
459 * nested scroll operation if appropriate.
460 *
461 * <p>This method will be called in response to a descendant view invoking
462 * {@link View#startNestedScroll(int)}. Each parent up the view hierarchy will be
463 * given an opportunity to respond and claim the nested scrolling operation by returning
464 * <code>true</code>.</p>
465 *
466 * <p>This method may be overridden by ViewParent implementations to indicate when the view
467 * is willing to support a nested scrolling operation that is about to begin. If it returns
468 * true, this ViewParent will become the target view's nested scrolling parent for the duration
469 * of the scroll operation in progress. When the nested scroll is finished this ViewParent
470 * will receive a call to {@link #onStopNestedScroll(View)}.
471 * </p>
472 *
473 * @param child Direct child of this ViewParent containing target
474 * @param target View that initiated the nested scroll
475 * @param nestedScrollAxes Flags consisting of {@link View#SCROLL_AXIS_HORIZONTAL},
476 * {@link View#SCROLL_AXIS_VERTICAL} or both
477 * @return true if this ViewParent accepts the nested scroll operation
478 */
479 public boolean onStartNestedScroll(View child, View target, int nestedScrollAxes);
480
481 /**
482 * React to the successful claiming of a nested scroll operation.
483 *
484 * <p>This method will be called after
485 * {@link #onStartNestedScroll(View, View, int) onStartNestedScroll} returns true. It offers
486 * an opportunity for the view and its superclasses to perform initial configuration
487 * for the nested scroll. Implementations of this method should always call their superclass's
488 * implementation of this method if one is present.</p>
489 *
490 * @param child Direct child of this ViewParent containing target
491 * @param target View that initiated the nested scroll
492 * @param nestedScrollAxes Flags consisting of {@link View#SCROLL_AXIS_HORIZONTAL},
493 * {@link View#SCROLL_AXIS_VERTICAL} or both
494 * @see #onStartNestedScroll(View, View, int)
495 * @see #onStopNestedScroll(View)
496 */
497 public void onNestedScrollAccepted(View child, View target, int nestedScrollAxes);
498
499 /**
500 * React to a nested scroll operation ending.
501 *
502 * <p>Perform cleanup after a nested scrolling operation.
503 * This method will be called when a nested scroll stops, for example when a nested touch
504 * scroll ends with a {@link MotionEvent#ACTION_UP} or {@link MotionEvent#ACTION_CANCEL} event.
505 * Implementations of this method should always call their superclass's implementation of this
506 * method if one is present.</p>
507 *
508 * @param target View that initiated the nested scroll
509 */
510 public void onStopNestedScroll(View target);
511
512 /**
513 * React to a nested scroll in progress.
514 *
515 * <p>This method will be called when the ViewParent's current nested scrolling child view
516 * dispatches a nested scroll event. To receive calls to this method the ViewParent must have
517 * previously returned <code>true</code> for a call to
518 * {@link #onStartNestedScroll(View, View, int)}.</p>
519 *
520 * <p>Both the consumed and unconsumed portions of the scroll distance are reported to the
521 * ViewParent. An implementation may choose to use the consumed portion to match or chase scroll
522 * position of multiple child elements, for example. The unconsumed portion may be used to
523 * allow continuous dragging of multiple scrolling or draggable elements, such as scrolling
524 * a list within a vertical drawer where the drawer begins dragging once the edge of inner
525 * scrolling content is reached.</p>
526 *
527 * @param target The descendent view controlling the nested scroll
528 * @param dxConsumed Horizontal scroll distance in pixels already consumed by target
529 * @param dyConsumed Vertical scroll distance in pixels already consumed by target
530 * @param dxUnconsumed Horizontal scroll distance in pixels not consumed by target
531 * @param dyUnconsumed Vertical scroll distance in pixels not consumed by target
532 */
533 public void onNestedScroll(View target, int dxConsumed, int dyConsumed,
534 int dxUnconsumed, int dyUnconsumed);
535
536 /**
537 * React to a nested scroll in progress before the target view consumes a portion of the scroll.
538 *
539 * <p>When working with nested scrolling often the parent view may want an opportunity
540 * to consume the scroll before the nested scrolling child does. An example of this is a
541 * drawer that contains a scrollable list. The user will want to be able to scroll the list
542 * fully into view before the list itself begins scrolling.</p>
543 *
544 * <p><code>onNestedPreScroll</code> is called when a nested scrolling child invokes
545 * {@link View#dispatchNestedPreScroll(int, int, int[], int[])}. The implementation should
546 * report how any pixels of the scroll reported by dx, dy were consumed in the
547 * <code>consumed</code> array. Index 0 corresponds to dx and index 1 corresponds to dy.
548 * This parameter will never be null. Initial values for consumed[0] and consumed[1]
549 * will always be 0.</p>
550 *
551 * @param target View that initiated the nested scroll
552 * @param dx Horizontal scroll distance in pixels
553 * @param dy Vertical scroll distance in pixels
554 * @param consumed Output. The horizontal and vertical scroll distance consumed by this parent
555 */
556 public void onNestedPreScroll(View target, int dx, int dy, int[] consumed);
557
558 /**
559 * Request a fling from a nested scroll.
560 *
Adam Powellb36e4f92014-05-01 10:23:33 -0700561 * <p>This method signifies that a nested scrolling child has detected suitable conditions
562 * for a fling. Generally this means that a touch scroll has ended with a
563 * {@link VelocityTracker velocity} in the direction of scrolling that meets or exceeds
564 * the {@link ViewConfiguration#getScaledMinimumFlingVelocity() minimum fling velocity}
565 * along a scrollable axis.</p>
566 *
Adam Powell10ba2772014-04-15 09:46:51 -0700567 * <p>If a nested scrolling child view would normally fling but it is at the edge of
Adam Powellb36e4f92014-05-01 10:23:33 -0700568 * its own content, it can use this method to delegate the fling to its nested scrolling
569 * parent instead. The parent may optionally consume the fling or observe a child fling.</p>
Adam Powell10ba2772014-04-15 09:46:51 -0700570 *
571 * @param target View that initiated the nested scroll
Adam Powellb72be592014-07-16 21:41:31 -0700572 * @param velocityX Horizontal velocity in pixels per second
Adam Powell10ba2772014-04-15 09:46:51 -0700573 * @param velocityY Vertical velocity in pixels per second
Adam Powellb36e4f92014-05-01 10:23:33 -0700574 * @param consumed true if the child consumed the fling, false otherwise
575 * @return true if this parent consumed or otherwise reacted to the fling
Adam Powell10ba2772014-04-15 09:46:51 -0700576 */
Adam Powellb36e4f92014-05-01 10:23:33 -0700577 public boolean onNestedFling(View target, float velocityX, float velocityY, boolean consumed);
Adam Powellb72be592014-07-16 21:41:31 -0700578
579 /**
580 * React to a nested fling before the target view consumes it.
581 *
582 * <p>This method siginfies that a nested scrolling child has detected a fling with the given
583 * velocity along each axis. Generally this means that a touch scroll has ended with a
584 * {@link VelocityTracker velocity} in the direction of scrolling that meets or exceeds
585 * the {@link ViewConfiguration#getScaledMinimumFlingVelocity() minimum fling velocity}
586 * along a scrollable axis.</p>
587 *
588 * <p>If a nested scrolling parent is consuming motion as part of a
589 * {@link #onNestedPreScroll(View, int, int, int[]) pre-scroll}, it may be appropriate for
590 * it to also consume the pre-fling to complete that same motion. By returning
591 * <code>true</code> from this method, the parent indicates that the child should not
592 * fling its own internal content as well.</p>
593 *
594 * @param target View that initiated the nested scroll
595 * @param velocityX Horizontal velocity in pixels per second
596 * @param velocityY Vertical velocity in pixels per second
597 * @return true if this parent consumed the fling ahead of the target view
598 */
599 public boolean onNestedPreFling(View target, float velocityX, float velocityY);
Adam Powellb6ab0982015-01-07 17:00:12 -0800600
601 /**
602 * React to an accessibility action delegated by a target descendant view before the target
603 * processes it.
604 *
605 * <p>This method may be called by a target descendant view if the target wishes to give
606 * a view in its parent chain a chance to react to the event before normal processing occurs.
607 * Most commonly this will be a scroll event such as
608 * {@link android.view.accessibility.AccessibilityNodeInfo#ACTION_SCROLL_FORWARD}.
609 * A ViewParent that supports acting as a nested scrolling parent should override this
610 * method and act accordingly to implement scrolling via accesibility systems.</p>
611 *
612 * @param target The target view dispatching this action
613 * @param action Action being performed; see
614 * {@link android.view.accessibility.AccessibilityNodeInfo}
615 * @param arguments Optional action arguments
616 * @return true if the action was consumed by this ViewParent
617 */
618 public boolean onNestedPrePerformAccessibilityAction(View target, int action, Bundle arguments);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800619}