Add support for setChildren

Summary: This adds support for UIManager.setChildren on Android like D2757388 added for iOS.

Reviewed By: andreicoman11

Differential Revision: D3235369

fb-gh-sync-id: b538556ec4abdb606f9be26d1b74734046bca0cd
fbshipit-source-id: b538556ec4abdb606f9be26d1b74734046bca0cd
This commit is contained in:
Dave Miller
2016-04-29 04:03:24 -07:00
committed by Facebook Github Bot 1
parent 3f0207d7b5
commit 3a5457cd7c
6 changed files with 136 additions and 29 deletions
@@ -14,6 +14,7 @@ import javax.annotation.Nullable;
import android.util.SparseBooleanArray;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMapKeySetIterator;
/**
@@ -171,6 +172,27 @@ public class NativeViewHierarchyOptimizer {
}
}
/**
* Handles a setChildren call. This is a simplification of handleManagerChildren that only adds
* children in index order of the childrenTags array
*/
public void handleSetChildren(
ReactShadowNode nodeToManage,
ReadableArray childrenTags
) {
if (!ENABLED) {
mUIViewOperationQueue.enqueueSetChildren(
nodeToManage.getReactTag(),
childrenTags);
return;
}
for (int i = 0; i < childrenTags.size(); i++) {
ReactShadowNode nodeToAdd = mShadowNodeRegistry.getNode(childrenTags.getInt(i));
addNodeToNode(nodeToManage, nodeToAdd, i);
}
}
/**
* Handles an updateLayout call. All updateLayout calls are collected and dispatched at the end
* of a batch because updateLayout calls to layout-only nodes can necessitate multiple