mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-04 22:56:32 +08:00
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:
committed by
Facebook Github Bot 1
parent
3f0207d7b5
commit
3a5457cd7c
@@ -323,6 +323,35 @@ public class UIImplementation {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An optimized version of manageChildren that is used for initial setting of child views.
|
||||
* The children are assumed to be in index order
|
||||
*
|
||||
* @param viewTag tag of the parent
|
||||
* @param childrenTags tags of the children
|
||||
*/
|
||||
public void setChildren(
|
||||
int viewTag,
|
||||
ReadableArray childrenTags) {
|
||||
|
||||
ReactShadowNode cssNodeToManage = mShadowNodeRegistry.getNode(viewTag);
|
||||
|
||||
for (int i = 0; i < childrenTags.size(); i++) {
|
||||
ReactShadowNode cssNodeToAdd = mShadowNodeRegistry.getNode(childrenTags.getInt(i));
|
||||
if (cssNodeToAdd == null) {
|
||||
throw new IllegalViewOperationException("Trying to add unknown view tag: "
|
||||
+ childrenTags.getInt(i));
|
||||
}
|
||||
cssNodeToManage.addChildAt(cssNodeToAdd, i);
|
||||
}
|
||||
|
||||
if (!cssNodeToManage.isVirtual() && !cssNodeToManage.isVirtualAnchor()) {
|
||||
mNativeViewHierarchyOptimizer.handleSetChildren(
|
||||
cssNodeToManage,
|
||||
childrenTags);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the View specified by oldTag with the View specified by newTag within oldTag's parent.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user