UIManagerModule

Native module to allow JS to create and update native Views.

== Transactional Requirement ==

A requirement of this class is to make sure that transactional UI updates occur all at once, meaning that no intermediate state is ever rendered to the screen. For example, if a JS application update changes the background of View A to blue and the width of View B to 100, both need to appear at once. Practically, this means that all UI update code related to a single transaction must be executed as a single code block on the UI thread. Executing as multiple code blocks could allow the platform UI system to interrupt and render a partial UI state.

To facilitate this, this module enqueues operations that are then applied to native view hierarchy through NativeViewHierarchyManager at the end of each transaction.

== CSSNodes ==

In order to allow layout and measurement to occur on a non-UI thread, this module also operates on intermediate CSSNodeDEPRECATED objects that correspond to a native view. These CSSNodeDEPRECATED are able to calculate layout according to their styling rules, and then the resulting x/y/width/height of that layout is scheduled as an operation that will be applied to native view hierarchy at the end of current batch. TODO(5241856): Investigate memory usage of creating many small objects in UIManageModule and consider implementing a pool TODO(5483063): Don't dispatch the view hierarchy at the end of a batch if no UI changes occurred

Constructors

Link copied to clipboard
constructor(reactContext: ReactApplicationContext, viewManagerResolver: ViewManagerResolver, minTimeLeftInFrameForNonBatchedOperationMs: Int)
constructor(reactContext: ReactApplicationContext, viewManagersList: List<ViewManager>, minTimeLeftInFrameForNonBatchedOperationMs: Int)

Types

Link copied to clipboard
Resolves a name coming from native side to a name of the event that is exposed to JS.

Properties

Link copied to clipboard
val METHOD_TYPE_ASYNC: String = "async"
Link copied to clipboard
val METHOD_TYPE_PROMISE: String = "promise"
Link copied to clipboard
val METHOD_TYPE_SYNC: String = "sync"
Link copied to clipboard
val NAME: String = "UIManager"
Link copied to clipboard
val TAG: String

Functions

Link copied to clipboard
open fun <T : View?> addRootView(rootView: T): Int

