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
This commit is contained in:
parent
4622532ca4
commit
87eb779eea
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue