feat:complete defination of LayoutConfig
This commit is contained in:
@@ -67,8 +67,8 @@ public class DoricJSEngine implements Handler.Callback, DoricTimerExtension.Time
|
||||
|
||||
|
||||
private void initJSExecutor() {
|
||||
// mDoricJSE = new DoricNativeJSExecutor();
|
||||
mDoricJSE = new DoricRemoteJSExecutor();
|
||||
mDoricJSE = new DoricNativeJSExecutor();
|
||||
// mDoricJSE = new DoricRemoteJSExecutor();
|
||||
mDoricJSE.injectGlobalJSFunction(DoricConstant.INJECT_LOG, new JavaFunction() {
|
||||
@Override
|
||||
public JavaValue exec(JSDecoder[] args) {
|
||||
|
@@ -116,12 +116,42 @@ public abstract class GroupNode<F extends ViewGroup> extends ViewNode<F> {
|
||||
}
|
||||
|
||||
protected ViewGroup.LayoutParams generateDefaultLayoutParams() {
|
||||
return new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
return new ViewGroup.LayoutParams(0, 0);
|
||||
}
|
||||
|
||||
protected void blendChild(ViewNode viewNode, JSObject jsObject) {
|
||||
|
||||
|
||||
JSValue jsValue = jsObject.getProperty("margin");
|
||||
JSValue widthSpec = jsObject.getProperty("widthSpec");
|
||||
JSValue heightSpec = jsObject.getProperty("widthSpec");
|
||||
|
||||
ViewGroup.LayoutParams layoutParams = viewNode.getLayoutParams();
|
||||
if (widthSpec.isNumber()) {
|
||||
switch (widthSpec.asNumber().toInt()) {
|
||||
case 1:
|
||||
layoutParams.width = ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
break;
|
||||
case 2:
|
||||
layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
if (heightSpec.isNumber()) {
|
||||
switch (heightSpec.asNumber().toInt()) {
|
||||
case 1:
|
||||
layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
break;
|
||||
case 2:
|
||||
layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (jsValue.isObject() && layoutParams instanceof ViewGroup.MarginLayoutParams) {
|
||||
JSValue topVal = jsValue.asObject().getProperty("top");
|
||||
if (topVal.isNumber()) {
|
||||
|
@@ -50,7 +50,7 @@ public class LinearNode extends GroupNode<LinearLayout> {
|
||||
|
||||
@Override
|
||||
protected ViewGroup.LayoutParams generateDefaultLayoutParams() {
|
||||
return new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
return new LinearLayout.LayoutParams(0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -62,6 +62,6 @@ public class StackNode extends GroupNode<FrameLayout> {
|
||||
|
||||
@Override
|
||||
protected ViewGroup.LayoutParams generateDefaultLayoutParams() {
|
||||
return new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
return new FrameLayout.LayoutParams(0, 0);
|
||||
}
|
||||
}
|
||||
|
@@ -86,16 +86,12 @@ public abstract class ViewNode<T extends View> extends DoricContextHolder {
|
||||
protected void blend(T view, ViewGroup.LayoutParams layoutParams, String name, JSValue prop) {
|
||||
switch (name) {
|
||||
case "width":
|
||||
if (prop.asNumber().toInt() < 0) {
|
||||
layoutParams.width = prop.asNumber().toInt();
|
||||
} else {
|
||||
if (layoutParams.width >= 0) {
|
||||
layoutParams.width = DoricUtils.dp2px(prop.asNumber().toFloat());
|
||||
}
|
||||
break;
|
||||
case "height":
|
||||
if (prop.asNumber().toInt() < 0) {
|
||||
layoutParams.height = prop.asNumber().toInt();
|
||||
} else {
|
||||
if (layoutParams.height >= 0) {
|
||||
layoutParams.height = DoricUtils.dp2px(prop.asNumber().toFloat());
|
||||
}
|
||||
break;
|
||||
|
Reference in New Issue
Block a user