-
public class UIImplementation
A class that is used to receive React commands from JS and translate them into a shadow node hierarchy that is then mapped to a native view hierarchy.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interface
UIImplementation.LayoutUpdateListener
Interface definition for a callback to be invoked when the layout has been updated
-
Constructor Summary
Constructors Constructor Description UIImplementation(ReactApplicationContext reactContext, ViewManagerResolver viewManagerResolver, EventDispatcher eventDispatcher, int minTimeLeftInFrameForNonBatchedOperationMs)
UIImplementation(ReactApplicationContext reactContext, List<ViewManager> viewManagers, EventDispatcher eventDispatcher, int minTimeLeftInFrameForNonBatchedOperationMs)
-
Method Summary
Modifier and Type Method Description final ReactShadowNode
resolveShadowNode(int reactTag)
void
updateRootView(int tag, int widthMeasureSpec, int heightMeasureSpec)
Updates the styles of the ReactShadowNode based on the Measure specs received byparameters. void
updateRootView(ReactShadowNode rootCSSNode, int widthMeasureSpec, int heightMeasureSpec)
Updates the styles of the ReactShadowNode based on the Measure specs received byparameters. <T extends View> void
registerRootView(T rootView, int tag, ThemedReactContext context)
Registers a root node with a given tag, size and ThemedReactContext and adds it to a noderegistry. void
removeRootView(int rootViewTag)
Unregisters a root node with a given tag. void
removeRootShadowNode(int rootViewTag)
Unregisters a root node with a given tag from the shadow node registry void
updateNodeSize(int nodeViewTag, int newWidth, int newHeight)
Invoked when native view that corresponds to a root node, or acts as a root view (ie. void
setViewLocalData(int tag, Object data)
void
profileNextBatch()
Map<String, Long>
getProfiledBatchPerfCounters()
void
createView(int tag, String className, int rootViewTag, ReadableMap props)
Invoked by React to create a new node with a given tag, class name and properties. void
updateView(int tag, String className, ReadableMap props)
Invoked by React to create a new node with a given tag has its properties changed. void
synchronouslyUpdateViewOnUIThread(int tag, ReactStylesDiffMap props)
Used by native animated module to bypass the process of updating the values through the shadowview hierarchy. void
manageChildren(int viewTag, @Nullable() ReadableArray moveFrom, @Nullable() ReadableArray moveTo, @Nullable() ReadableArray addChildTags, @Nullable() ReadableArray addAtIndices, @Nullable() ReadableArray removeFrom)
Invoked when there is a mutation in a node tree. void
setChildren(int viewTag, ReadableArray childrenTags)
An optimized version of manageChildren that is used for initial setting of child views. void
replaceExistingNonRootView(int oldTag, int newTag)
Replaces the View specified by oldTag with the View specified by newTag within oldTag's parent. void
removeSubviewsFromContainerWithID(int containerTag)
Method which takes a container tag and then releases all subviews for that container uponreceipt. void
findSubviewIn(int reactTag, float targetX, float targetY, Callback callback)
Find the touch target child native view in the supplied root view hierarchy, given a reacttarget location. void
viewIsDescendantOf(int reactTag, int ancestorReactTag, Callback callback)
Check if the first shadow node is the descendant of the second shadow node void
measure(int reactTag, Callback callback)
Determines the location on screen, width, and height of the given view relative to the rootview and returns the values via an async callback. void
measureInWindow(int reactTag, Callback callback)
Determines the location on screen, width, and height of the given view relative to the devicescreen and returns the values via an async callback. void
measureLayout(int tag, int ancestorTag, Callback errorCallback, Callback successCallback)
Measures the view specified by tag relative to the given ancestorTag. void
measureLayoutRelativeToParent(int tag, Callback errorCallback, Callback successCallback)
Like measure and measureLayout but measures relative to the immediate parent. void
dispatchViewUpdates(int batchId)
Invoked at the end of the transaction to commit any updates to the node hierarchy. void
setLayoutAnimationEnabledExperimental(boolean enabled)
LayoutAnimation API on Android is currently experimental. void
configureNextLayoutAnimation(ReadableMap config, Callback success)
Configure an animation to be used for the native layout changes, and native views creation. void
setJSResponder(int reactTag, boolean blockNativeResponder)
void
clearJSResponder()
void
dispatchViewManagerCommand(int reactTag, int commandId, @Nullable() ReadableArray commandArgs)
void
dispatchViewManagerCommand(int reactTag, String commandId, @Nullable() ReadableArray commandArgs)
void
showPopupMenu(int reactTag, ReadableArray items, Callback error, Callback success)
Show a PopupMenu. void
dismissPopupMenu()
void
sendAccessibilityEvent(int tag, int eventType)
void
onHostResume()
void
onHostPause()
void
onHostDestroy()
void
onCatalystInstanceDestroyed()
void
setViewHierarchyUpdateDebugListener(@Nullable() NotThreadSafeViewHierarchyUpdateDebugListener listener)
void
addUIBlock(UIBlock block)
void
prependUIBlock(UIBlock block)
int
resolveRootTagFromReactTag(int reactTag)
void
setLayoutUpdateListener(UIImplementation.LayoutUpdateListener listener)
void
removeLayoutUpdateListener()
-
-
Constructor Detail
-
UIImplementation
UIImplementation(ReactApplicationContext reactContext, ViewManagerResolver viewManagerResolver, EventDispatcher eventDispatcher, int minTimeLeftInFrameForNonBatchedOperationMs)
-
UIImplementation
UIImplementation(ReactApplicationContext reactContext, List<ViewManager> viewManagers, EventDispatcher eventDispatcher, int minTimeLeftInFrameForNonBatchedOperationMs)
-
-
Method Detail
-
resolveShadowNode
final ReactShadowNode resolveShadowNode(int reactTag)
-
updateRootView
void updateRootView(int tag, int widthMeasureSpec, int heightMeasureSpec)
Updates the styles of the ReactShadowNode based on the Measure specs received byparameters.
-
updateRootView
void updateRootView(ReactShadowNode rootCSSNode, int widthMeasureSpec, int heightMeasureSpec)
Updates the styles of the ReactShadowNode based on the Measure specs received byparameters.
-
registerRootView
<T extends View> void registerRootView(T rootView, int tag, ThemedReactContext context)
Registers a root node with a given tag, size and ThemedReactContext and adds it to a noderegistry.
-
removeRootView
void removeRootView(int rootViewTag)
Unregisters a root node with a given tag.
-
removeRootShadowNode
void removeRootShadowNode(int rootViewTag)
Unregisters a root node with a given tag from the shadow node registry
-
updateNodeSize
void updateNodeSize(int nodeViewTag, int newWidth, int newHeight)
Invoked when native view that corresponds to a root node, or acts as a root view (ie. Modals)has its size changed.
-
setViewLocalData
void setViewLocalData(int tag, Object data)
-
profileNextBatch
void profileNextBatch()
-
getProfiledBatchPerfCounters
Map<String, Long> getProfiledBatchPerfCounters()
-
createView
void createView(int tag, String className, int rootViewTag, ReadableMap props)
Invoked by React to create a new node with a given tag, class name and properties.
-
updateView
void updateView(int tag, String className, ReadableMap props)
Invoked by React to create a new node with a given tag has its properties changed.
-
synchronouslyUpdateViewOnUIThread
void synchronouslyUpdateViewOnUIThread(int tag, ReactStylesDiffMap 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 :)
-
manageChildren
void manageChildren(int viewTag, @Nullable() ReadableArray moveFrom, @Nullable() ReadableArray moveTo, @Nullable() ReadableArray addChildTags, @Nullable() ReadableArray addAtIndices, @Nullable() ReadableArray removeFrom)
Invoked when there is a mutation in a node tree.
-
setChildren
void setChildren(int viewTag, ReadableArray childrenTags)
An optimized version of manageChildren that is used for initial setting of child views. Thechildren are assumed to be in index order
- Parameters:
viewTag
- tag of the parentchildrenTags
- tags of the children
-
replaceExistingNonRootView
void replaceExistingNonRootView(int oldTag, int newTag)
Replaces the View specified by oldTag with the View specified by newTag within oldTag's parent.
-
removeSubviewsFromContainerWithID
void removeSubviewsFromContainerWithID(int containerTag)
Method which takes a container tag and then releases all subviews for that container uponreceipt. TODO: The method name is incorrect and will be renamed, #6033872
- Parameters:
containerTag
- the tag of the container for which the subviews must be removed
-
findSubviewIn
void findSubviewIn(int reactTag, float targetX, float targetY, Callback callback)
Find the touch target child native view in the supplied root view hierarchy, given a reacttarget location.
This method is currently used only by Element Inspector DevTool.
- Parameters:
reactTag
- the tag of the root view to traversetargetX
- target X locationtargetY
- target Y locationcallback
- will be called if with the identified child view react ID, and measurementinfo.
-
viewIsDescendantOf
@Deprecated() void viewIsDescendantOf(int reactTag, int ancestorReactTag, Callback callback)
Check if the first shadow node is the descendant of the second shadow node
-
measure
void measure(int reactTag, Callback callback)
Determines the location on screen, width, and height of the given view relative to the rootview and returns the values via an async callback.
-
measureInWindow
void measureInWindow(int reactTag, Callback callback)
Determines the location on screen, width, and height of the given view relative to the devicescreen and returns the values via an async callback. This is the absolute position includingthings like the status bar
-
measureLayout
void measureLayout(int tag, int ancestorTag, Callback errorCallback, Callback successCallback)
Measures the view specified by tag relative to the given ancestorTag. This means that thereturned x, y are relative to the origin x, y of the ancestor view. Results are stored in thegiven outputBuffer. We allow ancestor view and measured view to be the same, in which case theposition always will be (0, 0) and method will only measure the view dimensions.
-
measureLayoutRelativeToParent
void measureLayoutRelativeToParent(int tag, Callback errorCallback, Callback successCallback)
Like measure and measureLayout but measures relative to the immediate parent.
-
dispatchViewUpdates
void dispatchViewUpdates(int batchId)
Invoked at the end of the transaction to commit any updates to the node hierarchy.
-
setLayoutAnimationEnabledExperimental
void setLayoutAnimationEnabledExperimental(boolean enabled)
LayoutAnimation API on Android is currently experimental. Therefore, it needs to be enabledexplicitly in order to avoid regression in existing application written for iOS using this API.
Warning : This method will be removed in future version of React Native, and layoutanimation will be enabled by default, so always check for its existence before invoking it.
TODO(9139831) : remove this method once layout animation is fully stable.
- Parameters:
enabled
- whether layout animation is enabled or not
-
configureNextLayoutAnimation
void configureNextLayoutAnimation(ReadableMap config, Callback success)
Configure an animation to be used for the native layout changes, and native views creation. Theanimation will only apply during the current batch operations.
TODO(7728153) : animating view deletion is currently not supported. TODO(7613721) :callbacks are not supported, this feature will likely be killed.
- Parameters:
config
- the configuration of the animation for view addition/removal/update.success
- will be called when the animation completes, or when the animation getinterrupted.
-
setJSResponder
void setJSResponder(int reactTag, boolean blockNativeResponder)
-
clearJSResponder
void clearJSResponder()
-
dispatchViewManagerCommand
@Deprecated() void dispatchViewManagerCommand(int reactTag, int commandId, @Nullable() ReadableArray commandArgs)
-
dispatchViewManagerCommand
void dispatchViewManagerCommand(int reactTag, String commandId, @Nullable() ReadableArray commandArgs)
-
showPopupMenu
void showPopupMenu(int reactTag, ReadableArray items, Callback error, Callback success)
Show a PopupMenu.
- Parameters:
reactTag
- the tag of the anchor view (the PopupMenu is displayed next to this view); thisneeds to be the tag of a native view (shadow views can not be anchors)items
- the menu items as an array of stringserror
- will be called if there is an error displaying the menusuccess
- will be called with the position of the selected item as the first argument, orno arguments if the menu is dismissed
-
dismissPopupMenu
void dismissPopupMenu()
-
sendAccessibilityEvent
void sendAccessibilityEvent(int tag, int eventType)
-
onHostResume
void onHostResume()
-
onHostPause
void onHostPause()
-
onHostDestroy
void onHostDestroy()
-
onCatalystInstanceDestroyed
void onCatalystInstanceDestroyed()
-
setViewHierarchyUpdateDebugListener
void setViewHierarchyUpdateDebugListener(@Nullable() NotThreadSafeViewHierarchyUpdateDebugListener listener)
-
addUIBlock
void addUIBlock(UIBlock block)
-
prependUIBlock
void prependUIBlock(UIBlock block)
-
resolveRootTagFromReactTag
int resolveRootTagFromReactTag(int reactTag)
-
setLayoutUpdateListener
void setLayoutUpdateListener(UIImplementation.LayoutUpdateListener listener)
-
removeLayoutUpdateListener
void removeLayoutUpdateListener()
-
-
-
-