void updateViewGroup(int reactTag, int[] viewsToAdd, int[] viewsToDetach) { View view = resolveView(reactTag); if (view instanceof FlatViewGroup) { ((FlatViewGroup) view).mountViews(this, viewsToAdd, viewsToDetach); return; } ViewGroup viewGroup = (ViewGroup) view; ViewGroupManager viewManager = (ViewGroupManager) resolveViewManager(reactTag); List<View> listOfViews = new ArrayList<>(viewsToAdd.length); // batch the set of additions - some view managers can take advantage of the batching to // decrease operations, etc. for (int viewIdToAdd : viewsToAdd) { int tag = Math.abs(viewIdToAdd); listOfViews.add(resolveView(tag)); } viewManager.addViews(viewGroup, listOfViews); }
NativeViewWrapper(ViewManager viewManager) { ReactShadowNode reactShadowNode = viewManager.createShadowNodeInstance(); if (reactShadowNode instanceof YogaMeasureFunction) { mReactShadowNode = reactShadowNode; setMeasureFunction((YogaMeasureFunction) reactShadowNode); } else { mReactShadowNode = null; } if (viewManager instanceof ViewGroupManager) { ViewGroupManager viewGroupManager = (ViewGroupManager) viewManager; mNeedsCustomLayoutForChildren = viewGroupManager.needsCustomLayoutForChildren(); mForceMountGrandChildrenToView = viewGroupManager.shouldPromoteGrandchildren(); } else { mNeedsCustomLayoutForChildren = false; } forceMountToView(); forceMountChildrenToView(); }
void detachAllChildrenFromViews(int[] viewsToDetachAllChildrenFrom) { for (int viewTag : viewsToDetachAllChildrenFrom) { View view = resolveView(viewTag); if (view instanceof FlatViewGroup) { ((FlatViewGroup) view).detachAllViewsFromParent(); continue; } ViewGroup viewGroup = (ViewGroup) view; ViewGroupManager viewManager = (ViewGroupManager) resolveViewManager(viewTag); viewManager.removeAllViews(viewGroup); } }