From 87eb779eeab79b1cefd460e1c0cc310e7e5c86aa Mon Sep 17 00:00:00 2001 From: Ahmed El-Helw Date: Fri, 1 Jul 2016 16:22:28 -0700 Subject: [PATCH] Fix commands not always going through with Nodes Summary: Previously, to fix the issue of commands happening before the Views were made and attached to the hierarchy, a check was added to see if a node had not been mounted to a View, to update its hierarchy. In reality, we need to do this irrespective, since a node could be mounted to a View, but its children may not yet be attached, for example. Note that if there is nothing to be done, this won't do extra work (i.e. applyUpdates recursively goes through the tree from the node on which we did the operation to apply updates, but if there are no updates, we stop traversing that praticular subtree). Reviewed By: sriramramani Differential Revision: D3511462 --- .../react/flat/FlatUIImplementation.java | 17 ++++------------- .../com/facebook/react/flat/StateBuilder.java | 5 ++--- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java index 6735986b7..df6cbaff2 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/FlatUIImplementation.java @@ -224,12 +224,10 @@ public class FlatUIImplementation extends UIImplementation { callback); } - private boolean ensureMountsToViewAndBackingViewIsCreated(int reactTag) { + private void ensureMountsToViewAndBackingViewIsCreated(int reactTag) { FlatShadowNode node = (FlatShadowNode) resolveShadowNode(reactTag); - boolean didUpdate = !node.mountsToView(); node.forceMountToView(); - didUpdate = didUpdate || mStateBuilder.ensureBackingViewIsCreated(node); - return didUpdate; + mStateBuilder.ensureBackingViewIsCreated(node); } @Override @@ -251,15 +249,8 @@ public class FlatUIImplementation extends UIImplementation { @Override public void dispatchViewManagerCommand(int reactTag, int commandId, ReadableArray commandArgs) { - if (ensureMountsToViewAndBackingViewIsCreated(reactTag)) { - // need to make sure any ui operations (UpdateViewGroup, for example, etc) have already - // happened before we actually dispatch the view manager command (since otherwise, the command - // may go to an empty shell parent without its children, which is against the specs). note - // that we only want to applyUpdates if the view has not yet been created so that it does - // get created (otherwise, we may end up changing the View's position when we're not supposed - // to, for example). - mStateBuilder.applyUpdates((FlatShadowNode) resolveShadowNode(reactTag)); - } + ensureMountsToViewAndBackingViewIsCreated(reactTag); + mStateBuilder.applyUpdates((FlatShadowNode) resolveShadowNode(reactTag)); super.dispatchViewManagerCommand(reactTag, commandId, commandArgs); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/flat/StateBuilder.java b/ReactAndroid/src/main/java/com/facebook/react/flat/StateBuilder.java index aa575c77b..c696c004f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/flat/StateBuilder.java +++ b/ReactAndroid/src/main/java/com/facebook/react/flat/StateBuilder.java @@ -154,16 +154,15 @@ import com.facebook.react.uimanager.events.EventDispatcher; } } - /* package */ boolean ensureBackingViewIsCreated(FlatShadowNode node) { + /* package */ void ensureBackingViewIsCreated(FlatShadowNode node) { if (node.isBackingViewCreated()) { - return false; + return; } int tag = node.getReactTag(); mOperationsQueue.enqueueCreateView(node.getThemedContext(), tag, node.getViewClass(), null); node.signalBackingViewIsCreated(); - return true; } /* package */ void dropView(FlatShadowNode node) {