@Test public void testReplaceExistingNonRootView() { UIManagerModule uiManager = getUIManagerModule(); TestMoveDeleteHierarchy hierarchy = createMoveDeleteHierarchy(uiManager); int newViewTag = 1234; uiManager.createView( newViewTag, ReactViewManager.REACT_CLASS, hierarchy.rootView, JavaOnlyMap.of("backgroundColor", Color.RED)); uiManager.replaceExistingNonRootView(hierarchy.view2, newViewTag); uiManager.onBatchComplete(); executePendingChoreographerCallbacks(); assertThat(hierarchy.nativeRootView.getChildCount()).isEqualTo(4); assertThat(hierarchy.nativeRootView.getChildAt(2)).isInstanceOf(ReactViewGroup.class); ReactViewGroup view = (ReactViewGroup) hierarchy.nativeRootView.getChildAt(2); assertThat(view.getBackgroundColor()).isEqualTo(Color.RED); }
@ReactMethod public void replaceExistingNonRootView(int oldTag, int newTag) { mUIImplementation.replaceExistingNonRootView(oldTag, newTag); }
UIManagerModule extends ReactContextBaseJavaModule implements
    OnBatchCompleteListener, LifecycleEventListener, PerformanceCounter { @ReactMethod public void replaceExistingNonRootView(int oldTag, int newTag) { mUIImplementation.replaceExistingNonRootView(oldTag, newTag); } }
UIManagerModule extends ReactContextBaseJavaModule implements
    OnBatchCompleteListener, LifecycleEventListener, PerformanceCounter { @ReactMethod public void replaceExistingNonRootView(int oldTag, int newTag) { mUIImplementation.replaceExistingNonRootView(oldTag, newTag); } UIManagerModule(
      ReactApplicationContext reactContext,
      List<ViewManager> viewManagerList,
      UIImplementationProvider uiImplementationProvider); }
UIManagerModule extends ReactContextBaseJavaModule implements
    OnBatchCompleteListener, LifecycleEventListener, PerformanceCounter { @ReactMethod public void replaceExistingNonRootView(int oldTag, int newTag) { mUIImplementation.replaceExistingNonRootView(oldTag, newTag); } UIManagerModule(
      ReactApplicationContext reactContext,
      List<ViewManager> viewManagerList,
      UIImplementationProvider uiImplementationProvider); UIImplementation getUIImplementation(); @Override String getName(); @Override Map<String, Object> getConstants(); @Override void initialize(); @Override void onHostResume(); @Override void onHostPause(); @Override void onHostDestroy(); @Override void onCatalystInstanceDestroy(); Map<String,Double> getPerformanceCounters(); int addMeasuredRootView(final SizeMonitoringFrameLayout rootView); @ReactMethod void removeRootView(int rootViewTag); void updateNodeSize(int nodeViewTag, int newWidth, int newHeight); @ReactMethod void createView(int tag, String className, int rootViewTag, ReadableMap props); @ReactMethod void updateView(int tag, String className, ReadableMap props); @ReactMethod void manageChildren(
      int viewTag,
      @Nullable ReadableArray moveFrom,
      @Nullable ReadableArray moveTo,
      @Nullable ReadableArray addChildTags,
      @Nullable ReadableArray addAtIndices,
      @Nullable ReadableArray removeFrom); @ReactMethod void setChildren(
    int viewTag,
    ReadableArray childrenTags); @ReactMethod void replaceExistingNonRootView(int oldTag, int newTag); @ReactMethod void removeSubviewsFromContainerWithID(int containerTag); @ReactMethod void measure(int reactTag, Callback callback); @ReactMethod void measureInWindow(int reactTag, Callback callback); @ReactMethod void measureLayout(
      int tag,
      int ancestorTag,
      Callback errorCallback,
      Callback successCallback); @ReactMethod void measureLayoutRelativeToParent(
      int tag,
      Callback errorCallback,
      Callback successCallback); @ReactMethod void findSubviewIn(
      final int reactTag,
      final ReadableArray point,
      final Callback callback); void registerAnimation(Animation animation); void addAnimation(int reactTag, int animationID, Callback onSuccess); void removeAnimation(int reactTag, int animationID); @ReactMethod void setJSResponder(int reactTag, boolean blockNativeResponder); @ReactMethod void clearJSResponder(); @ReactMethod void dispatchViewManagerCommand(int reactTag, int commandId, ReadableArray commandArgs); @ReactMethod void showPopupMenu(int reactTag, ReadableArray items, Callback error, Callback success); @ReactMethod void setLayoutAnimationEnabledExperimental(boolean enabled); @ReactMethod void configureNextLayoutAnimation(
      ReadableMap config,
      Callback success,
      Callback error); @Override void onBatchComplete(); void setViewHierarchyUpdateDebugListener(
      @Nullable NotThreadSafeViewHierarchyUpdateDebugListener listener); EventDispatcher getEventDispatcher(); @ReactMethod void sendAccessibilityEvent(int tag, int eventType); void addUIBlock(UIBlock block); int resolveRootTagFromReactTag(int reactTag); }
