mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00: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
+45
@@ -388,6 +388,51 @@ public class NativeViewHierarchyManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Simplified version of constructManageChildrenErrorMessage that only deals with adding children
|
||||
* views
|
||||
*/
|
||||
private static String constructSetChildrenErrorMessage(
|
||||
ViewGroup viewToManage,
|
||||
ViewGroupManager viewManager,
|
||||
ReadableArray childrenTags) {
|
||||
ViewAtIndex[] viewsToAdd = new ViewAtIndex[childrenTags.size()];
|
||||
for (int i = 0; i < childrenTags.size(); i++) {
|
||||
viewsToAdd[i] = new ViewAtIndex(childrenTags.getInt(i), i);
|
||||
}
|
||||
return constructManageChildrenErrorMessage(
|
||||
viewToManage,
|
||||
viewManager,
|
||||
null,
|
||||
viewsToAdd,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Simplified version of manageChildren that only deals with adding children views
|
||||
*/
|
||||
public void setChildren(
|
||||
int tag,
|
||||
ReadableArray childrenTags) {
|
||||
ViewGroup viewToManage = (ViewGroup) mTagsToViews.get(tag);
|
||||
ViewGroupManager viewManager = (ViewGroupManager) resolveViewManager(tag);
|
||||
|
||||
for (int i = 0; i < childrenTags.size(); i++) {
|
||||
View viewToAdd = mTagsToViews.get(childrenTags.getInt(i));
|
||||
if (viewToAdd == null) {
|
||||
throw new IllegalViewOperationException(
|
||||
"Trying to add unknown view tag: "
|
||||
+ childrenTags.getInt(i) + "\n detail: " +
|
||||
constructSetChildrenErrorMessage(
|
||||
viewToManage,
|
||||
viewManager,
|
||||
childrenTags));
|
||||
}
|
||||
viewManager.addView(viewToManage, viewToAdd, i);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link UIManagerModule#addMeasuredRootView}.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user