Fix commit order of operations in Nodes

Summary: @public Split dispatchViewUpdates into two methods, which enables subclasses to commit pending ui operations, even when no root node is present.

Differential Revision: D3011191
This commit is contained in:
Ahmed El-Helw 2016-03-04 16:20:47 -08:00
parent a541384621
commit 1a4d40df6c
2 changed files with 15 additions and 4 deletions

View File

@ -380,13 +380,20 @@ public class FlatUIImplementation extends UIImplementation {
parentNode.addChildAt(childNode, index);
}
@Override
protected void updateViewHierarchy(EventDispatcher eventDispatcher) {
mStateBuilder.beforeUpdateViewHierarchy();
super.updateViewHierarchy(eventDispatcher);
mStateBuilder.afterUpdateViewHierarchy(eventDispatcher);
}
@Override
protected void applyUpdatesRecursive(
ReactShadowNode cssNode,
float absoluteX,
float absoluteY,
EventDispatcher eventDispatcher) {
mStateBuilder.applyUpdates(eventDispatcher, (FlatRootShadowNode) cssNode);
mStateBuilder.applyUpdates((FlatRootShadowNode) cssNode);
}
@Override

View File

@ -61,13 +61,15 @@ 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.
*/
/* package */ void applyUpdates(EventDispatcher eventDispatcher, FlatShadowNode node) {
commitViewUpdates();
/* package */ void applyUpdates(FlatShadowNode node) {
float width = node.getLayoutWidth();
float height = node.getLayoutHeight();
float left = node.getLayoutX();
@ -87,7 +89,9 @@ import com.facebook.react.uimanager.events.EventDispatcher;
Float.POSITIVE_INFINITY);
updateViewBounds(node, left, top, right, bottom);
}
void afterUpdateViewHierarchy(EventDispatcher eventDispatcher) {
if (mDetachAllChildrenFromViews != null) {
int[] viewsToDetachAllChildrenFrom = collectViewTags(mViewsToDetachAllChildrenFrom);
mViewsToDetachAllChildrenFrom.clear();