@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.CatalystStylesDiffMap)
- updateLayout(int, int, int, int, int, int)
- createView(com.facebook.react.uimanager.ThemedReactContext, int, java.lang.String, com.facebook.react.uimanager.CatalystStylesDiffMap)
- 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.SizeMonitoringFrameLayout, com.facebook.react.uimanager.ThemedReactContext)).
TODO(5483031): Only dispatch updates when shadow views have changed| Constructor and Description |
|---|
NativeViewHierarchyManager(ViewManagerRegistry viewManagers) |
| 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,
CatalystStylesDiffMap initialProps) |
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() |
void |
manageChildren(int tag,
int[] indicesToRemove,
com.facebook.react.uimanager.ViewAtIndex[] viewsToAdd,
int[] tagsToDelete) |
void |
measure(int tag,
int[] outputBuffer)
Returns true on success, false on failure.
|
void |
removeRootView(int rootViewTag) |
protected android.view.View |
resolveView(int tag) |
protected ViewManager |
resolveViewManager(int tag) |
void |
sendAccessibilityEvent(int tag,
int eventType) |
void |
setJSResponder(int reactTag,
int initialReactTag,
boolean blockNativeResponder) |
void |
setLayoutAnimationEnabled(boolean enabled) |
void |
showPopupMenu(int reactTag,
ReadableArray items,
Callback success)
Show a
PopupMenu. |
void |
updateLayout(int parentTag,
int tag,
int x,
int y,
int width,
int height) |
void |
updateProperties(int tag,
CatalystStylesDiffMap props) |
void |
updateViewExtraData(int tag,
java.lang.Object extraData) |
public NativeViewHierarchyManager(ViewManagerRegistry viewManagers)
protected final android.view.View resolveView(int tag)
protected final ViewManager resolveViewManager(int tag)
public AnimationRegistry getAnimationRegistry()
public void setLayoutAnimationEnabled(boolean enabled)
public void updateProperties(int tag,
CatalystStylesDiffMap 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)
public void createView(ThemedReactContext themedContext, int tag, java.lang.String className, @Nullable CatalystStylesDiffMap initialProps)
public void manageChildren(int tag,
@Nullable
int[] indicesToRemove,
@Nullable
com.facebook.react.uimanager.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 addRootView(int tag,
SizeMonitoringFrameLayout view,
ThemedReactContext themedContext)
UIManagerModule.addMeasuredRootView(com.facebook.react.uimanager.SizeMonitoringFrameLayout).
Must be called from the UI thread.protected final void addRootViewGroup(int tag,
android.view.ViewGroup view,
ThemedReactContext themedContext)
protected final void dropView(android.view.View view)
public void removeRootView(int rootViewTag)
public void measure(int tag,
int[] outputBuffer)
public 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)
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 sendAccessibilityEvent(int tag,
int eventType)