open fun <T : View?> addRootView(rootView: T, initialProps: WritableMap): Int
Registers a new root view.
Link copied to clipboard
open fun addUIBlock(block: UIBlock)
Schedule a block to be executed on the UI thread.
Link copied to clipboard
Register a UIManagerListener with this UIManager to receive lifecycle callbacks.
Link copied to clipboard
Link copied to clipboard
Return true if you intend to override some other native module that was registered e.g.
Link copied to clipboard
open fun clearJSResponder()
Link copied to clipboard
open fun configureNextLayoutAnimation(config: ReadableMap, success: Callback, error: Callback)
Configure an animation to be used for the native layout changes, and native views creation.
Link copied to clipboard
open fun createConstants(viewManagers: List<ViewManager>, @Nullable customBubblingEvents: Map<String, Any>, @Nullable customDirectEvents: Map<String, Any>): Map<String, Any>
Link copied to clipboard
open fun createView(tag: Int, className: String, rootViewTag: Int, props: ReadableMap)
Link copied to clipboard
open fun dispatchCommand(reactTag: Int, commandId: Int, @Nullable commandArgs: ReadableArray)
Deprecated, use dispatchCommand instead.
open fun dispatchCommand(reactTag: Int, commandId: String, @Nullable commandArgs: ReadableArray)
Dispatches the commandId received by parameter to the view associated with the reactTag.
Link copied to clipboard
open fun dispatchViewManagerCommand(reactTag: Int, commandId: Dynamic, @Nullable commandArgs: ReadableArray)
Link copied to clipboard
open fun findSubviewIn(reactTag: Int, point: ReadableArray, callback: Callback)
Find the touch target child native view in the supplied root view hierarchy, given a react target location.
Link copied to clipboard
open fun getConstants(): Map<String, Any>
Link copied to clipboard
open fun getConstantsForViewManager(viewManager: ViewManager, customDirectEvents: Map<String, Any>): WritableMap
Link copied to clipboard
Link copied to clipboard
Resolves Direct Event name exposed to JS from the one known to the Native side.
Link copied to clipboard
Link copied to clipboard
open fun getName(): String
Link copied to clipboard
Link copied to clipboard
This method gives an access to the UIImplementation object that can be used to execute operations on the view hierarchy.
Link copied to clipboard
This method is intended to reuse the ViewManagerRegistry with FabricUIManager.
Link copied to clipboard
open fun initialize()
This method is called after ReactApplicationContext has been created.
Link copied to clipboard
open fun invalidate()
The CatalystInstance is going away with Venice.
Link copied to clipboard
open fun invalidateNodeLayout(tag: Int)
Dirties the node associated with the given react tag
Link copied to clipboard
open fun manageChildren(viewTag: Int, @Nullable moveFrom: ReadableArray, @Nullable moveTo: ReadableArray, @Nullable addChildTags: ReadableArray, @Nullable addAtIndices: ReadableArray, @Nullable removeFrom: ReadableArray)
Interface for adding/removing/moving views within a parent view from JS.
Link copied to clipboard
open fun markActiveTouchForTag(surfaceId: Int, reactTag: Int)
Mark a view as currently active for a touch event.
Link copied to clipboard
open fun measure(reactTag: Int, callback: Callback)
Determines the location on screen, width, and height of the given view and returns the values via an async callback.
Link copied to clipboard
open fun measureInWindow(reactTag: Int, callback: Callback)
Determines the location on screen, width, and height of the given view relative to the device screen and returns the values via an async callback.
Link copied to clipboard
open fun measureLayout(tag: Int, ancestorTag: Int, errorCallback: Callback, successCallback: Callback)
Measures the view specified by tag relative to the given ancestorTag.
Link copied to clipboard
open fun onBatchComplete()
To implement the transactional requirement mentioned in the class javadoc, we only commit UI changes to the actual view hierarchy once a batch of JS->Java calls have been completed.
Link copied to clipboard
Allow NativeModule to clean up.
Link copied to clipboard
open fun onHostDestroy()
Called when host activity receives destroy event (e.g.
Link copied to clipboard
open fun onHostPause()
Called when host activity receives pause event (e.g.
Link copied to clipboard
open fun onHostResume()
Called either when the host activity receives a resume event (e.g.
Link copied to clipboard
open fun prependUIBlock(block: UIBlock)
Schedule a block to be executed on the UI thread.
Link copied to clipboard
open fun profileNextBatch()
Link copied to clipboard
open fun receiveEvent(reactTag: Int, eventName: String, @Nullable event: WritableMap)
open fun receiveEvent(surfaceId: Int, reactTag: Int, eventName: String, @Nullable event: WritableMap)
This method dispatches events from RN Android code to JS.
Link copied to clipboard
open fun removeRootView(rootViewTag: Int)
Unregisters a new root view.
Link copied to clipboard
Unregister a UIManagerListener from this UIManager to stop receiving lifecycle callbacks.
Link copied to clipboard
Link copied to clipboard
Resolves Direct Event name exposed to JS from the one known to the Native side.
Link copied to clipboard
open fun resolveRootTagFromReactTag(reactTag: Int): Int
Given a reactTag from a component, find its root node tag, if possible.
Link copied to clipboard
open fun resolveView(tag: Int): View
Resolves a view based on its reactTag.
Link copied to clipboard
open fun sendAccessibilityEvent(tag: Int, eventType: Int)
Dispatch an accessibility event to a view asynchronously.
Link copied to clipboard
open fun setChildren(viewTag: Int, childrenTags: ReadableArray)
Interface for fast tracking the initial adding of views.
Link copied to clipboard
open fun setJSResponder(reactTag: Int, blockNativeResponder: Boolean)
Link copied to clipboard
LayoutAnimation API on Android is currently experimental.
Link copied to clipboard
open fun setViewHierarchyUpdateDebugListener(@Nullable listener: NotThreadSafeViewHierarchyUpdateDebugListener)
Link copied to clipboard
open fun setViewLocalData(tag: Int, data: Any)
Sets local data for a shadow node corresponded with given tag.
Link copied to clipboard
open fun <T : View?> startSurface(rootView: T, moduleName: String, initialProps: WritableMap, widthMeasureSpec: Int, heightMeasureSpec: Int): Int
Registers a new root view with width and height.
Link copied to clipboard
open fun stopSurface(surfaceId: Int)
Stop a surface from running in JS and clears up native memory usage.
Link copied to clipboard
open fun sweepActiveTouchForTag(surfaceId: Int, reactTag: Int)
Sweep a view as currently not active for a touch event.
Link copied to clipboard
Used by native animated module to bypass the process of updating the values through the shadow view hierarchy.
Link copied to clipboard
open fun updateInsetsPadding(nodeViewTag: Int, top: Int, left: Int, bottom: Int, right: Int)
Link copied to clipboard
open fun updateNodeSize(nodeViewTag: Int, newWidth: Int, newHeight: Int)
Link copied to clipboard
open fun updateRootLayoutSpecs(rootViewTag: Int, widthMeasureSpec: Int, heightMeasureSpec: Int, offsetX: Int, offsetY: Int)
Updates the styles of the ReactShadowNode based on the Measure specs received by parameters.
Link copied to clipboard
open fun updateView(tag: Int, className: String, props: ReadableMap)
Link copied to clipboard
open fun viewIsDescendantOf(reactTag: Int, ancestorReactTag: Int, callback: Callback)
Check if the first shadow node is the descendant of the second shadow node