com.facebook.react.uimanager.ReactShadowNode#mutableCopyWithNewChildren ( )源码实例Demo

下面列出了com.facebook.react.uimanager.ReactShadowNode#mutableCopyWithNewChildren ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: react-native-GPay   文件: FabricUIManager.java
/**
 * @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);
  }
}
 
源代码2 项目: react-native-GPay   文件: FabricUIManager.java
private ReactShadowNode calculateDiffingAndCreateNewRootNode(
    ReactShadowNode currentRootShadowNode, List<ReactShadowNode> newChildList) {
  SystraceMessage.beginSection(
    Systrace.TRACE_TAG_REACT_JAVA_BRIDGE,
    "FabricUIManager.calculateDiffingAndCreateNewRootNode")
    .flush();
  try {
    ReactShadowNode newRootShadowNode = currentRootShadowNode.mutableCopyWithNewChildren(currentRootShadowNode.getInstanceHandle());
    for (ReactShadowNode child : newChildList) {
      appendChild(newRootShadowNode, child);
    }

    if (DEBUG) {
      FLog.d(
        TAG,
        "ReactShadowNodeHierarchy before calculateLayout: " + newRootShadowNode.getHierarchyInfo());
    }

    notifyOnBeforeLayoutRecursive(newRootShadowNode);

    calculateLayout(newRootShadowNode);

    if (DEBUG) {
      FLog.d(
        TAG,
        "ReactShadowNodeHierarchy after calculateLayout: " + newRootShadowNode.getHierarchyInfo());
    }

    mFabricReconciler.manageChildren(currentRootShadowNode, newRootShadowNode);
    return newRootShadowNode;
  } finally{
    Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
  }
}