com.facebook.react.uimanager.ReactShadowNode Java Examples

The following examples show how to use com.facebook.react.uimanager.ReactShadowNode. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FabricUIManager.java    From react-native-GPay with MIT License 6 votes vote down vote up
/**
 * @return a clone of the {@link ReactShadowNode} received by parameter. The cloned
 *     ReactShadowNode will contain a copy of all the internal data of the original node, but its
 *     props will be overridden with the {@link ReadableMap} received by parameter.
 */
@Nullable
@DoNotStrip
public ReactShadowNode cloneNodeWithNewProps(
    ReactShadowNode node, @Nullable ReadableNativeMap newProps) {
  if (DEBUG) {
    FLog.d(TAG, "cloneNodeWithNewProps \n\tnode: " + node + "\n\tprops: " + newProps);
  }
  SystraceMessage.beginSection(
    Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
    "FabricUIManager.cloneNodeWithNewProps")
    .flush();
  try {
    ReactShadowNode clone = node.mutableCopyWithNewProps(node.getInstanceHandle(),
          newProps == null ? null : new ReactStylesDiffMap(newProps));
    assertReactShadowNodeCopy(node, clone);
    return clone;
  } catch (Throwable t) {
    handleException(node, t);
    return null;
  } finally{
    Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
  }
}
 
Example #2
Source File: FabricUIManager.java    From react-native-GPay with MIT License 6 votes vote down vote up
/**
 * Updates the root view size and re-render the RN surface.
 *
 * //TODO: change synchronization to integrate with new #render loop.
 */
private synchronized void updateRootSize(int rootTag, int newWidth, int newHeight) {
  ReactShadowNode rootNode = getRootNode(rootTag);
  if (rootNode == null) {
    FLog.w(
      ReactConstants.TAG,
      "Tried to update size of non-existent tag: " + rootTag);
    return;
  }

  ReactShadowNode newRootNode = rootNode.mutableCopy(rootNode.getInstanceHandle());
  int newWidthSpec = View.MeasureSpec.makeMeasureSpec(newWidth, View.MeasureSpec.EXACTLY);
  int newHeightSpec = View.MeasureSpec.makeMeasureSpec(newHeight, View.MeasureSpec.EXACTLY);
  updateRootView(newRootNode, newWidthSpec, newHeightSpec);

  completeRoot(rootTag, newRootNode.getChildrenList());
}
 
Example #3
Source File: FabricUIManager.java    From react-native-GPay with MIT License 6 votes vote down vote up
/**
 * Appends the child {@link ReactShadowNode} to the children set of the parent {@link
 * ReactShadowNode}.
 */
@Nullable
@DoNotStrip
public void appendChild(ReactShadowNode parent, ReactShadowNode child) {
  if (DEBUG) {
    FLog.d(TAG, "appendChild \n\tparent: " + parent + "\n\tchild: " + child);
  }
  SystraceMessage.beginSection(
    Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
    "FabricUIManager.appendChild")
    .flush();
  try {
    // If the child to append was already committed (child.isSealed()),
    // then we add a mutation of it. In the future this will be performed by FabricJS / Fiber.
    //TODO: T27926878 avoid cloning shared child
    if (child.isSealed()) {
      child = child.mutableCopy(child.getInstanceHandle());
    }
    parent.addChildAt(child, parent.getChildCount());
  } catch (Throwable t) {
    handleException(parent, t);
  } finally{
    Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
  }
}
 
Example #4
Source File: FabricUIManager.java    From react-native-GPay with MIT License 6 votes vote down vote up
/**
 * @return a clone of the {@link ReactShadowNode} received by parameter. The cloned
 *     ReactShadowNode will contain a copy of all the internal data of the original node, but its
 *     props will be overridden with the {@link ReadableMap} received by parameter and its
 *     children set will be empty.
 */
@Nullable
@DoNotStrip
public ReactShadowNode cloneNodeWithNewChildrenAndProps(
    ReactShadowNode node, ReadableNativeMap newProps) {
  if (DEBUG) {
    FLog.d(TAG, "cloneNodeWithNewChildrenAndProps \n\tnode: " + node + "\n\tnewProps: " + newProps);
  }
  SystraceMessage.beginSection(
    Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
    "FabricUIManager.cloneNodeWithNewChildrenAndProps")
    .flush();
  try {
    ReactShadowNode clone =
        node.mutableCopyWithNewChildrenAndProps(node.getInstanceHandle(),
            newProps == null ? null : new ReactStylesDiffMap(newProps));
    assertReactShadowNodeCopy(node, clone);
    return clone;
  } catch (Throwable t) {
    handleException(node, t);
    return null;
  } finally{
    Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
  }
}
 
