public final class ViewRootImpl extends Object implements ViewParent
WindowManagerGlobal
.
Modifier and Type | Class and Description |
---|---|
static class |
ViewRootImpl.CalledFromWrongThreadException |
Modifier and Type | Field and Description |
---|---|
protected InputEventConsistencyVerifier |
mInputEventConsistencyVerifier
Consistency verifier for debugging purposes.
|
static String |
PROPERTY_EMULATOR_WIN_OUTSET_BOTTOM_PX |
Constructor and Description |
---|
ViewRootImpl(Context context,
Display display) |
Modifier and Type | Method and Description |
---|---|
static void |
addConfigCallback(ComponentCallbacks callback) |
static void |
addFirstDrawHandler(Runnable callback) |
void |
addWindowCallbacks(WindowCallbacks callback) |
void |
bringChildToFront(View child)
Change the z order of the child so it's on top of all other children.
|
void |
cancelInvalidate(View view) |
boolean |
canResolveLayoutDirection()
Tells if this view parent can resolve the layout direction.
|
boolean |
canResolveTextAlignment()
Tells if this view parent can resolve the text alignment.
|
boolean |
canResolveTextDirection()
Tells if this view parent can resolve the text direction.
|
void |
childDrawableStateChanged(View child)
This method is called on the parent when a child's drawable state
has changed.
|
void |
childHasTransientStateChanged(View child,
boolean hasTransientState)
Called when a child view now has or no longer is tracking transient state.
|
void |
clearChildFocus(View child)
Called when a child of this parent is giving up focus
|
void |
createContextMenu(ContextMenu menu)
Have the parent populate the specified context menu if it has anything to
add (and then recurse on its parent).
|
void |
debug() |
void |
detachFunctor(long functor) |
void |
dispatchAppVisibility(boolean visible) |
void |
dispatchCheckFocus() |
void |
dispatchCloseSystemDialogs(String reason) |
void |
dispatchDragEvent(DragEvent event) |
void |
dispatchGetNewSurface() |
void |
dispatchInputEvent(InputEvent event) |
void |
dispatchInputEvent(InputEvent event,
InputEventReceiver receiver) |
void |
dispatchInvalidateDelayed(View view,
long delayMilliseconds) |
void |
dispatchInvalidateOnAnimation(View view) |
void |
dispatchInvalidateRectDelayed(android.view.View.AttachInfo.InvalidateInfo info,
long delayMilliseconds) |
void |
dispatchInvalidateRectOnAnimation(android.view.View.AttachInfo.InvalidateInfo info) |
void |
dispatchKeyFromIme(KeyEvent event) |
void |
dispatchMoved(int newX,
int newY) |
void |
dispatchRequestKeyboardShortcuts(IResultReceiver receiver,
int deviceId) |
void |
dispatchResized(Rect frame,
Rect overscanInsets,
Rect contentInsets,
Rect visibleInsets,
Rect stableInsets,
Rect outsets,
boolean reportDraw,
Configuration newConfig,
Rect backDropFrame,
boolean forceLayout,
boolean alwaysConsumeNavBar) |
void |
dispatchSystemUiVisibilityChanged(int seq,
int globalVisibility,
int localValue,
int localChanges) |
void |
dispatchUnhandledInputEvent(InputEvent event)
Reinject unhandled
InputEvent s in order to synthesize fallbacks events. |
void |
dispatchWindowShown() |
void |
dump(String prefix,
FileDescriptor fd,
PrintWriter writer,
String[] args) |
void |
dumpGfxInfo(int[] info) |
void |
focusableViewAvailable(View v)
Tells the parent that a new focusable view has become available.
|
View |
focusSearch(View focused,
int direction)
Find the nearest view in the specified direction that wants to take focus
|
View |
getAccessibilityFocusedHost() |
AccessibilityNodeInfo |
getAccessibilityFocusedVirtualView() |
android.view.AccessibilityInteractionController |
getAccessibilityInteractionController() |
boolean |
getChildVisibleRect(View child,
Rect r,
Point offset)
Compute the visible part of a rectangular region defined in terms of a child view's
coordinates.
|
int |
getDisplayId() |
void |
getLastTouchPoint(Point outLocation) |
int |
getLastTouchSource() |
int |
getLayoutDirection()
Return this view parent layout direction.
|
ViewParent |
getParent()
Returns the parent if it exists, or null.
|
ViewParent |
getParentForAccessibility()
Gets the parent of a given View for accessibility.
|
int |
getTextAlignment()
Return this view parent text alignment.
|
int |
getTextDirection()
Return this view parent text direction.
|
CharSequence |
getTitle() |
View |
getView() |
int |
getWindowFlags() |
void |
handleDispatchSystemUiVisibilityChanged(android.view.ViewRootImpl.SystemUiVisibilityInfo args) |
void |
handleDispatchWindowShown() |
void |
handleRequestKeyboardShortcuts(IResultReceiver receiver,
int deviceId) |
void |
invalidateChild(View child,
Rect dirty)
All or part of a child is dirty and needs to be redrawn.
|
ViewParent |
invalidateChildInParent(int[] location,
Rect dirty)
All or part of a child is dirty and needs to be redrawn.
|
static void |
invokeFunctor(long functor,
boolean waitForCompletion)
Schedules the functor for execution in either kModeProcess or
kModeProcessNoContext, depending on whether or not there is an EGLContext.
|
boolean |
isLayoutDirectionResolved()
Tells if this view parent layout direction is resolved.
|
boolean |
isLayoutRequested()
Indicates whether layout was requested on this view parent.
|
boolean |
isTextAlignmentResolved()
Tells if this view parent text alignment is resolved.
|
boolean |
isTextDirectionResolved()
Tells if this view parent text direction is resolved.
|
static boolean |
isViewDescendantOf(View child,
View parent)
Return true if child is an ancestor of parent, (or equal to the parent).
|
void |
loadSystemProperties() |
void |
notifyChildRebuilt()
Notifies us that our child has been rebuilt, following
a window preservation operation.
|
void |
notifySubtreeAccessibilityStateChanged(View child,
View source,
int changeType)
Notifies a view parent that the accessibility state of one of its
descendants has changed and that the structure of the subtree is
different.
|
void |
onHardwarePostDraw(DisplayListCanvas canvas)
Invoked after a view is drawn by a hardware renderer.
|
void |
onHardwarePreDraw(DisplayListCanvas canvas)
Invoked before a view is drawn by a hardware renderer.
|
boolean |
onNestedFling(View target,
float velocityX,
float velocityY,
boolean consumed)
Request a fling from a nested scroll.
|
boolean |
onNestedPreFling(View target,
float velocityX,
float velocityY)
React to a nested fling before the target view consumes it.
|
boolean |
onNestedPrePerformAccessibilityAction(View target,
int action,
Bundle args)
React to an accessibility action delegated by a target descendant view before the target
processes it.
|
void |
onNestedPreScroll(View target,
int dx,
int dy,
int[] consumed)
React to a nested scroll in progress before the target view consumes a portion of the scroll.
|
void |
onNestedScroll(View target,
int dxConsumed,
int dyConsumed,
int dxUnconsumed,
int dyUnconsumed)
React to a nested scroll in progress.
|
void |
onNestedScrollAccepted(View child,
View target,
int nestedScrollAxes)
React to the successful claiming of a nested scroll operation.
|
boolean |
onStartNestedScroll(View child,
View target,
int nestedScrollAxes)
React to a descendant view initiating a nestable scroll operation, claiming the
nested scroll operation if appropriate.
|
void |
onStopNestedScroll(View target)
React to a nested scroll operation ending.
|
boolean |
performHapticFeedback(int effectId,
boolean always) |
void |
playSoundEffect(int effectId) |
void |
profile()
Call this to profile the next traversal call.
|
void |
recomputeViewAttributes(View child)
Tell view hierarchy that the global view attributes need to be
re-evaluated.
|
void |
registerAnimatingRenderNode(RenderNode animator) |
void |
registerVectorDrawableAnimator(AnimatedVectorDrawable.VectorDrawableAnimatorRT animator) |
void |
removeWindowCallbacks(WindowCallbacks callback) |
void |
reportActivityRelaunched()
Tells this instance that its corresponding activity has just relaunched.
|
void |
reportDrawFinish() |
void |
requestChildFocus(View child,
View focused)
Called when a child of this parent wants focus
|
boolean |
requestChildRectangleOnScreen(View child,
Rect rectangle,
boolean immediate)
Called when a child of this group wants a particular rectangle to be
positioned onto the screen.
|
void |
requestDisallowInterceptTouchEvent(boolean disallowIntercept)
Called when a child does not want this parent and its ancestors to
intercept touch events with
ViewGroup.onInterceptTouchEvent(MotionEvent) . |
void |
requestFitSystemWindows()
Ask that a new dispatch of
View.fitSystemWindows(Rect) be performed. |
void |
requestInvalidateRootRenderNode()
Requests that the root render node is invalidated next time we perform a draw, such that
WindowCallbacks.onPostDraw(android.view.DisplayListCanvas) gets called. |
void |
requestLayout()
Called when something has changed which has invalidated the layout of a
child of this view parent.
|
boolean |
requestSendAccessibilityEvent(View child,
AccessibilityEvent event)
Called by a child to request from its parent to send an
AccessibilityEvent . |
void |
requestTransitionStart(LayoutTransition transition)
Add LayoutTransition to the list of transitions to be started in the next traversal.
|
void |
requestTransparentRegion(View child)
Called when a child wants the view hierarchy to gather and report
transparent regions to the window compositor.
|
void |
requestUpdateConfiguration(Configuration config) |
void |
setDragFocus(View newDragTarget,
DragEvent event) |
void |
setIsAmbientMode(boolean ambient) |
void |
setPausedForTransition(boolean paused)
Block the input events during an Activity Transition.
|
void |
setReportNextDraw()
Force the window to report its next draw.
|
void |
setView(View view,
WindowManager.LayoutParams attrs,
View panelParentView)
We have one child
|
boolean |
showContextMenuForChild(View originalView)
Shows the context menu for the specified view or its ancestors.
|
boolean |
showContextMenuForChild(View originalView,
float x,
float y)
Shows the context menu for the specified view or its ancestors anchored
to the specified view-relative coordinate.
|
ActionMode |
startActionModeForChild(View originalView,
ActionMode.Callback callback)
Start an action mode for the specified view with the default type
ActionMode.TYPE_PRIMARY . |
ActionMode |
startActionModeForChild(View originalView,
ActionMode.Callback callback,
int type)
Start an action mode of a specific type for the specified view.
|
void |
synthesizeInputEvent(InputEvent event) |
void |
updatePointerIcon(float x,
float y) |
void |
windowFocusChanged(boolean hasFocus,
boolean inTouchMode) |
public static final String PROPERTY_EMULATOR_WIN_OUTSET_BOTTOM_PX
protected final InputEventConsistencyVerifier mInputEventConsistencyVerifier
public static void addFirstDrawHandler(Runnable callback)
public static void addConfigCallback(ComponentCallbacks callback)
public void addWindowCallbacks(WindowCallbacks callback)
public void removeWindowCallbacks(WindowCallbacks callback)
public void reportDrawFinish()
public void profile()
public void notifyChildRebuilt()
public void setView(View view, WindowManager.LayoutParams attrs, View panelParentView)
public int getWindowFlags()
public int getDisplayId()
public CharSequence getTitle()
public void detachFunctor(long functor)
public static void invokeFunctor(long functor, boolean waitForCompletion)
functor
- The native functor to invokewaitForCompletion
- If true, this will not return until the functor
has invoked. If false, the functor may be invoked
asynchronously.public void registerAnimatingRenderNode(RenderNode animator)
public void registerVectorDrawableAnimator(AnimatedVectorDrawable.VectorDrawableAnimatorRT animator)
public View getView()
public void requestFitSystemWindows()
ViewParent
View.fitSystemWindows(Rect)
be performed.requestFitSystemWindows
in interface ViewParent
public void requestLayout()
ViewParent
requestLayout
in interface ViewParent
public boolean isLayoutRequested()
ViewParent
isLayoutRequested
in interface ViewParent
public void invalidateChild(View child, Rect dirty)
ViewParent
invalidateChild
in interface ViewParent
child
- The child which is dirtydirty
- The area within the child that is invalidpublic ViewParent invalidateChildInParent(int[] location, Rect dirty)
ViewParent
The location array is an array of two int values which respectively define the left and the top position of the dirty child.
This method must return the parent of this ViewParent if the specified rectangle must be invalidated in the parent. If the specified rectangle does not require invalidation in the parent or if the parent does not exist, this method must return null.
When this method returns a non-null value, the location array must have been updated with the left and top coordinates of this ViewParent.
invalidateChildInParent
in interface ViewParent
location
- An array of 2 ints containing the left and top
coordinates of the child to invalidatedirty
- The area within the child that is invalidpublic void setIsAmbientMode(boolean ambient)
public void setPausedForTransition(boolean paused)
paused
- true to pause, false to resume.public ViewParent getParent()
ViewParent
getParent
in interface ViewParent
public boolean getChildVisibleRect(View child, Rect r, Point offset)
ViewParent
Returns the clipped visible part of the rectangle r
, defined in the
child
's local coordinate system. r
is modified by this method to
contain the result, expressed in the global (root) coordinate system.
The resulting rectangle is always axis aligned. If a rotation is applied to a node in the View hierarchy, the result is the axis-aligned bounding box of the visible rectangle.
getChildVisibleRect
in interface ViewParent
child
- A child View, whose rectangular visible region we want to computer
- The input rectangle, defined in the child coordinate system. Will be overwritten to
contain the resulting visible rectangle, expressed in global (root) coordinatesoffset
- The input coordinates of a point, defined in the child coordinate system.
As with the r
parameter, this will be overwritten to contain the global (root)
coordinates of that point.
A null
value is valid (in case you are not interested in this result)public void bringChildToFront(View child)
ViewParent
Build.VERSION_CODES.KITKAT
this
method should be followed by calls to ViewParent.requestLayout()
and
View.invalidate()
on this parent to force the parent to redraw
with the new child ordering.bringChildToFront
in interface ViewParent
child
- The child to bring to the top of the z orderpublic void requestTransitionStart(LayoutTransition transition)
transition
- The LayoutTransition to be started on the next traversal.public void requestTransparentRegion(View child)
ViewParent
requestTransparentRegion
in interface ViewParent
child
- the view requesting the transparent region computationpublic void onHardwarePreDraw(DisplayListCanvas canvas)
canvas
- The Canvas used to render the view.public void onHardwarePostDraw(DisplayListCanvas canvas)
canvas
- The Canvas used to render the view.public void requestInvalidateRootRenderNode()
WindowCallbacks.onPostDraw(android.view.DisplayListCanvas)
gets called.public View getAccessibilityFocusedHost()
public AccessibilityNodeInfo getAccessibilityFocusedVirtualView()
public void requestChildFocus(View child, View focused)
ViewParent
requestChildFocus
in interface ViewParent
child
- The child of this ViewParent that wants focus. This view
will contain the focused view. It is not necessarily the view that
actually has focus.focused
- The view that is a descendant of child that actually has
focuspublic void clearChildFocus(View child)
ViewParent
clearChildFocus
in interface ViewParent
child
- The view that is giving up focuspublic ViewParent getParentForAccessibility()
ViewParent
getParentForAccessibility
in interface ViewParent
null
if no such is found.public void focusableViewAvailable(View v)
ViewParent
focusableViewAvailable
in interface ViewParent
v
- The view that has become newly focusablepublic void recomputeViewAttributes(View child)
ViewParent
recomputeViewAttributes
in interface ViewParent
child
- View whose attributes have changed.public static boolean isViewDescendantOf(View child, View parent)
public void handleDispatchSystemUiVisibilityChanged(android.view.ViewRootImpl.SystemUiVisibilityInfo args)
public void handleDispatchWindowShown()
public void handleRequestKeyboardShortcuts(IResultReceiver receiver, int deviceId)
public void getLastTouchPoint(Point outLocation)
public int getLastTouchSource()
public android.view.AccessibilityInteractionController getAccessibilityInteractionController()
public void playSoundEffect(int effectId)
public boolean performHapticFeedback(int effectId, boolean always)
public View focusSearch(View focused, int direction)
focusSearch
in interface ViewParent
focused
- The view that currently has focusdirection
- One of FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, and FOCUS_RIGHTpublic void debug()
public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args)
public void dumpGfxInfo(int[] info)
public void requestUpdateConfiguration(Configuration config)
public void loadSystemProperties()
public void dispatchResized(Rect frame, Rect overscanInsets, Rect contentInsets, Rect visibleInsets, Rect stableInsets, Rect outsets, boolean reportDraw, Configuration newConfig, Rect backDropFrame, boolean forceLayout, boolean alwaysConsumeNavBar)
public void dispatchMoved(int newX, int newY)
public void dispatchInvalidateDelayed(View view, long delayMilliseconds)
public void dispatchInvalidateRectDelayed(android.view.View.AttachInfo.InvalidateInfo info, long delayMilliseconds)
public void dispatchInvalidateOnAnimation(View view)
public void dispatchInvalidateRectOnAnimation(android.view.View.AttachInfo.InvalidateInfo info)
public void cancelInvalidate(View view)
public void dispatchInputEvent(InputEvent event)
public void dispatchInputEvent(InputEvent event, InputEventReceiver receiver)
public void synthesizeInputEvent(InputEvent event)
public void dispatchKeyFromIme(KeyEvent event)
public void dispatchUnhandledInputEvent(InputEvent event)
InputEvent
s in order to synthesize fallbacks events.
Note that it is the responsibility of the caller of this API to recycle the InputEvent it
passes in.public void dispatchAppVisibility(boolean visible)
public void dispatchGetNewSurface()
public void windowFocusChanged(boolean hasFocus, boolean inTouchMode)
public void dispatchWindowShown()
public void dispatchCloseSystemDialogs(String reason)
public void dispatchDragEvent(DragEvent event)
public void updatePointerIcon(float x, float y)
public void dispatchSystemUiVisibilityChanged(int seq, int globalVisibility, int localValue, int localChanges)
public void dispatchCheckFocus()
public void dispatchRequestKeyboardShortcuts(IResultReceiver receiver, int deviceId)
public boolean showContextMenuForChild(View originalView)
ViewParent
In most cases, a subclass does not need to override this. However, if
the subclass is added directly to the window manager (for example,
ViewManager.addView(View, android.view.ViewGroup.LayoutParams)
)
then it should override this and show the context menu.
showContextMenuForChild
in interface ViewParent
originalView
- the source view where the context menu was first
invokedtrue
if the context menu was shown, false
otherwiseViewParent.showContextMenuForChild(View, float, float)
public boolean showContextMenuForChild(View originalView, float x, float y)
ViewParent
In most cases, a subclass does not need to override this. However, if
the subclass is added directly to the window manager (for example,
ViewManager.addView(View, android.view.ViewGroup.LayoutParams)
)
then it should override this and show the context menu.
If a subclass overrides this method it should also override
ViewParent.showContextMenuForChild(View)
.
showContextMenuForChild
in interface ViewParent
originalView
- the source view where the context menu was first
invokedx
- the X coordinate in pixels relative to the original view to
which the menu should be anchored, or Float.NaN
to
disable anchoringy
- the Y coordinate in pixels relative to the original view to
which the menu should be anchored, or Float.NaN
to
disable anchoringtrue
if the context menu was shown, false
otherwisepublic ActionMode startActionModeForChild(View originalView, ActionMode.Callback callback)
ViewParent
ActionMode.TYPE_PRIMARY
.
In most cases, a subclass does not need to override this. However, if the
subclass is added directly to the window manager (for example,
ViewManager.addView(View, android.view.ViewGroup.LayoutParams)
)
then it should override this and start the action mode.
startActionModeForChild
in interface ViewParent
originalView
- The source view where the action mode was first invokedcallback
- The callback that will handle lifecycle events for the action modeViewParent.startActionModeForChild(View, android.view.ActionMode.Callback, int)
public ActionMode startActionModeForChild(View originalView, ActionMode.Callback callback, int type)
ViewParent
In most cases, a subclass does not need to override this. However, if the
subclass is added directly to the window manager (for example,
ViewManager.addView(View, android.view.ViewGroup.LayoutParams)
)
then it should override this and start the action mode.
startActionModeForChild
in interface ViewParent
originalView
- The source view where the action mode was first invokedcallback
- The callback that will handle lifecycle events for the action modetype
- One of ActionMode.TYPE_PRIMARY
or ActionMode.TYPE_FLOATING
.public void createContextMenu(ContextMenu menu)
ViewParent
createContextMenu
in interface ViewParent
menu
- The menu to populatepublic void childDrawableStateChanged(View child)
ViewParent
childDrawableStateChanged
in interface ViewParent
child
- The child whose drawable state has changed.public boolean requestSendAccessibilityEvent(View child, AccessibilityEvent event)
ViewParent
AccessibilityEvent
.
The child has already populated a record for itself in the event and is delegating
to its parent to send the event. The parent can optionally add a record for itself.
Note: An accessibility event is fired by an individual view which populates the event with a record for its state and requests from its parent to perform the sending. The parent can optionally add a record for itself before dispatching the request to its parent. A parent can also choose not to respect the request for sending the event. The accessibility event is sent by the topmost view in the view tree.
requestSendAccessibilityEvent
in interface ViewParent
child
- The child which requests sending the event.event
- The event to be sent.public void notifySubtreeAccessibilityStateChanged(View child, View source, int changeType)
ViewParent
notifySubtreeAccessibilityStateChanged
in interface ViewParent
child
- The direct child whose subtree has changed.source
- The descendant view that changed.changeType
- A bit mask of the types of changes that occurred. One
or more of:
public boolean canResolveLayoutDirection()
ViewParent
View.setLayoutDirection(int)
canResolveLayoutDirection
in interface ViewParent
public boolean isLayoutDirectionResolved()
ViewParent
View.setLayoutDirection(int)
isLayoutDirectionResolved
in interface ViewParent
public int getLayoutDirection()
ViewParent
View.getLayoutDirection()
getLayoutDirection
in interface ViewParent
View.LAYOUT_DIRECTION_RTL
if the layout direction is RTL or returns
View.LAYOUT_DIRECTION_LTR
if the layout direction is not RTL.public boolean canResolveTextDirection()
ViewParent
View.setTextDirection(int)
canResolveTextDirection
in interface ViewParent
public boolean isTextDirectionResolved()
ViewParent
View.setTextDirection(int)
isTextDirectionResolved
in interface ViewParent
public int getTextDirection()
ViewParent
View.getTextDirection()
getTextDirection
in interface ViewParent
View.TEXT_DIRECTION_FIRST_STRONG
View.TEXT_DIRECTION_ANY_RTL
,
View.TEXT_DIRECTION_LTR
,
View.TEXT_DIRECTION_RTL
,
View.TEXT_DIRECTION_LOCALE
public boolean canResolveTextAlignment()
ViewParent
View.setTextAlignment(int)
canResolveTextAlignment
in interface ViewParent
public boolean isTextAlignmentResolved()
ViewParent
View.setTextAlignment(int)
isTextAlignmentResolved
in interface ViewParent
public int getTextAlignment()
ViewParent
View.getTextAlignment()
getTextAlignment
in interface ViewParent
View.TEXT_ALIGNMENT_GRAVITY
,
View.TEXT_ALIGNMENT_CENTER
,
View.TEXT_ALIGNMENT_TEXT_START
,
View.TEXT_ALIGNMENT_TEXT_END
,
View.TEXT_ALIGNMENT_VIEW_START
,
View.TEXT_ALIGNMENT_VIEW_END
public void requestDisallowInterceptTouchEvent(boolean disallowIntercept)
ViewParent
ViewGroup.onInterceptTouchEvent(MotionEvent)
.
This parent should pass this call onto its parents. This parent must obey this request for the duration of the touch (that is, only clear the flag after this parent has received an up or a cancel.
requestDisallowInterceptTouchEvent
in interface ViewParent
disallowIntercept
- True if the child does not want the parent to
intercept touch events.public boolean requestChildRectangleOnScreen(View child, Rect rectangle, boolean immediate)
ViewParent
ViewGroup
s overriding this can trust
that:
ViewGroup
s overriding this should uphold the contract:
requestChildRectangleOnScreen
in interface ViewParent
child
- The direct child making the request.rectangle
- The rectangle in the child's coordinates the child
wishes to be on the screen.immediate
- True to forbid animated or delayed scrolling,
false otherwisepublic void childHasTransientStateChanged(View child, boolean hasTransientState)
ViewParent
"Transient state" is any state that a View might hold that is not expected to be reflected in the data model that the View currently presents. This state only affects the presentation to the user within the View itself, such as the current state of animations in progress or the state of a text selection operation.
Transient state is useful for hinting to other components of the View system
that a particular view is tracking something complex but encapsulated.
A ListView
for example may acknowledge that list item Views
with transient state should be preserved within their position or stable item ID
instead of treating that view as trivially replaceable by the backing adapter.
This allows adapter implementations to be simpler instead of needing to track
the state of item view animations in progress such that they could be restored
in the event of an unexpected recycling and rebinding of attached item views.
This method is called on a parent view when a child view or a view within its subtree begins or ends tracking of internal transient state.
childHasTransientStateChanged
in interface ViewParent
child
- Child view whose state has changedhasTransientState
- true if this child has transient statepublic boolean onStartNestedScroll(View child, View target, int nestedScrollAxes)
ViewParent
This method will be called in response to a descendant view invoking
View.startNestedScroll(int)
. Each parent up the view hierarchy will be
given an opportunity to respond and claim the nested scrolling operation by returning
true
.
This method may be overridden by ViewParent implementations to indicate when the view
is willing to support a nested scrolling operation that is about to begin. If it returns
true, this ViewParent will become the target view's nested scrolling parent for the duration
of the scroll operation in progress. When the nested scroll is finished this ViewParent
will receive a call to ViewParent.onStopNestedScroll(View)
.
onStartNestedScroll
in interface ViewParent
child
- Direct child of this ViewParent containing targettarget
- View that initiated the nested scrollnestedScrollAxes
- Flags consisting of View.SCROLL_AXIS_HORIZONTAL
,
View.SCROLL_AXIS_VERTICAL
or bothpublic void onStopNestedScroll(View target)
ViewParent
Perform cleanup after a nested scrolling operation.
This method will be called when a nested scroll stops, for example when a nested touch
scroll ends with a MotionEvent.ACTION_UP
or MotionEvent.ACTION_CANCEL
event.
Implementations of this method should always call their superclass's implementation of this
method if one is present.
onStopNestedScroll
in interface ViewParent
target
- View that initiated the nested scrollpublic void onNestedScrollAccepted(View child, View target, int nestedScrollAxes)
ViewParent
This method will be called after
onStartNestedScroll
returns true. It offers
an opportunity for the view and its superclasses to perform initial configuration
for the nested scroll. Implementations of this method should always call their superclass's
implementation of this method if one is present.
onNestedScrollAccepted
in interface ViewParent
child
- Direct child of this ViewParent containing targettarget
- View that initiated the nested scrollnestedScrollAxes
- Flags consisting of View.SCROLL_AXIS_HORIZONTAL
,
View.SCROLL_AXIS_VERTICAL
or bothViewParent.onStartNestedScroll(View, View, int)
,
ViewParent.onStopNestedScroll(View)
public void onNestedScroll(View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed)
ViewParent
This method will be called when the ViewParent's current nested scrolling child view
dispatches a nested scroll event. To receive calls to this method the ViewParent must have
previously returned true
for a call to
ViewParent.onStartNestedScroll(View, View, int)
.
Both the consumed and unconsumed portions of the scroll distance are reported to the ViewParent. An implementation may choose to use the consumed portion to match or chase scroll position of multiple child elements, for example. The unconsumed portion may be used to allow continuous dragging of multiple scrolling or draggable elements, such as scrolling a list within a vertical drawer where the drawer begins dragging once the edge of inner scrolling content is reached.
onNestedScroll
in interface ViewParent
target
- The descendent view controlling the nested scrolldxConsumed
- Horizontal scroll distance in pixels already consumed by targetdyConsumed
- Vertical scroll distance in pixels already consumed by targetdxUnconsumed
- Horizontal scroll distance in pixels not consumed by targetdyUnconsumed
- Vertical scroll distance in pixels not consumed by targetpublic void onNestedPreScroll(View target, int dx, int dy, int[] consumed)
ViewParent
When working with nested scrolling often the parent view may want an opportunity to consume the scroll before the nested scrolling child does. An example of this is a drawer that contains a scrollable list. The user will want to be able to scroll the list fully into view before the list itself begins scrolling.
onNestedPreScroll
is called when a nested scrolling child invokes
View.dispatchNestedPreScroll(int, int, int[], int[])
. The implementation should
report how any pixels of the scroll reported by dx, dy were consumed in the
consumed
array. Index 0 corresponds to dx and index 1 corresponds to dy.
This parameter will never be null. Initial values for consumed[0] and consumed[1]
will always be 0.
onNestedPreScroll
in interface ViewParent
target
- View that initiated the nested scrolldx
- Horizontal scroll distance in pixelsdy
- Vertical scroll distance in pixelsconsumed
- Output. The horizontal and vertical scroll distance consumed by this parentpublic boolean onNestedFling(View target, float velocityX, float velocityY, boolean consumed)
ViewParent
This method signifies that a nested scrolling child has detected suitable conditions
for a fling. Generally this means that a touch scroll has ended with a
velocity
in the direction of scrolling that meets or exceeds
the minimum fling velocity
along a scrollable axis.
If a nested scrolling child view would normally fling but it is at the edge of its own content, it can use this method to delegate the fling to its nested scrolling parent instead. The parent may optionally consume the fling or observe a child fling.
onNestedFling
in interface ViewParent
target
- View that initiated the nested scrollvelocityX
- Horizontal velocity in pixels per secondvelocityY
- Vertical velocity in pixels per secondconsumed
- true if the child consumed the fling, false otherwisepublic boolean onNestedPreFling(View target, float velocityX, float velocityY)
ViewParent
This method siginfies that a nested scrolling child has detected a fling with the given
velocity along each axis. Generally this means that a touch scroll has ended with a
velocity
in the direction of scrolling that meets or exceeds
the minimum fling velocity
along a scrollable axis.
If a nested scrolling parent is consuming motion as part of a
pre-scroll
, it may be appropriate for
it to also consume the pre-fling to complete that same motion. By returning
true
from this method, the parent indicates that the child should not
fling its own internal content as well.
onNestedPreFling
in interface ViewParent
target
- View that initiated the nested scrollvelocityX
- Horizontal velocity in pixels per secondvelocityY
- Vertical velocity in pixels per secondpublic boolean onNestedPrePerformAccessibilityAction(View target, int action, Bundle args)
ViewParent
This method may be called by a target descendant view if the target wishes to give
a view in its parent chain a chance to react to the event before normal processing occurs.
Most commonly this will be a scroll event such as
AccessibilityNodeInfo.ACTION_SCROLL_FORWARD
.
A ViewParent that supports acting as a nested scrolling parent should override this
method and act accordingly to implement scrolling via accesibility systems.
onNestedPrePerformAccessibilityAction
in interface ViewParent
target
- The target view dispatching this actionaction
- Action being performed; see
AccessibilityNodeInfo
args
- Optional action argumentspublic void setReportNextDraw()
This method is only supposed to be used to speed up the interaction from SystemUI and window manager when waiting for the first frame to be drawn when turning on the screen. DO NOT USE unless you fully understand this interaction.
public void reportActivityRelaunched()