feat:remove JSObject while build in node
This commit is contained in:
parent
d2f4302e42
commit
9e505894b0
@ -34,8 +34,8 @@ public class HLayoutNode extends LinearNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LinearLayout build(JSObject jsObject) {
|
||||
LinearLayout linearLayout = super.build(jsObject);
|
||||
protected LinearLayout build() {
|
||||
LinearLayout linearLayout = super.build();
|
||||
linearLayout.setOrientation(LinearLayout.HORIZONTAL);
|
||||
return linearLayout;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class ImageNode extends ViewNode<ImageView> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ImageView build(JSObject jsObject) {
|
||||
protected ImageView build() {
|
||||
return new ImageView(getContext());
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ public class LinearNode extends GroupNode<LinearLayout> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LinearLayout build(JSObject jsObject) {
|
||||
protected LinearLayout build() {
|
||||
return new LinearLayout(getContext());
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ public class StackNode extends GroupNode<FrameLayout> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FrameLayout build(JSObject jsObject) {
|
||||
protected FrameLayout build() {
|
||||
return new FrameLayout(getContext());
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ public class TextNode extends ViewNode<TextView> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TextView build(JSObject jsObject) {
|
||||
protected TextView build() {
|
||||
return new TextView(getContext());
|
||||
}
|
||||
|
||||
|
@ -34,8 +34,8 @@ public class VLayoutNode extends LinearNode {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LinearLayout build(JSObject jsObject) {
|
||||
LinearLayout linearLayout = super.build(jsObject);
|
||||
protected LinearLayout build() {
|
||||
LinearLayout linearLayout = super.build();
|
||||
linearLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
return linearLayout;
|
||||
}
|
||||
|
@ -41,7 +41,6 @@ import java.util.LinkedList;
|
||||
*/
|
||||
public abstract class ViewNode<T extends View> extends DoricContextHolder {
|
||||
protected T mView;
|
||||
int index;
|
||||
SuperNode mSuperNode;
|
||||
String mId;
|
||||
private ViewGroup.LayoutParams mLayoutParams;
|
||||
@ -52,6 +51,16 @@ public abstract class ViewNode<T extends View> extends DoricContextHolder {
|
||||
|
||||
private DoricLayer doricLayer;
|
||||
|
||||
public void init(SuperNode superNode) {
|
||||
this.mSuperNode = superNode;
|
||||
this.mLayoutParams = superNode.generateDefaultLayoutParams();
|
||||
this.doricLayer = new DoricLayer(getContext());
|
||||
this.mView = build();
|
||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(mLayoutParams.width, mLayoutParams.height);
|
||||
doricLayer.addView(mView, params);
|
||||
}
|
||||
|
||||
|
||||
public void setSuperNode(SuperNode parentNode) {
|
||||
mSuperNode = parentNode;
|
||||
}
|
||||
@ -68,12 +77,12 @@ public abstract class ViewNode<T extends View> extends DoricContextHolder {
|
||||
return getDoricContext().getContext();
|
||||
}
|
||||
|
||||
protected abstract T build(JSObject jsObject);
|
||||
protected abstract T build();
|
||||
|
||||
public void blend(JSObject jsObject, ViewGroup.LayoutParams layoutParams) {
|
||||
mLayoutParams = layoutParams;
|
||||
if (mView == null) {
|
||||
mView = build(jsObject);
|
||||
mView = build();
|
||||
}
|
||||
if (getDoricLayer() == null) {
|
||||
doricLayer = new DoricLayer(getContext());
|
||||
|
@ -35,7 +35,7 @@ public class ListItemNode extends StackNode {
|
||||
|
||||
public ListItemNode(DoricContext doricContext) {
|
||||
super(doricContext);
|
||||
this.mView = this.build(null);
|
||||
this.mView = this.build();
|
||||
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
this.blend(null, params);
|
||||
|
@ -48,7 +48,7 @@ public class ListNode extends SuperNode<RecyclerView> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RecyclerView build(JSObject jsObject) {
|
||||
protected RecyclerView build() {
|
||||
RecyclerView recyclerView = new RecyclerView(getContext());
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
recyclerView.setAdapter(this.listAdapter);
|
||||
|
Reference in New Issue
Block a user