Example #5
Source File: FabricUIManager.java    From react-native-GPay with MIT License 6 votes vote down vote up
/**
 * @return a clone of the {@link ReactShadowNode} received by parameter. The cloned
 *     ReactShadowNode will contain a copy of all the internal data of the original node, but its
 *     children set will be empty.
 */
@Nullable
@DoNotStrip
public ReactShadowNode cloneNodeWithNewChildren(ReactShadowNode node) {
  if (DEBUG) {
    FLog.d(TAG, "cloneNodeWithNewChildren \n\tnode: " + node);
  }
  SystraceMessage.beginSection(
    Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
    "FabricUIManager.cloneNodeWithNewChildren")
    .flush();
  try {
    ReactShadowNode clone = node.mutableCopyWithNewChildren(node.getInstanceHandle());
    assertReactShadowNodeCopy(node, clone);
    return clone;
  } catch (Throwable t) {
    handleException(node, t);
    return null;
  } finally{
    Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
  }
}
 
Example #6
Source File: FabricUIManager.java    From react-native-GPay with MIT License 6 votes vote down vote up
/**
 * @return a clone of the {@link ReactShadowNode} received by parameter. The cloned
 *     ReactShadowNode will contain a copy of all the internal data of the original node,
 *     including its children set (note that the children nodes will not be cloned).
 */
@Nullable
@DoNotStrip
public ReactShadowNode cloneNode(ReactShadowNode node) {
  if (DEBUG) {
    FLog.d(TAG, "cloneNode \n\tnode: " + node);
  }
  SystraceMessage.beginSection(
    Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
    "FabricUIManager.cloneNode")
    .flush();
  try {
    ReactShadowNode clone = node.mutableCopy(node.getInstanceHandle());
    assertReactShadowNodeCopy(node, clone);
    return clone;
  } catch (Throwable t) {
    handleException(node, t);
    return null;
  } finally{
    Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
  }
}
 
Example #7
Source File: FabricReconciler.java    From react-native-GPay with MIT License 6 votes vote down vote up
private void enqueueUpdateProperties(ReactShadowNode newNode, ReactShadowNode prevNode) {
  int reactTag = newNode.getReactTag();
  if (DEBUG) {
    FLog.d(
      TAG,
      "manageChildren.enqueueUpdateProperties " +
        "\n\ttag: " + reactTag +
        "\n\tviewClass: " + newNode.getViewClass() +
        "\n\tinstanceHandle: " + newNode.getInstanceHandle() +
        "\n\tnewProps: " + newNode.getNewProps());
  }

  if (prevNode != null) {
    newNode.updateScreenLayout(prevNode);
  }

  if (newNode.getNewProps() != null) {
    uiViewOperationQueue.enqueueUpdateProperties(
      reactTag, newNode.getViewClass(), newNode.getNewProps());
  }

  uiViewOperationQueue.enqueueUpdateInstanceHandle(
    reactTag, newNode.getInstanceHandle());
}
 
Example #8
Source File: FabricReconcilerTest.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Test
public void testVirtualNodes() {
  ReactShadowNode parent = createNode(0);
  ReactShadowNode child1 = createVirtualNode(1);
  ReactShadowNode child2 = createVirtualNode(2);
  ReactShadowNode child3 = createVirtualNode(3);
  addChildren(parent, child1, child2, child3);

  ReactShadowNode parentCloned = createNode(0);
  ReactShadowNode child4 = createVirtualNode(4);
  addChildren(parentCloned, child1, child4, child3);

  mFabricReconciler.manageChildren(parent, parentCloned);

  List<ManageChildrenOperation> expectedOperations = new ArrayList<>();
  assertThat(mMockUIViewOperationQueue.getOperations()).isEqualTo(expectedOperations);
}
 
Example #9
Source File: FabricUIManagerTest.java    From react-native-GPay with MIT License 6 votes vote down vote up
/**
 * Tests that cloned text nodes will not share measure functions
 */
