Package 

Class NativeViewHierarchyManager


  • @NotThreadSafe() 
    public class NativeViewHierarchyManager
    
                        

    Delegate of UIManagerModule that owns the native view hierarchy and mapping between native view names used in JS and corresponding instances of ViewManager. The communicates with this class by it's public interface methods:

    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 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 for each root view added to the manager (see addRootView).

    TODO(5483031): Only dispatch updates when shadow views have changed

    • Method Detail

      • updateLayout

         synchronized void updateLayout(int parentTag, int tag, int x, int y, int width, int height)
      • manageChildren

         synchronized void manageChildren(int tag, @Nullable() Array<int> indicesToRemove, @Nullable() Array<ViewAtIndex> viewsToAdd, @Nullable() Array<int> tagsToDelete)
        Parameters:
        tag - react tag of the node we want to manage
        indicesToRemove - ordered (asc) list of indicies at which view should be removed
        viewsToAdd - ordered (asc based on mIndex property) list of tag-index pairs that representa view which should be added at the specified index
        tagsToDelete - list of tags corresponding to views that should be removed
      • setChildren

         synchronized void setChildren(int tag, ReadableArray childrenTags)

        Simplified version of manageChildren that only deals with adding children views

      • addRootView

         synchronized void addRootView(int tag, View view)

        See addRootView.

      • measure

         synchronized void measure(int tag, Array<int> outputBuffer)

        Returns true on success, false on failure. If successful, after calling, output buffer will be {x, y, width, height}.

      • measureInWindow

         synchronized void measureInWindow(int tag, Array<int> outputBuffer)

        Returns the coordinates of a view relative to the window (not just the RootView which is whatmeasure will return)

        Parameters:
        tag - - the tag for the view
        outputBuffer - - output buffer that contains [x,y,width,height] of the view in coordinatesrelative to the device window
      • findTargetTagForTouch

         synchronized int findTargetTagForTouch(int reactTag, float touchX, float touchY)
      • setJSResponder

         synchronized void setJSResponder(int reactTag, int initialReactTag, boolean blockNativeResponder)
      • showPopupMenu

         synchronized void showPopupMenu(int reactTag, ReadableArray items, Callback success, Callback error)

        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 strings
        success - will be called with the position of the selected item as the first argument, orno arguments if the menu is dismissed