Start creating views before end of batch for nodes

Summary:
Depends on D3120798
Depends on D3120631

Enables D3120631 for nodes. This implementation seems to work but let me know if I'm doing something really stupid.

Reviewed By: ahmedre

Differential Revision: D3120814
This commit is contained in:
Andy Street 2016-06-30 04:12:52 -07:00 committed by Ahmed El-Helw
parent f8d623ca3a
commit ace1b4d78e
2 changed files with 15 additions and 39 deletions

View File

@ -464,7 +464,6 @@ public class FlatUIImplementation extends UIImplementation {
@Override
protected void updateViewHierarchy(EventDispatcher eventDispatcher) {
mStateBuilder.beforeUpdateViewHierarchy();
super.updateViewHierarchy(eventDispatcher);
mStateBuilder.afterUpdateViewHierarchy(eventDispatcher);
}

View File

@ -45,8 +45,6 @@ import com.facebook.react.uimanager.events.EventDispatcher;
private final ArrayList<FlatShadowNode> mViewsToDetachAllChildrenFrom = new ArrayList<>();
private final ArrayList<FlatShadowNode> mViewsToDetach = new ArrayList<>();
private final ArrayList<FlatShadowNode> mViewsToDrop = new ArrayList<>();
private final ArrayList<FlatShadowNode> mViewsToUpdate = new ArrayList<>();
private final ArrayList<ReactStylesDiffMap> mStylesToUpdate = new ArrayList<>();
private final ArrayList<OnLayoutEvent> mOnLayoutEvents = new ArrayList<>();
private final ArrayList<FlatUIViewOperationQueue.UpdateViewBounds> mUpdateViewBoundsOperations =
new ArrayList<>();
@ -61,10 +59,6 @@ import com.facebook.react.uimanager.events.EventDispatcher;
return mOperationsQueue;
}
void beforeUpdateViewHierarchy() {
commitViewUpdates();
}
/**
* Given a root of the laid-out shadow node hierarchy, walks the tree and generates an array of
* DrawCommands that will then mount in UI thread to a root FlatViewGroup so that it can draw.
@ -143,8 +137,21 @@ import com.facebook.react.uimanager.events.EventDispatcher;
/* package */ void enqueueCreateOrUpdateView(
FlatShadowNode node,
@Nullable ReactStylesDiffMap styles) {
mViewsToUpdate.add(node);
mStylesToUpdate.add(styles);
if (node.isBackingViewCreated()) {
// if the View is already created, make sure propagate new styles.
mOperationsQueue.enqueueUpdateProperties(
node.getReactTag(),
node.getViewClass(),
styles);
} else {
mOperationsQueue.enqueueCreateView(
node.getThemedContext(),
node.getReactTag(),
node.getViewClass(),
styles);
node.signalBackingViewIsCreated();
}
}
/* package */ boolean ensureBackingViewIsCreated(FlatShadowNode node) {
@ -163,36 +170,6 @@ import com.facebook.react.uimanager.events.EventDispatcher;
mViewsToDrop.add(node);
}
private void commitViewUpdates() {
for (int i = 0, numViewsToUpdate = mViewsToUpdate.size(); i != numViewsToUpdate; ++i) {
FlatShadowNode node = mViewsToUpdate.get(i);
if (node.getParent() == null) {
// Shadow node is not attached to the hierarchy, which means it is being discarded.
// No need to create or update view in this case, as the View is already gone as well.
continue;
}
if (node.isBackingViewCreated()) {
// if the View is already created, make sure propagate new styles.
mOperationsQueue.enqueueUpdateProperties(
node.getReactTag(),
node.getViewClass(),
mStylesToUpdate.get(i));
} else {
mOperationsQueue.enqueueCreateView(
node.getThemedContext(),
node.getReactTag(),
node.getViewClass(),
mStylesToUpdate.get(i));
node.signalBackingViewIsCreated();
}
}
mViewsToUpdate.clear();
mStylesToUpdate.clear();
}
private void addNodeRegion(
FlatShadowNode node,
float left,