@Test
public void testTextMutableClone() {
  ReactRootView rootView =
      new ReactRootView(RuntimeEnvironment.application.getApplicationContext());
  int rootTag = mFabricUIManager.addRootView(rootView);
  ReactShadowNode text =
      mFabricUIManager.createNode(0, ReactTextViewManager.REACT_CLASS, rootTag, null, randomInstanceHandle());
  assertThat(text.isMeasureDefined()).isTrue();

  ReactShadowNode textCopy = text.mutableCopy(randomInstanceHandle());
  assertThat(textCopy.isMeasureDefined()).isTrue();

  textCopy.setStyleWidth(200);
  text.onBeforeLayout();
  text.calculateLayout();
  textCopy.onBeforeLayout();
  textCopy.calculateLayout();

  assertThat(text.getLayoutWidth()).isNotEqualTo(textCopy.getLayoutWidth());
}
 
Example #10
Source File: FabricUIManagerTest.java    From react-native-GPay with MIT License 6 votes vote down vote up
private void assertSameFields(ReactShadowNode node1, ReactShadowNode node2) {
  assertThat(node1.getReactTag()).isEqualTo(node2.getReactTag());
  assertThat(node1.getViewClass()).isEqualTo(node2.getViewClass());
  assertThat(node2.getParent()).isNull();
  assertThat(node1.getThemedContext()).isEqualTo(node2.getThemedContext());
  assertThat(node1.isVirtual()).isEqualTo(node2.isVirtual());
  assertThat(node1.getLayoutDirection()).isEqualTo(node2.getLayoutDirection());
  assertThat(node1.getLayoutHeight()).isEqualTo(node2.getLayoutHeight());
  assertThat(node1.getLayoutWidth()).isEqualTo(node2.getLayoutWidth());
  assertThat(node1.getLayoutX()).isEqualTo(node2.getLayoutX());
  assertThat(node1.getLayoutY()).isEqualTo(node2.getLayoutY());
  for (int spacingType = Spacing.LEFT; spacingType <= Spacing.ALL; spacingType++) {
    assertThat(node1.getStylePadding(spacingType)).isEqualTo(node2.getStylePadding(spacingType));
  }
  assertThat(node1.getStyleWidth()).isEqualTo(node2.getStyleWidth());
  assertThat(node1.getStyleHeight()).isEqualTo(node2.getStyleHeight());
}
 
Example #11
Source File: FabricReconcilerTest.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Test
public void testSimpleHierarchy() {
  ReactShadowNode parent = createNode(0);
  ReactShadowNode child1 = createNode(1);
  ReactShadowNode child2 = createNode(2);
  addChildren(parent, child1, child2);

  ReactShadowNode parentCloned = createNode(0);
  ReactShadowNode child3 = createNode(3);
  addChildren(parentCloned, child3, child2);

  mFabricReconciler.manageChildren(parent, parentCloned);

  List<ManageChildrenOperation> expectedOperations = new ArrayList<>();
  expectedOperations.add(
      new ManageChildrenOperation(
          0,
          new int[] {0, 1},
          new ViewAtIndex[] {new ViewAtIndex(3, 0), new ViewAtIndex(2, 1)},
          new int[] {1}));
  assertThat(mMockUIViewOperationQueue.getOperations()).isEqualTo(expectedOperations);
}
 
Example #12
Source File: FabricUIManagerTest.java    From react-native-GPay with MIT License 6 votes vote down vote up
@Test
public void testSealReactShadowNode() {
  ReactRootView rootView =
    new ReactRootView(RuntimeEnvironment.application.getApplicationContext());
  int rootTag = mFabricUIManager.addRootView(rootView);
  String viewClass = ReactViewManager.REACT_CLASS;

  ReactShadowNode container = mFabricUIManager.createNode(6, viewClass, rootTag, null, randomInstanceHandle());
  List<ReactShadowNode> childSet = mFabricUIManager.createChildSet(rootTag);
  mFabricUIManager.appendChildToSet(childSet, container);

  assertThat(container.isSealed()).isFalse();

  mFabricUIManager.completeRoot(rootTag, childSet);

  assertThat(container.isSealed()).isTrue();
}
 
Example #13
Source File: FabricUIManagerTest.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Test
public void testCloneNodeWithNewProps() {
  ReactShadowNode node = createViewNode();
  ReadableNativeMap props = null; // TODO(ayc): Figure out how to create a Native map from tests.

  ReactShadowNode clonedNode = mFabricUIManager.cloneNodeWithNewProps(node, props);
}
 
