-
@NotThreadSafe() public class NativeViewHierarchyManager
Delegate of UIManagerModule that owns the native view hierarchy and mapping between native view names used in JS and corresponding instances of ViewManager. The communicates with this class by it's public interface methods:
- updateProperties
- updateLayout
- createView
- manageChildren
NB: All native view management methods listed above must be called from the UI thread.
The ReactContext instance that is passed to views that this manager creates differs from the one that we pass as a constructor. Instead we wrap the provided instance of in an instance of ThemedReactContext that additionally provide a correct theme based on the root view for a view tree that we attach newly created view to. Therefore this view manager will create a copy of ThemedReactContext that wraps the instance of for each root view added to the manager (see addRootView).
TODO(5483031): Only dispatch updates when shadow views have changed
-
-
Constructor Summary
Constructors Constructor Description NativeViewHierarchyManager(ViewManagerRegistry viewManagers)
NativeViewHierarchyManager(ViewManagerRegistry viewManagers, RootViewManager manager)
-
Method Summary
Modifier and Type Method Description final synchronized View
resolveView(int tag)
final synchronized ViewManager
resolveViewManager(int tag)
void
setLayoutAnimationEnabled(boolean enabled)
synchronized void
updateInstanceHandle(int tag, long instanceHandle)
synchronized void
updateProperties(int tag, ReactStylesDiffMap props)
synchronized void
updateViewExtraData(int tag, Object extraData)
synchronized void
updateLayout(int parentTag, int tag, int x, int y, int width, int height)
long
getInstanceHandle(int reactTag)
synchronized void
createView(ThemedReactContext themedContext, int tag, String className, @Nullable() ReactStylesDiffMap initialProps)
synchronized void
manageChildren(int tag, @Nullable() Array<int> indicesToRemove, @Nullable() Array<ViewAtIndex> viewsToAdd, @Nullable() Array<int> tagsToDelete)
synchronized void
setChildren(int tag, ReadableArray childrenTags)
Simplified version of manageChildren that only deals with adding children views synchronized void
addRootView(int tag, View view)
See addRootView. synchronized void
removeRootView(int rootViewTag)
synchronized void
measure(int tag, Array<int> outputBuffer)
Returns true on success, false on failure. synchronized void
measureInWindow(int tag, Array<int> outputBuffer)
Returns the coordinates of a view relative to the window (not just the RootView which is whatmeasure will return) synchronized int
findTargetTagForTouch(int reactTag, float touchX, float touchY)
synchronized void
setJSResponder(int reactTag, int initialReactTag, boolean blockNativeResponder)
void
clearJSResponder()
synchronized void
dispatchCommand(int reactTag, int commandId, @Nullable() ReadableArray args)
synchronized void
dispatchCommand(int reactTag, String commandId, @Nullable() ReadableArray args)
synchronized void
showPopupMenu(int reactTag, ReadableArray items, Callback success, Callback error)
Show a PopupMenu. void
dismissPopupMenu()
Dismiss the last opened PopupMenu PopupMenu. void
sendAccessibilityEvent(int tag, int eventType)
-
-
Constructor Detail
-
NativeViewHierarchyManager
NativeViewHierarchyManager(ViewManagerRegistry viewManagers)
-
NativeViewHierarchyManager
NativeViewHierarchyManager(ViewManagerRegistry viewManagers, RootViewManager manager)
-
-
Method Detail
-
resolveView
final synchronized View resolveView(int tag)
-
resolveViewManager
final synchronized ViewManager resolveViewManager(int tag)
-
setLayoutAnimationEnabled
void setLayoutAnimationEnabled(boolean enabled)
-
updateInstanceHandle
synchronized void updateInstanceHandle(int tag, long instanceHandle)
-
updateProperties
synchronized void updateProperties(int tag, ReactStylesDiffMap props)
-
updateViewExtraData
synchronized void updateViewExtraData(int tag, Object extraData)
-
updateLayout
synchronized void updateLayout(int parentTag, int tag, int x, int y, int width, int height)
-
getInstanceHandle
@Nullable() long getInstanceHandle(int reactTag)
-
createView
synchronized void createView(ThemedReactContext themedContext, int tag, String className, @Nullable() ReactStylesDiffMap initialProps)
-
manageChildren
synchronized void manageChildren(int tag, @Nullable() Array<int> indicesToRemove, @Nullable() Array<ViewAtIndex> viewsToAdd, @Nullable() Array<int> tagsToDelete)
- Parameters:
tag
- react tag of the node we want to manageindicesToRemove
- ordered (asc) list of indicies at which view should be removedviewsToAdd
- ordered (asc based on mIndex property) list of tag-index pairs that representa view which should be added at the specified indextagsToDelete
- list of tags corresponding to views that should be removed
-
setChildren
synchronized void setChildren(int tag, ReadableArray childrenTags)
Simplified version of manageChildren that only deals with adding children views
-
addRootView
synchronized void addRootView(int tag, View view)
See addRootView.
-
removeRootView
synchronized void removeRootView(int rootViewTag)
-
measure
synchronized void measure(int tag, Array<int> outputBuffer)
Returns true on success, false on failure. If successful, after calling, output buffer will be {x, y, width, height}.
-
measureInWindow
synchronized void measureInWindow(int tag, Array<int> outputBuffer)
Returns the coordinates of a view relative to the window (not just the RootView which is whatmeasure will return)
- Parameters:
tag
- - the tag for the viewoutputBuffer
- - output buffer that contains [x,y,width,height] of the view in coordinatesrelative to the device window
-
findTargetTagForTouch
synchronized int findTargetTagForTouch(int reactTag, float touchX, float touchY)
-
setJSResponder
synchronized void setJSResponder(int reactTag, int initialReactTag, boolean blockNativeResponder)
-
clearJSResponder
void clearJSResponder()
-
dispatchCommand
@Deprecated() synchronized void dispatchCommand(int reactTag, int commandId, @Nullable() ReadableArray args)
-
dispatchCommand
synchronized void dispatchCommand(int reactTag, String commandId, @Nullable() ReadableArray args)
-
showPopupMenu
synchronized void showPopupMenu(int reactTag, ReadableArray items, Callback success, Callback error)
Show a PopupMenu.
- Parameters:
reactTag
- the tag of the anchor view (the PopupMenu is displayed next to this view); thisneeds to be the tag of a native view (shadow views can not be anchors)items
- the menu items as an array of stringssuccess
- will be called with the position of the selected item as the first argument, orno arguments if the menu is dismissed
-
dismissPopupMenu
void dismissPopupMenu()
Dismiss the last opened PopupMenu PopupMenu.
-
sendAccessibilityEvent
void sendAccessibilityEvent(int tag, int eventType)
-
-
-
-