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.
|
Constructor and Description |
---|
ViewRootImpl(Context context,
Display display) |
Modifier and Type | Method and Description |
---|---|
static void |
addConfigCallback(ComponentCallbacks callback) |
static void |
addFirstDrawHandler(Runnable callback) |
boolean |
attachFunctor(int functor) |
void |
bringChildToFront(View child)
Change the z order of the child so it's on top of all other children
|
void |
cancelInvalidate(View view) |
void |
childAccessibilityStateChanged(View child)
A child notifies its parent that its state for accessibility has changed.
|
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 |
dequeueDisplayList(DisplayList displayList) |
void |
detachFunctor(int functor) |
void |
die(boolean immediate) |
void |
dispatchAppVisibility(boolean visible) |
void |
dispatchCheckFocus() |
void |
dispatchCloseSystemDialogs(String reason) |
void |
dispatchDoneAnimating() |
void |
dispatchDragEvent(DragEvent event) |
void |
dispatchFinishInputConnection(InputConnection connection) |
void |
dispatchGetNewSurface() |
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 |
dispatchKey(KeyEvent event) |
void |
dispatchKeyFromIme(KeyEvent event) |
void |
dispatchMoved(int newX,
int newY) |
void |
dispatchResized(Rect frame,
Rect contentInsets,
Rect visibleInsets,
boolean reportDraw,
Configuration newConfig) |
void |
dispatchScreenStateChange(boolean on) |
void |
dispatchSystemUiVisibilityChanged(int seq,
int globalVisibility,
int localValue,
int localChanges) |
void |
dispatchUnhandledKey(KeyEvent event) |
void |
dumpGfxInfo(int[] info) |
void |
enqueueDisplayList(DisplayList displayList) |
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.
|
void |
getLastTouchPoint(Point outLocation) |
ViewParent |
getParent()
Returns the parent if it exists, or null.
|
ViewParent |
getParentForAccessibility()
Gets the parent of a given View for accessibility.
|
View |
getView() |
void |
handleDispatchDoneAnimating() |
void |
handleDispatchSystemUiVisibilityChanged(android.view.ViewRootImpl.SystemUiVisibilityInfo args) |
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.
|
boolean |
isLayoutRequested()
Indicates whether layout was requested on this view parent.
|
static boolean |
isViewDescendantOf(View child,
View parent)
Return true if child is an ancestor of parent, (or equal to the parent).
|
void |
loadSystemProperties() |
void |
onHardwarePostDraw(HardwareCanvas canvas)
Invoked after a view is drawn by a hardware renderer.
|
void |
onHardwarePreDraw(HardwareCanvas canvas)
Invoked before a view is drawn by a hardware renderer.
|
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 |
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 |
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) |
void |
setView(View view,
WindowManager.LayoutParams attrs,
View panelParentView)
We have one child
|
boolean |
showContextMenuForChild(View originalView)
Bring up a context menu for the specified view or its ancestors.
|
ActionMode |
startActionModeForChild(View originalView,
ActionMode.Callback callback)
Start an action mode for the specified view.
|
void |
windowFocusChanged(boolean hasFocus,
boolean inTouchMode) |
protected final InputEventConsistencyVerifier mInputEventConsistencyVerifier
public static void addFirstDrawHandler(Runnable callback)
public static void addConfigCallback(ComponentCallbacks callback)
public void profile()
public void setView(View view, WindowManager.LayoutParams attrs, View panelParentView)
public boolean attachFunctor(int functor)
public void detachFunctor(int functor)
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 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
bringChildToFront
in interface ViewParent
public 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(HardwareCanvas canvas)
canvas
- The Canvas used to render the view.public void onHardwarePostDraw(HardwareCanvas canvas)
canvas
- The Canvas used to render the view.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 handleDispatchDoneAnimating()
public void getLastTouchPoint(Point outLocation)
public void setDragFocus(View newDragTarget)
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 dumpGfxInfo(int[] info)
public void die(boolean immediate)
public void requestUpdateConfiguration(Configuration config)
public void loadSystemProperties()
public void dispatchFinishInputConnection(InputConnection connection)
public void dispatchResized(Rect frame, Rect contentInsets, Rect visibleInsets, boolean reportDraw, Configuration newConfig)
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 enqueueDisplayList(DisplayList displayList)
public void dequeueDisplayList(DisplayList displayList)
public void cancelInvalidate(View view)
public void dispatchKey(KeyEvent event)
public void dispatchKeyFromIme(KeyEvent event)
public void dispatchUnhandledKey(KeyEvent event)
public void dispatchAppVisibility(boolean visible)
public void dispatchScreenStateChange(boolean on)
public void dispatchGetNewSurface()
public void windowFocusChanged(boolean hasFocus, boolean inTouchMode)
public void dispatchCloseSystemDialogs(String reason)
public void dispatchDragEvent(DragEvent event)
public void dispatchSystemUiVisibilityChanged(int seq, int globalVisibility, int localValue, int localChanges)
public void dispatchDoneAnimating()
public void dispatchCheckFocus()
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 invokedpublic ActionMode startActionModeForChild(View originalView, ActionMode.Callback callback)
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 modepublic 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 childAccessibilityStateChanged(View child)
ViewParent
childAccessibilityStateChanged
in interface ViewParent
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
childHasTransientStateChanged
in interface ViewParent
child
- Child view whose state has changedhasTransientState
- true if this child has transient state