UIManagerModule extends ReactContextBaseJavaModule implements
    OnBatchCompleteListener, LifecycleEventListener, PerformanceCounter { @ReactMethod public void replaceExistingNonRootView(int oldTag, int newTag) { mUIImplementation.replaceExistingNonRootView(oldTag, newTag); } UIManagerModule(
      ReactApplicationContext reactContext,
      List<ViewManager> viewManagerList,
      UIImplementationProvider uiImplementationProvider); UIImplementation getUIImplementation(); @Override String getName(); @Override Map<String, Object> getConstants(); @Override void initialize(); @Override void onHostResume(); @Override void onHostPause(); @Override void onHostDestroy(); @Override void onCatalystInstanceDestroy(); Map<String,Double> getPerformanceCounters(); int addMeasuredRootView(final SizeMonitoringFrameLayout rootView); @ReactMethod void removeRootView(int rootViewTag); void updateNodeSize(int nodeViewTag, int newWidth, int newHeight); @ReactMethod void createView(int tag, String className, int rootViewTag, ReadableMap props); @ReactMethod void updateView(int tag, String className, ReadableMap props); @ReactMethod void manageChildren(
      int viewTag,
      @Nullable ReadableArray moveFrom,
      @Nullable ReadableArray moveTo,
      @Nullable ReadableArray addChildTags,
      @Nullable ReadableArray addAtIndices,
      @Nullable ReadableArray removeFrom); @ReactMethod void setChildren(
    int viewTag,
    ReadableArray childrenTags); @ReactMethod void replaceExistingNonRootView(int oldTag, int newTag); @ReactMethod void removeSubviewsFromContainerWithID(int containerTag); @ReactMethod void measure(int reactTag, Callback callback); @ReactMethod void measureInWindow(int reactTag, Callback callback); @ReactMethod void measureLayout(
      int tag,
      int ancestorTag,
      Callback errorCallback,
      Callback successCallback); @ReactMethod void measureLayoutRelativeToParent(
      int tag,
      Callback errorCallback,
      Callback successCallback); @ReactMethod void findSubviewIn(
      final int reactTag,
      final ReadableArray point,
      final Callback callback); void registerAnimation(Animation animation); void addAnimation(int reactTag, int animationID, Callback onSuccess); void removeAnimation(int reactTag, int animationID); @ReactMethod void setJSResponder(int reactTag, boolean blockNativeResponder); @ReactMethod void clearJSResponder(); @ReactMethod void dispatchViewManagerCommand(int reactTag, int commandId, ReadableArray commandArgs); @ReactMethod void showPopupMenu(int reactTag, ReadableArray items, Callback error, Callback success); @ReactMethod void setLayoutAnimationEnabledExperimental(boolean enabled); @ReactMethod void configureNextLayoutAnimation(
      ReadableMap config,
      Callback success,
      Callback error); @Override void onBatchComplete(); void setViewHierarchyUpdateDebugListener(
      @Nullable NotThreadSafeViewHierarchyUpdateDebugListener listener); EventDispatcher getEventDispatcher(); @ReactMethod void sendAccessibilityEvent(int tag, int eventType); void addUIBlock(UIBlock block); int resolveRootTagFromReactTag(int reactTag);  }