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(); }
public void setMeasureFunction(YogaMeasureFunction measureFunction) { if ((measureFunction == null ^ mYogaNode.isMeasureDefined()) && getChildCount() != 0) { throw new RuntimeException( "Since a node with a measure function does not add any native yoga children, it's " + "not safe to transition to/from having a measure function unless a node has no children"); } mYogaNode.setMeasureFunction(measureFunction); }