Make YogaLayout create programmatically. Make YogaNode of YogaLayout …

Summary:
Make YogaLayout constructible programmatically.
Make YogaLayout's YogaNode accessible from outside.
Closes https://github.com/facebook/yoga/pull/436

Differential Revision: D4850451

Pulled By: emilsjolander

fbshipit-source-id: 2821a6ef4160854244c0227a3c4c96369f7b2e64
This commit is contained in:
birfincankafein
2017-04-07 01:57:02 -07:00
committed by Facebook Github Bot
parent 49e18738c3
commit f66f52d1ba

View File

@@ -91,15 +91,20 @@ public class YogaLayout extends ViewGroup {
mYogaNode.setData(this); mYogaNode.setData(this);
mYogaNode.setMeasureFunction(new ViewMeasureFunction()); mYogaNode.setMeasureFunction(new ViewMeasureFunction());
final LayoutParams layoutParams = new LayoutParams(context, attrs); LayoutParams layoutParams = null;
if (attrs != null) {
layoutParams = new LayoutParams(context, attrs);
} else {
layoutParams = (LayoutParams) generateDefaultLayoutParams();
}
applyLayoutParams(layoutParams, mYogaNode, this); applyLayoutParams(layoutParams, mYogaNode, this);
} }
YogaNode getYogaNode() { public YogaNode getYogaNode() {
return mYogaNode; return mYogaNode;
} }
YogaNode getYogaNodeForView(View view) { public YogaNode getYogaNodeForView(View view) {
return mYogaNodes.get(view); return mYogaNodes.get(view);
} }
@@ -154,7 +159,11 @@ public class YogaLayout extends ViewGroup {
if (child instanceof YogaLayout) { if (child instanceof YogaLayout) {
childNode = ((YogaLayout) child).getYogaNode(); childNode = ((YogaLayout) child).getYogaNode();
} else { } else {
childNode = new YogaNode(); if(mYogaNodes.containsKey(child)) {
childNode = mYogaNodes.get(child);
} else {
childNode = new YogaNode();
}
childNode.setData(child); childNode.setData(child);
childNode.setMeasureFunction(new ViewMeasureFunction()); childNode.setMeasureFunction(new ViewMeasureFunction());