Switch to YogaNode.create()

Summary:
@public

Switches instance creation from `new YogaNode()` to `YogaNode.create()`.

This allows for experimentation with different implementations, while maintaining API + ABI compatibility internally at FB, as well as for dependent projects in open source and elsewhere.

Reviewed By: amir-shalem

Differential Revision: D14122975

fbshipit-source-id: f194b146b7cd693dba1a7dafdf92d350e54cb179
This commit is contained in:
David Aurelio
2019-02-19 11:15:10 -08:00
committed by Facebook Github Bot
parent cbcf07f08a
commit 016a10df26
3 changed files with 6 additions and 6 deletions

View File

@@ -33,7 +33,7 @@ public class VirtualYogaLayout extends ViewGroup {
final private List<View> mChildren = new LinkedList<>(); final private List<View> mChildren = new LinkedList<>();
final private Map<View, YogaNode> mYogaNodes = new HashMap<>(); final private Map<View, YogaNode> mYogaNodes = new HashMap<>();
final private YogaNode mYogaNode = new YogaNode(); final private YogaNode mYogaNode = YogaNode.create();
public VirtualYogaLayout(Context context) { public VirtualYogaLayout(Context context) {
super(context); super(context);
@@ -73,7 +73,7 @@ public class VirtualYogaLayout extends ViewGroup {
return; return;
} }
YogaNode node = new YogaNode(); YogaNode node = YogaNode.create();
YogaLayout.LayoutParams lp = new YogaLayout.LayoutParams(params); YogaLayout.LayoutParams lp = new YogaLayout.LayoutParams(params);
YogaLayout.applyLayoutParams(lp, node, child); YogaLayout.applyLayoutParams(lp, node, child);
node.setData(child); node.setData(child);

View File

@@ -78,7 +78,7 @@ public class YogaLayout extends ViewGroup {
public YogaLayout(Context context, AttributeSet attrs, int defStyleAttr) { public YogaLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr); super(context, attrs, defStyleAttr);
mYogaNode = new YogaNode(); mYogaNode = YogaNode.create();
mYogaNodes = new HashMap<>(); mYogaNodes = new HashMap<>();
mYogaNode.setData(this); mYogaNode.setData(this);
@@ -155,7 +155,7 @@ public class YogaLayout extends ViewGroup {
if(mYogaNodes.containsKey(child)) { if(mYogaNodes.containsKey(child)) {
childNode = mYogaNodes.get(child); childNode = mYogaNodes.get(child);
} else { } else {
childNode = new YogaNode(); childNode = YogaNode.create();
} }
childNode.setData(child); childNode.setData(child);

View File

@@ -15,12 +15,12 @@ public class TestParametrization {
NodeFactory nodeFactory = new NodeFactory() { NodeFactory nodeFactory = new NodeFactory() {
@Override @Override
public YogaNode create() { public YogaNode create() {
return new YogaNode(); return YogaNode.create();
} }
@Override @Override
public YogaNode create(YogaConfig config) { public YogaNode create(YogaConfig config) {
return new YogaNode(config); return YogaNode.create(config);
} }
@Override @Override