Example #14
Source File: FabricUIManager.java    From react-native-GPay with MIT License 5 votes vote down vote up
private ReactShadowNode createRootShadowNode(int rootTag, ThemedReactContext themedReactContext) {
  ReactShadowNode rootNode = new ReactShadowNodeImpl();
  I18nUtil sharedI18nUtilInstance = I18nUtil.getInstance();
  if (sharedI18nUtilInstance.isRTL(themedReactContext)) {
    rootNode.setLayoutDirection(YogaDirection.RTL);
  }
  rootNode.setViewClassName("Root");
  rootNode.setReactTag(rootTag);
  rootNode.setThemedContext(themedReactContext);
  return rootNode;
}
 
Example #15
Source File: FabricUIManager.java    From react-native-GPay with MIT License 5 votes vote down vote up
/**
 * Updates the styles of the {@link ReactShadowNode} based on the Measure specs received by
 * parameters.
 */
private void updateRootView(
    ReactShadowNode node, int widthMeasureSpec, int heightMeasureSpec) {
  int widthMode = View.MeasureSpec.getMode(widthMeasureSpec);
  int widthSize = View.MeasureSpec.getSize(widthMeasureSpec);
  switch (widthMode) {
    case EXACTLY:
      node.setStyleWidth(widthSize);
      break;
    case AT_MOST:
      node.setStyleMaxWidth(widthSize);
      break;
    case UNSPECIFIED:
      node.setStyleWidthAuto();
      break;
  }

  int heightMode = View.MeasureSpec.getMode(heightMeasureSpec);
  int heightSize = View.MeasureSpec.getSize(heightMeasureSpec);
  switch (heightMode) {
    case EXACTLY:
      node.setStyleHeight(heightSize);
      break;
    case AT_MOST:
      node.setStyleMaxHeight(heightSize);
      break;
    case UNSPECIFIED:
      node.setStyleHeightAuto();
      break;
  }
}
 
Example #16
Source File: FabricUIManager.java    From react-native-GPay with MIT License 5 votes vote down vote up
private void handleException(ReactShadowNode node, Throwable t) {
  try {
    ThemedReactContext context = node.getThemedContext();
    // TODO move exception management to JNI side, and refactor to avoid wrapping Throwable into
    // a RuntimeException
    context.handleException(new RuntimeException(t));
  } catch (Exception ex) {
    FLog.e(TAG, "Exception while executing a Fabric method", t);
    throw new RuntimeException(ex.getMessage(), t);
  }
}
 
Example #17
Source File: FabricUIManagerTest.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Test
public void testCreateNode() {
  ReactRootView rootView =
      new ReactRootView(RuntimeEnvironment.application.getApplicationContext());
  int rootTag = mFabricUIManager.addRootView(rootView);
  int reactTag = mNextReactTag++;
  String viewClass = ReactViewManager.REACT_CLASS;
  ReactShadowNode node =
      mFabricUIManager.createNode(reactTag, viewClass, rootTag, null, randomInstanceHandle());

  assertThat(reactTag).isEqualTo(node.getReactTag());
  assertThat(viewClass).isEqualTo(node.getViewClass());
  assertThat(rootTag).isEqualTo(rootTag);
}
 
Example #18
Source File: FabricUIManagerTest.java    From react-native-GPay with MIT License 5 votes vote down vote up
private int createAndRenderRootView() {
  ReactRootView rootView =
      new ReactRootView(RuntimeEnvironment.application.getApplicationContext());
  int rootTag = mFabricUIManager.addRootView(rootView);
  int reactTag = mNextReactTag++;
  String viewClass = ReactViewManager.REACT_CLASS;
  ReactShadowNode node =
      mFabricUIManager.createNode(reactTag, viewClass, rootTag, null, randomInstanceHandle());

  List<ReactShadowNode> childSet = mFabricUIManager.createChildSet(rootTag);
  mFabricUIManager.appendChildToSet(childSet, node);
  mFabricUIManager.completeRoot(rootTag, childSet);

  return rootTag;
}
 
