public abstract class ViewManager<T extends android.view.View,C extends ReactShadowNode>
extends java.lang.Object
| Constructor and Description |
|---|
ViewManager() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addEventEmitters(ThemedReactContext reactContext,
T view)
Subclasses can override this method to install custom event emitters on the given View.
|
abstract C |
createCSSNodeInstance()
This method should return a subclass of
CSSNode which will be then used for measuring
position and size of the view. |
T |
createView(ThemedReactContext reactContext,
JSResponderHandler jsResponderHandler)
Creates a view and installs event emitters on it.
|
protected abstract T |
createViewInstance(ThemedReactContext reactContext)
Subclasses should return a new View instance of the proper type.
|
java.util.Map<java.lang.String,java.lang.Integer> |
getCommandsMap()
Subclasses of
ViewManager that expect to receive commands through
UIManagerModule.dispatchViewManagerCommand(int, int, com.facebook.react.bridge.ReadableArray) should override this method returning the
map between names of the commands and IDs that are then used in receiveCommand(T, int, com.facebook.react.bridge.ReadableArray) method
whenever the command is dispatched for this particular ViewManager. |
java.util.Map<java.lang.String,java.lang.Object> |
getExportedCustomBubblingEventTypeConstants()
Returns a map of config data passed to JS that defines eligible events that can be placed on
native views.
|
java.util.Map<java.lang.String,java.lang.Object> |
getExportedCustomDirectEventTypeConstants()
Returns a map of config data passed to JS that defines eligible events that can be placed on
native views.
|
java.util.Map<java.lang.String,java.lang.Object> |
getExportedViewConstants()
Returns a map of view-specific constants that are injected to JavaScript.
|
abstract java.lang.String |
getName() |
java.util.Map<java.lang.String,java.lang.String> |
getNativeProps() |
protected void |
onAfterUpdateTransaction(T view)
Callback that will be triggered after all properties are updated in current update transaction
(all @ReactProp handlers for properties updated in current transaction have been called).
|
void |
onDropViewInstance(ThemedReactContext reactContext,
T view)
Called when view is detached from view hierarchy and allows for some additional cleanup by
the
ViewManager subclass. |
void |
receiveCommand(T root,
int commandId,
ReadableArray args)
Subclasses may use this method to receive events/commands directly from JS through the
UIManager. |
abstract void |
updateExtraData(T root,
java.lang.Object extraData)
Subclasses can implement this method to receive an optional extra data enqueued from the
corresponding instance of
ReactShadowNode in
ReactShadowNode.onCollectExtraUpdates(com.facebook.react.uimanager.UIViewOperationQueue). |
void |
updateProperties(T viewToUpdate,
CatalystStylesDiffMap props) |
protected void |
updateView(T root,
CatalystStylesDiffMap props)
Deprecated.
|
public final void updateProperties(T viewToUpdate, CatalystStylesDiffMap props)
public final T createView(ThemedReactContext reactContext, JSResponderHandler jsResponderHandler)
public abstract java.lang.String getName()
public abstract C createCSSNodeInstance()
protected abstract T createViewInstance(ThemedReactContext reactContext)
reactContext - public void onDropViewInstance(ThemedReactContext reactContext, T view)
ViewManager subclass.protected void addEventEmitters(ThemedReactContext reactContext, T view)
@Deprecated protected void updateView(T root, CatalystStylesDiffMap props)
protected void onAfterUpdateTransaction(T view)
public abstract void updateExtraData(T root, java.lang.Object extraData)
ReactShadowNode in
ReactShadowNode.onCollectExtraUpdates(com.facebook.react.uimanager.UIViewOperationQueue).
Since css layout step and ui updates can be executed in separate thread apart of setting
x/y/width/height this is the recommended and thread-safe way of passing extra data from css
node to the native view counterpart.
TODO(7247021): Replace updateExtraData with generic update props mechanism after D2086999public void receiveCommand(T root, int commandId, @Nullable ReadableArray args)
UIManager. Good example of such a command would be scrollTo request with
coordinates for a ScrollView or goBack request for a WebView instance.root - View instance that should receive the commandcommandId - code of the commandargs - optional arguments for the command@Nullable public java.util.Map<java.lang.String,java.lang.Integer> getCommandsMap()
ViewManager that expect to receive commands through
UIManagerModule.dispatchViewManagerCommand(int, int, com.facebook.react.bridge.ReadableArray) should override this method returning the
map between names of the commands and IDs that are then used in receiveCommand(T, int, com.facebook.react.bridge.ReadableArray) method
whenever the command is dispatched for this particular ViewManager.
As an example we may consider ReactWebViewManager that expose the following commands:
goBack, goForward, reload. In this case the map returned from getCommandsMap() from
ReactWebViewManager will look as follows:
{
"goBack": 1,
"goForward": 2,
"reload": 3,
}
Now assuming that "reload" command is dispatched through UIManagerModule we trigger
ReactWebViewManager#receiveCommand passing "3" as commandId argument.@Nullable public java.util.Map<java.lang.String,java.lang.Object> getExportedCustomBubblingEventTypeConstants()
@Nullable public java.util.Map<java.lang.String,java.lang.Object> getExportedCustomDirectEventTypeConstants()
@Nullable public java.util.Map<java.lang.String,java.lang.Object> getExportedViewConstants()
public java.util.Map<java.lang.String,java.lang.String> getNativeProps()