@NotThreadSafe
public class NativeViewHierarchyManager
extends java.lang.Object
UIManagerModule
that owns the native view hierarchy and mapping between
native view names used in JS and corresponding instances of ViewManager
. The
UIManagerModule
communicates with this class by it's public interface methods:
- updateProperties(int, com.facebook.react.uimanager.ReactStylesDiffMap)
- updateLayout(int, int, int, int, int, int)
- createView(com.facebook.react.uimanager.ThemedReactContext, int, java.lang.String, com.facebook.react.uimanager.ReactStylesDiffMap)
- manageChildren(int, int[], com.facebook.react.uimanager.ViewAtIndex[], int[])
executing all the scheduled UI operations at the end of JS batch.
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
ReactContext
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 ReactContext
for each root view added to the manager (see
addRootView(int, com.facebook.react.uimanager.common.SizeMonitoringFrameLayout, com.facebook.react.uimanager.ThemedReactContext)
).
TODO(5483031): Only dispatch updates when shadow views have changedConstructor and Description |
---|
NativeViewHierarchyManager(ViewManagerRegistry viewManagers) |
NativeViewHierarchyManager(ViewManagerRegistry viewManagers,
RootViewManager manager) |
Modifier and Type | Method and Description |
---|---|
void |
addRootView(int tag,
SizeMonitoringFrameLayout view,
ThemedReactContext themedContext)
|
protected void |
addRootViewGroup(int tag,
android.view.ViewGroup view,
ThemedReactContext themedContext) |
void |
clearJSResponder() |
void |
createView(ThemedReactContext themedContext,
int tag,
java.lang.String className,
ReactStylesDiffMap initialProps) |
void |
dismissPopupMenu()
Dismiss the last opened PopupMenu
PopupMenu . |
void |
dispatchCommand(int reactTag,
int commandId,
ReadableArray args) |
protected void |
dropView(android.view.View view)
Releases all references to given native View.
|
int |
findTargetTagForTouch(int reactTag,
float touchX,
float touchY) |
AnimationRegistry |
getAnimationRegistry() |
long |
getInstanceHandle(int reactTag) |
void |
manageChildren(int tag,
int[] indicesToRemove,
ViewAtIndex[] viewsToAdd,
int[] tagsToDelete) |
void |
measure(int tag,
int[] outputBuffer)
Returns true on success, false on failure.
|
void |
measureInWindow(int tag,
int[] outputBuffer)
Returns the coordinates of a view relative to the window (not just the RootView
which is what measure will return)
|
void |
removeRootView(int rootViewTag) |
android.view.View |
resolveView(int tag) |
ViewManager |
resolveViewManager(int tag) |
void |
sendAccessibilityEvent(int tag,
int eventType) |
void |
setChildren(int tag,
ReadableArray childrenTags)
Simplified version of manageChildren that only deals with adding children views
|
void |
setJSResponder(int reactTag,
int initialReactTag,
boolean blockNativeResponder) |
void |
setLayoutAnimationEnabled(boolean enabled) |
void |
showPopupMenu(int reactTag,
ReadableArray items,
Callback success,
Callback error)
Show a
PopupMenu . |
void |
updateInstanceHandle(int tag,
long instanceHandle) |
void |
updateLayout(int parentTag,
int tag,
int x,
int y,
int width,
int height) |
void |
updateProperties(int tag,
ReactStylesDiffMap props) |
void |
updateViewExtraData(int tag,
java.lang.Object extraData) |
public NativeViewHierarchyManager(ViewManagerRegistry viewManagers)
public NativeViewHierarchyManager(ViewManagerRegistry viewManagers, RootViewManager manager)
public final android.view.View resolveView(int tag)
public final ViewManager resolveViewManager(int tag)
public AnimationRegistry getAnimationRegistry()
public void setLayoutAnimationEnabled(boolean enabled)
public void updateInstanceHandle(int tag, long instanceHandle)
public void updateProperties(int tag, ReactStylesDiffMap props)
public void updateViewExtraData(int tag, java.lang.Object extraData)
public void updateLayout(int parentTag, int tag, int x, int y, int width, int height)
@Nullable public long getInstanceHandle(int reactTag)
public void createView(ThemedReactContext themedContext, int tag, java.lang.String className, @Nullable ReactStylesDiffMap initialProps)
public void manageChildren(int tag, @Nullable int[] indicesToRemove, @Nullable ViewAtIndex[] viewsToAdd, @Nullable int[] tagsToDelete)
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 represent
a view which should be added at the specified indextagsToDelete
- list of tags corresponding to views that should be removedpublic void setChildren(int tag, ReadableArray childrenTags)
public void addRootView(int tag, SizeMonitoringFrameLayout view, ThemedReactContext themedContext)
protected final void addRootViewGroup(int tag, android.view.ViewGroup view, ThemedReactContext themedContext)
protected void dropView(android.view.View view)
public void removeRootView(int rootViewTag)
public void measure(int tag, int[] outputBuffer)
public void measureInWindow(int tag, int[] outputBuffer)
tag
- - the tag for the viewoutputBuffer
- - output buffer that contains [x,y,width,height] of the view in coordinates
relative to the device windowpublic int findTargetTagForTouch(int reactTag, float touchX, float touchY)
public void setJSResponder(int reactTag, int initialReactTag, boolean blockNativeResponder)
public void clearJSResponder()
public void dispatchCommand(int reactTag, int commandId, @Nullable ReadableArray args)
public void showPopupMenu(int reactTag, ReadableArray items, Callback success, Callback error)
PopupMenu
.reactTag
- the tag of the anchor view (the PopupMenu is displayed next to this view); this
needs 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, or
no arguments if the menu is dismissedpublic void dismissPopupMenu()
PopupMenu
.public void sendAccessibilityEvent(int tag, int eventType)