Example #19
Source File: FabricUIManagerTest.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Test
public void testCloneNode() {
  ReactShadowNode node = createViewNode();
  ReactShadowNode child = createViewNode();
  node.addChildAt(child, 0);

  ReactShadowNode clonedNode = mFabricUIManager.cloneNode(node);

  assertThat(clonedNode).isNotSameAs(node);
  assertThat(clonedNode.getOriginalReactShadowNode()).isSameAs(node);
  assertSameFields(clonedNode, node);
  assertSameChildren(clonedNode, node);
  assertThat(clonedNode.getChildAt(0)).isEqualTo(child);
}
 
Example #20
Source File: FabricUIManagerTest.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Test
public void testDefaultSpacingCloning() {
  ReactShadowNode node = createViewNode();
  node.setDefaultPadding(Spacing.LEFT, 10);

  ReactShadowNode clonedNode = mFabricUIManager.cloneNode(node);

  node.setDefaultPadding(Spacing.LEFT, 20);
  assertThat(clonedNode.getStylePadding(Spacing.LEFT).value).isEqualTo(10f, Offset.offset(0.01f));
  assertThat(node.getStylePadding(Spacing.LEFT).value).isEqualTo(20f, Offset.offset(0.01f));
}
 
Example #21
Source File: FabricUIManagerTest.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Test
public void testCloneNodeWithNewChildren() {
  ReactShadowNode node = createViewNode();
  ReactShadowNode child = createViewNode();
  node.addChildAt(child, 0);

  ReactShadowNode clonedNode = mFabricUIManager.cloneNodeWithNewChildren(node);

  assertThat(clonedNode.getChildCount()).isZero();
  assertSameFields(clonedNode, node);
}
 
Example #22
Source File: FabricUIManagerTest.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Test
public void testCloneNodeWithNewChildrenAndProps() {
  ReactShadowNode node = createViewNode();
  ReadableNativeMap props = null;

  ReactShadowNode clonedNode = mFabricUIManager.cloneNodeWithNewChildrenAndProps(node, props);

  assertThat(clonedNode.getChildCount()).isZero();
}
 
Example #23
Source File: ARTRenderableViewManager.java    From art with MIT License 5 votes vote down vote up
@Override
public Class<? extends ReactShadowNode> getShadowNodeClass() {
  if (CLASS_GROUP.equals(mClassName)) {
    return ARTGroupShadowNode.class;
  } else if (CLASS_SHAPE.equals(mClassName)) {
    return ARTShapeShadowNode.class;
  } else if (CLASS_TEXT.equals(mClassName)) {
    return ARTTextShadowNode.class;
  } else {
    throw new IllegalStateException("Unexpected type " + mClassName);
  }
}
 
Example #24
Source File: FabricUIManagerTest.java    From react-native-GPay with MIT License 5 votes vote down vote up
/**
 * Verifies that the reconciliation phase will always set the originalNode field of every node in
 * the tree to null once completeRoot has finished to prevent memory leaks.
 */
@Test
public void testRemoveOriginalNodeReferences() {
  ReactRootView rootView =
      new ReactRootView(RuntimeEnvironment.application.getApplicationContext());
  int rootTag = mFabricUIManager.addRootView(rootView);
  String viewClass = ReactViewManager.REACT_CLASS;

  ReactShadowNode aa = mFabricUIManager.createNode(2, viewClass, rootTag, null, randomInstanceHandle());
  ReactShadowNode a = mFabricUIManager.createNode(3, viewClass, rootTag, null, randomInstanceHandle());
  mFabricUIManager.appendChild(a, aa);
  ReactShadowNode bb = mFabricUIManager.createNode(4, viewClass, rootTag, null, randomInstanceHandle());
  ReactShadowNode b = mFabricUIManager.createNode(5, viewClass, rootTag, null, randomInstanceHandle());
  mFabricUIManager.appendChild(b, bb);
  ReactShadowNode container = mFabricUIManager.createNode(6, viewClass, rootTag, null, randomInstanceHandle());
  mFabricUIManager.appendChild(container, a);
  mFabricUIManager.appendChild(container, b);
  List<ReactShadowNode> childSet = mFabricUIManager.createChildSet(rootTag);
  mFabricUIManager.appendChildToSet(childSet, container);
  mFabricUIManager.completeRoot(rootTag, childSet);

  ReactShadowNode aaClone = mFabricUIManager.cloneNodeWithNewProps(aa, null);
  ReactShadowNode aClone = mFabricUIManager.cloneNodeWithNewChildren(a);
  mFabricUIManager.appendChild(aClone, aaClone);
  ReactShadowNode containerClone = mFabricUIManager.cloneNodeWithNewChildren(container);
  mFabricUIManager.appendChild(containerClone, b);
  mFabricUIManager.appendChild(containerClone, aClone);
  List<ReactShadowNode> childSet2 = mFabricUIManager.createChildSet(rootTag);
  mFabricUIManager.appendChildToSet(childSet2, containerClone);
  mFabricUIManager.completeRoot(rootTag, childSet2);

  ReactShadowNode[] nodes =
      new ReactShadowNode[] {aa, a, bb, b, container, aaClone, aClone, containerClone};

  for (ReactShadowNode node : nodes) {
    assertThat(node.getOriginalReactShadowNode()).isNull();
  }
}
 
