-
- All Implemented Interfaces:
-
com.facebook.react.bridge.JSIModule
,com.facebook.react.bridge.LifecycleEventListener
,com.facebook.react.bridge.PerformanceCounter
,com.facebook.react.bridge.UIManager
public class FabricUIManager implements UIManager, LifecycleEventListener
We instruct ProGuard not to strip out any fields or methods, because many of these methods are only called through the JNI from Cxx so it appears that most of this class is "unused".
-
-
Field Summary
Fields Modifier and Type Field Description public final static String
TAG
public final static boolean
IS_DEVELOPMENT_ENVIRONMENT
public final static boolean
ENABLE_FABRIC_LOGS
public DevToolsReactPerfLogger
mDevToolsReactPerfLogger
-
Constructor Summary
Constructors Constructor Description FabricUIManager(ReactApplicationContext reactContext, ViewManagerRegistry viewManagerRegistry, EventDispatcher eventDispatcher, EventBeatManager eventBeatManager)
FabricUIManager(ReactApplicationContext reactContext, ViewManagerRegistry viewManagerRegistry, EventBeatManager eventBeatManager)
-
Method Summary
Modifier and Type Method Description <T extends View> int
addRootView(T rootView, WritableMap initialProps, @Nullable() String initialUITemplate)
Registers a new root view. ReadableMap
getInspectorDataForInstance(int surfaceId, View view)
This API returns metadata associated to the React Component that rendered the Android Viewreceived as a parameter. void
preInitializeViewManagers(List<String> viewManagerNames)
Helper method to pre-initialize view managers. <T extends View> int
startSurface(T rootView, String moduleName, WritableMap initialProps, int widthMeasureSpec, int heightMeasureSpec)
Registers a new root view with width and height. void
startSurface(SurfaceHandler surfaceHandler, Context context, @Nullable() View rootView)
void
attachRootView(SurfaceHandler surfaceHandler, View rootView)
void
stopSurface(SurfaceHandler surfaceHandler)
void
onRequestEventBeat()
Method called when an event has been dispatched on the C++ side. void
stopSurface(int surfaceID)
Stop a surface from running in JS and clears up native memory usage. void
initialize()
This is called at the end of createCatalystInstance afterthe CatalystInstance has been created, in order to initialize NativeModules that require theCatalystInstance or JS modules. void
onCatalystInstanceDestroy()
Called before {CatalystInstance#onHostDestroy} int
getColor(int surfaceId, ReadableMap platformColor)
boolean
getThemeData(int surfaceId, Array<float> defaultTextInputPadding)
void
addUIManagerEventListener(UIManagerListener listener)
Register a UIManagerListener with this UIManager to receive lifecycle callbacks. void
removeUIManagerEventListener(UIManagerListener listener)
Unregister a UIManagerListener from this UIManager to stop receiving lifecyclecallbacks. void
synchronouslyUpdateViewOnUIThread(int reactTag, @NonNull() ReadableMap props)
Used by native animated module to bypass the process of updating the values through the shadowview hierarchy. void
setBinding(Binding binding)
void
updateRootLayoutSpecs(int surfaceId, int widthMeasureSpec, int heightMeasureSpec, int offsetX, int offsetY)
Updates the layout metrics of the root view based on the Measure specs received by parameters. View
resolveView(int reactTag)
Resolves a view based on its reactTag. void
receiveEvent(int reactTag, String eventName, @Nullable() WritableMap params)
This method dispatches events from RN Android code to JS. void
receiveEvent(int surfaceId, int reactTag, String eventName, @Nullable() WritableMap params)
This method dispatches events from RN Android code to JS. void
receiveEvent(int surfaceId, int reactTag, String eventName, boolean canCoalesceEvent, int customCoalesceKey, @Nullable() WritableMap params)
void
receiveEvent(int surfaceId, int reactTag, String eventName, boolean canCoalesceEvent, int customCoalesceKey, @Nullable() WritableMap params, int eventCategory)
receiveEvent API that emits an event to C++. void
onHostResume()
Called either when the host activity receives a resume event (e.g. EventDispatcher
getEventDispatcher()
void
onHostPause()
Called when host activity receives pause event (e.g. void
onHostDestroy()
Called when host activity receives destroy event (e.g. void
dispatchCommand(int reactTag, int commandId, @Nullable() ReadableArray commandArgs)
Dispatches the commandId received by parameter to the view associated with the reactTag. void
dispatchCommand(int reactTag, String commandId, @Nullable() ReadableArray commandArgs)
Dispatches the commandId received by parameter to the view associated with the reactTag. void
dispatchCommand(int surfaceId, int reactTag, int commandId, @Nullable() ReadableArray commandArgs)
void
dispatchCommand(int surfaceId, int reactTag, String commandId, @Nullable() ReadableArray commandArgs)
void
sendAccessibilityEvent(int reactTag, int eventType)
Dispatch an accessibility event to a view asynchronously. void
sendAccessibilityEventFromJS(int surfaceId, int reactTag, String eventTypeJS)
void
setJSResponder(int surfaceId, int reactTag, int initialReactTag, boolean blockNativeResponder)
Set the JS responder for the view associated with the tags received as a parameter. void
clearJSResponder()
Clears the JS Responder specified by setJSResponder. void
profileNextBatch()
String
resolveCustomDirectEventName(@Nullable() String eventName)
Resolves Direct Event name exposed to JS from the one known to the Native side. void
onAnimationStarted()
void
onAllAnimationsComplete()
Map<String, Long>
getPerformanceCounters()
-
Methods inherited from class com.facebook.react.bridge.UIManager
addRootView, dispatchCommand, dispatchCommand, getEventDispatcher, receiveEvent, receiveEvent, stopSurface, synchronouslyUpdateViewOnUIThread, updateRootLayoutSpecs
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
FabricUIManager
FabricUIManager(ReactApplicationContext reactContext, ViewManagerRegistry viewManagerRegistry, EventDispatcher eventDispatcher, EventBeatManager eventBeatManager)
-
FabricUIManager
FabricUIManager(ReactApplicationContext reactContext, ViewManagerRegistry viewManagerRegistry, EventBeatManager eventBeatManager)
-
-
Method Detail
-
addRootView
@UiThread()@Deprecated() <T extends View> int addRootView(T rootView, WritableMap initialProps, @Nullable() String initialUITemplate)
Registers a new root view. @Deprecated call startSurface instead
-
getInspectorDataForInstance
@UiThread() ReadableMap getInspectorDataForInstance(int surfaceId, View view)
This API returns metadata associated to the React Component that rendered the Android Viewreceived as a parameter.
- Parameters:
surfaceId
- that represents the surfaceId for the View received as aparameter.view
- View view that will be used to retrieve the React view hierarchy metadata.
-
preInitializeViewManagers
void preInitializeViewManagers(List<String> viewManagerNames)
Helper method to pre-initialize view managers. When using Native ViewConfigs this method willalso pre-compute the constants for a view manager. The purpose is to ensure that we don't blockfor getting the constants for view managers during initial rendering of a surface.
-
startSurface
@AnyThread() <T extends View> int startSurface(T rootView, String moduleName, WritableMap initialProps, int widthMeasureSpec, int heightMeasureSpec)
Registers a new root view with width and height.
-
startSurface
void startSurface(SurfaceHandler surfaceHandler, Context context, @Nullable() View rootView)
-
attachRootView
void attachRootView(SurfaceHandler surfaceHandler, View rootView)
-
stopSurface
void stopSurface(SurfaceHandler surfaceHandler)
-
onRequestEventBeat
void onRequestEventBeat()
Method called when an event has been dispatched on the C++ side.
-
stopSurface
@AnyThread() void stopSurface(int surfaceID)
Stop a surface from running in JS and clears up native memory usage. Assumes that the nativeView hierarchy has already been cleaned up. Fabric-only.
-
initialize
void initialize()
This is called at the end of createCatalystInstance afterthe CatalystInstance has been created, in order to initialize NativeModules that require theCatalystInstance or JS modules.
-
onCatalystInstanceDestroy
@AnyThread() void onCatalystInstanceDestroy()
Called before {CatalystInstance#onHostDestroy}
-
getColor
int getColor(int surfaceId, ReadableMap platformColor)
-
getThemeData
boolean getThemeData(int surfaceId, Array<float> defaultTextInputPadding)
- Parameters:
surfaceId
- surface IDdefaultTextInputPadding
- output parameter will contain the default themepadding used by RN Android TextInput.
-
addUIManagerEventListener
void addUIManagerEventListener(UIManagerListener listener)
Register a UIManagerListener with this UIManager to receive lifecycle callbacks.
-
removeUIManagerEventListener
void removeUIManagerEventListener(UIManagerListener listener)
Unregister a UIManagerListener from this UIManager to stop receiving lifecyclecallbacks.
-
synchronouslyUpdateViewOnUIThread
@UiThread() void synchronouslyUpdateViewOnUIThread(int reactTag, @NonNull() ReadableMap props)
Used by native animated module to bypass the process of updating the values through the shadowview hierarchy. This method will directly update native views, which means that updates forlayout-related propertied won't be handled properly. Make sure you know what you're doingbefore calling this method :)
- Parameters:
reactTag
- that identifies the view that will be updatedprops
- ReadableMap props that should be immediately updated in view
-
setBinding
void setBinding(Binding binding)
-
updateRootLayoutSpecs
@UiThread() void updateRootLayoutSpecs(int surfaceId, int widthMeasureSpec, int heightMeasureSpec, int offsetX, int offsetY)
Updates the layout metrics of the root view based on the Measure specs received by parameters.
-
resolveView
View resolveView(int reactTag)
Resolves a view based on its reactTag. Do not mutate properties on this view that are alreadymanaged by React, as there are no guarantees this changes will be preserved.
- Parameters:
reactTag
- tag
-
receiveEvent
void receiveEvent(int reactTag, String eventName, @Nullable() WritableMap params)
This method dispatches events from RN Android code to JS. The delivery of this event will notbe queued in EventDispatcher class.
- Parameters:
reactTag
- tageventName
- name of the event
-
receiveEvent
void receiveEvent(int surfaceId, int reactTag, String eventName, @Nullable() WritableMap params)
This method dispatches events from RN Android code to JS. The delivery of this event will notbe queued in EventDispatcher class.
- Parameters:
reactTag
- tageventName
- name of the event
-
receiveEvent
void receiveEvent(int surfaceId, int reactTag, String eventName, boolean canCoalesceEvent, int customCoalesceKey, @Nullable() WritableMap params)
-
receiveEvent
void receiveEvent(int surfaceId, int reactTag, String eventName, boolean canCoalesceEvent, int customCoalesceKey, @Nullable() WritableMap params, int eventCategory)
receiveEvent API that emits an event to C++. If `canCoalesceEvent` is true, that signals thatC++ may coalesce the event optionally. Otherwise, coalescing can happen in Java beforeemitting.
`customCoalesceKey` is currently unused.
-
onHostResume
void onHostResume()
Called either when the host activity receives a resume event (e.g. onResume orif the native module that implements this is initialized while the host activity is alreadyresumed. Always called for the most current activity.
-
getEventDispatcher
@NonNull() EventDispatcher getEventDispatcher()
-
onHostPause
void onHostPause()
Called when host activity receives pause event (e.g. onPause. Always calledfor the most current activity.
-
onHostDestroy
void onHostDestroy()
Called when host activity receives destroy event (e.g. onDestroy. Only calledfor the last React activity to be destroyed.
-
dispatchCommand
@Deprecated()@AnyThread() void dispatchCommand(int reactTag, int commandId, @Nullable() ReadableArray commandArgs)
Dispatches the commandId received by parameter to the view associated with the reactTag. Thecommand will be processed in the UIThread.
Receiving commands as ints is deprecated and will be removed in a future release.
Pre-Fabric, this is only called on the Native Module Thread.
- Parameters:
reactTag
- that identifies the view that will receive this commandcommandId
- command idcommandArgs
- ReadableArray parameters associated with the command
-
dispatchCommand
@Deprecated()@AnyThread() void dispatchCommand(int reactTag, String commandId, @Nullable() ReadableArray commandArgs)
Dispatches the commandId received by parameter to the view associated with the reactTag. Thecommand will be processed in the UIThread.
Pre-Fabric, this is only called on the Native Module Thread.
- Parameters:
reactTag
- that identifies the view that will receive this commandcommandId
- String command idcommandArgs
- ReadableArray parameters associated with the command
-
dispatchCommand
@Deprecated()@AnyThread() void dispatchCommand(int surfaceId, int reactTag, int commandId, @Nullable() ReadableArray commandArgs)
-
dispatchCommand
@AnyThread() void dispatchCommand(int surfaceId, int reactTag, String commandId, @Nullable() ReadableArray commandArgs)
-
sendAccessibilityEvent
@AnyThread() void sendAccessibilityEvent(int reactTag, int eventType)
Dispatch an accessibility event to a view asynchronously.
Pre-Fabric, this is only called on the Native Module Thread.
-
sendAccessibilityEventFromJS
@AnyThread() void sendAccessibilityEventFromJS(int surfaceId, int reactTag, String eventTypeJS)
-
setJSResponder
void setJSResponder(int surfaceId, int reactTag, int initialReactTag, boolean blockNativeResponder)
Set the JS responder for the view associated with the tags received as a parameter.
- Parameters:
reactTag
- React tag of the first parent of the view that is NOT virtualinitialReactTag
- React tag of the JS view that initiated the touch operationblockNativeResponder
- If native responder should be blocked or not
-
clearJSResponder
void clearJSResponder()
Clears the JS Responder specified by setJSResponder. After this method is called, allthe touch events are going to be handled by JS.
-
profileNextBatch
void profileNextBatch()
-
resolveCustomDirectEventName
@Deprecated()@Nullable() String resolveCustomDirectEventName(@Nullable() String eventName)
Resolves Direct Event name exposed to JS from the one known to the Native side.
-
onAnimationStarted
@AnyThread() void onAnimationStarted()
-
onAllAnimationsComplete
@AnyThread() void onAllAnimationsComplete()
-
getPerformanceCounters
Map<String, Long> getPerformanceCounters()
-
-
-
-