Example #25
Source File: FabricUIManagerTest.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Test
public void testAppendChild() {
  ReactShadowNode node = createViewNode();
  ReactShadowNode child = createViewNode();

  mFabricUIManager.appendChild(node, child);

  assertThat(node.getChildCount()).isEqualTo(1);
  assertThat(node.getChildAt(0)).isEqualTo(child);
}
 
Example #26
Source File: FabricUIManagerTest.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Test
public void testAppendChildToSet() {
  ReactShadowNode node = createViewNode();
  List<ReactShadowNode> childSet = mFabricUIManager.createChildSet(0);

  mFabricUIManager.appendChildToSet(childSet, node);

  assertThat(childSet).hasSize(1);
  assertThat(childSet).contains(node);
}
 
Example #27
Source File: FabricUIManagerTest.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Test
public void testCompleteRoot() {
  ReactRootView rootView =
      new ReactRootView(RuntimeEnvironment.application.getApplicationContext());
  int rootTag = mFabricUIManager.addRootView(rootView);
  List<ReactShadowNode> children = mFabricUIManager.createChildSet(rootTag);

  mFabricUIManager.completeRoot(rootTag, children);
}
 
Example #28
Source File: FabricUIManager.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Override
@DoNotStrip
public <T extends SizeMonitoringFrameLayout & MeasureSpecProvider> int addRootView(
    final T rootView) {

  SystraceMessage.beginSection(
    Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
    "FabricUIManager.addRootView")
    .flush();
  try {
    final int rootTag = ReactRootViewTagGenerator.getNextRootViewTag();
    ThemedReactContext themedRootContext =
        new ThemedReactContext(mReactApplicationContext, rootView.getContext());

    ReactShadowNode rootShadowNode = createRootShadowNode(rootTag, themedRootContext);

    int widthMeasureSpec = rootView.getWidthMeasureSpec();
    int heightMeasureSpec = rootView.getHeightMeasureSpec();
    updateRootView(rootShadowNode, widthMeasureSpec, heightMeasureSpec);

    rootView.setOnSizeChangedListener(
      new SizeMonitoringFrameLayout.OnSizeChangedListener() {
        @Override
        public void onSizeChanged(final int width, final int height, int oldW, int oldH) {
          updateRootSize(rootTag, width, height);
        }
      });

    mRootShadowNodeRegistry.registerNode(rootShadowNode);
    mUIViewOperationQueue.addRootView(rootTag, rootView, themedRootContext);
    return rootTag;
  } finally{
    Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
  }
}
 
Example #29
Source File: ARTRenderableViewManager.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Override
public ReactShadowNode createShadowNodeInstance() {
  if (CLASS_GROUP.equals(mClassName)) {
    return new ARTGroupShadowNode();
  } else if (CLASS_SHAPE.equals(mClassName)) {
    return new ARTShapeShadowNode();
  } else if (CLASS_TEXT.equals(mClassName)) {
    return new ARTTextShadowNode();
  } else {
    throw new IllegalStateException("Unexpected type " + mClassName);
  }
}
 
Example #30
Source File: ARTRenderableViewManager.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Override
public Class<? extends ReactShadowNode> getShadowNodeClass() {
  if (CLASS_GROUP.equals(mClassName)) {
    return ARTGroupShadowNode.class;
  } else if (CLASS_SHAPE.equals(mClassName)) {
    return ARTShapeShadowNode.class;
  } else if (CLASS_TEXT.equals(mClassName)) {
    return ARTTextShadowNode.class;
  } else {
    throw new IllegalStateException("Unexpected type " + mClassName);
  }
}