diff --git a/doric-android/doric/src/main/java/pub/doric/shader/HLayoutNode.java b/doric-android/doric/src/main/java/pub/doric/shader/HLayoutNode.java index 240158d8..c5ec668e 100644 --- a/doric-android/doric/src/main/java/pub/doric/shader/HLayoutNode.java +++ b/doric-android/doric/src/main/java/pub/doric/shader/HLayoutNode.java @@ -15,12 +15,12 @@ */ package pub.doric.shader; -import android.widget.LinearLayout; + +import androidx.appcompat.widget.DoricLinearLayoutCompat; import pub.doric.DoricContext; import pub.doric.extension.bridge.DoricPlugin; -import com.github.pengfeizhou.jscore.JSObject; /** * @Description: com.github.penfeizhou.doric.shader @@ -34,9 +34,9 @@ public class HLayoutNode extends LinearNode { } @Override - protected LinearLayout build() { - LinearLayout linearLayout = super.build(); - linearLayout.setOrientation(LinearLayout.HORIZONTAL); + protected DoricLinearLayoutCompat build() { + DoricLinearLayoutCompat linearLayout = super.build(); + linearLayout.setOrientation(DoricLinearLayoutCompat.HORIZONTAL); return linearLayout; } } diff --git a/doric-android/doric/src/main/java/pub/doric/shader/LinearNode.java b/doric-android/doric/src/main/java/pub/doric/shader/LinearNode.java index 924b1db9..ae61c6ca 100644 --- a/doric-android/doric/src/main/java/pub/doric/shader/LinearNode.java +++ b/doric-android/doric/src/main/java/pub/doric/shader/LinearNode.java @@ -18,7 +18,8 @@ package pub.doric.shader; import android.content.Context; import android.graphics.drawable.ShapeDrawable; import android.view.ViewGroup; -import android.widget.LinearLayout; + +import androidx.appcompat.widget.DoricLinearLayoutCompat; import com.github.pengfeizhou.jscore.JSObject; import com.github.pengfeizhou.jscore.JSValue; @@ -31,9 +32,9 @@ import pub.doric.utils.DoricUtils; * @Author: pengfei.zhou * @CreateDate: 2019-07-23 */ -public class LinearNode extends GroupNode { +public class LinearNode extends GroupNode { - private static class MaximumLinearLayout extends LinearLayout { + private static class MaximumLinearLayout extends DoricLinearLayoutCompat { private int maxWidth = Integer.MAX_VALUE; private int maxHeight = Integer.MAX_VALUE; @@ -55,6 +56,11 @@ public class LinearNode extends GroupNode { super.onMeasure(widthMeasureSpec, heightMeasureSpec); } } + + @Override + protected void onLayout(boolean changed, int l, int t, int r, int b) { + super.onLayout(changed, l, t, r, b); + } } public LinearNode(DoricContext doricContext) { @@ -75,32 +81,32 @@ public class LinearNode extends GroupNode { } @Override - protected void blendSubLayoutConfig(ViewNode viewNode, JSObject layoutConfig) { + protected void blendSubLayoutConfig(ViewNode viewNode, JSObject layoutConfig) { super.blendSubLayoutConfig(viewNode, layoutConfig); JSValue jsValue = layoutConfig.getProperty("alignment"); if (jsValue.isNumber()) { - ((LinearLayout.LayoutParams) viewNode.getLayoutParams()).gravity = jsValue.asNumber().toInt(); + ((DoricLinearLayoutCompat.LayoutParams) viewNode.getLayoutParams()).gravity = jsValue.asNumber().toInt(); } JSValue weight = layoutConfig.getProperty("weight"); if (weight.isNumber()) { - ((LinearLayout.LayoutParams) viewNode.getLayoutParams()).weight = weight.asNumber().toInt(); + ((DoricLinearLayoutCompat.LayoutParams) viewNode.getLayoutParams()).weight = weight.asNumber().toInt(); } } @Override protected ViewGroup.LayoutParams generateDefaultLayoutParams() { - return new LinearLayout.LayoutParams(0, 0); + return new DoricLinearLayoutCompat.LayoutParams(0, 0); } @Override - protected LinearLayout build() { - LinearLayout linearLayout= new MaximumLinearLayout(getContext()); + protected DoricLinearLayoutCompat build() { + DoricLinearLayoutCompat linearLayout = new MaximumLinearLayout(getContext()); linearLayout.setBaselineAligned(false); - return linearLayout; + return linearLayout; } @Override - protected void blend(LinearLayout view, String name, JSValue prop) { + protected void blend(DoricLinearLayoutCompat view, String name, JSValue prop) { switch (name) { case "space": if (!prop.isNumber()) { @@ -110,12 +116,12 @@ public class LinearNode extends GroupNode { if (view.getDividerDrawable() == null) { shapeDrawable = new ShapeDrawable(); shapeDrawable.setAlpha(0); - view.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); + view.setShowDividers(DoricLinearLayoutCompat.SHOW_DIVIDER_MIDDLE); } else { shapeDrawable = (ShapeDrawable) view.getDividerDrawable(); view.setDividerDrawable(null); } - if (view.getOrientation() == LinearLayout.VERTICAL) { + if (view.getOrientation() == DoricLinearLayoutCompat.VERTICAL) { shapeDrawable.setIntrinsicHeight(DoricUtils.dp2px(prop.asNumber().toFloat())); } else { shapeDrawable.setIntrinsicWidth(DoricUtils.dp2px(prop.asNumber().toFloat())); diff --git a/doric-android/doric/src/main/java/pub/doric/shader/VLayoutNode.java b/doric-android/doric/src/main/java/pub/doric/shader/VLayoutNode.java index 6c6ba948..1c278fed 100644 --- a/doric-android/doric/src/main/java/pub/doric/shader/VLayoutNode.java +++ b/doric-android/doric/src/main/java/pub/doric/shader/VLayoutNode.java @@ -15,7 +15,7 @@ */ package pub.doric.shader; -import android.widget.LinearLayout; +import androidx.appcompat.widget.DoricLinearLayoutCompat; import pub.doric.DoricContext; import pub.doric.extension.bridge.DoricPlugin; @@ -32,9 +32,9 @@ public class VLayoutNode extends LinearNode { } @Override - protected LinearLayout build() { - LinearLayout linearLayout = super.build(); - linearLayout.setOrientation(LinearLayout.VERTICAL); + protected DoricLinearLayoutCompat build() { + DoricLinearLayoutCompat linearLayout = super.build(); + linearLayout.setOrientation(DoricLinearLayoutCompat.VERTICAL); return linearLayout; } diff --git a/doric-android/doric/src/main/java/pub/doric/shader/ViewNode.java b/doric-android/doric/src/main/java/pub/doric/shader/ViewNode.java index 40d895a2..30341c8c 100644 --- a/doric-android/doric/src/main/java/pub/doric/shader/ViewNode.java +++ b/doric-android/doric/src/main/java/pub/doric/shader/ViewNode.java @@ -39,6 +39,7 @@ import android.widget.FrameLayout; import android.widget.LinearLayout; import androidx.annotation.NonNull; +import androidx.appcompat.widget.DoricLinearLayoutCompat; import androidx.interpolator.view.animation.FastOutSlowInInterpolator; import com.github.pengfeizhou.jscore.JSArray; @@ -159,7 +160,7 @@ public abstract class ViewNode extends DoricContextHolder { } else { params = mLayoutParams; } - if (mLayoutParams instanceof LinearLayout.LayoutParams && ((LinearLayout.LayoutParams) mLayoutParams).weight > 0) { + if (mLayoutParams instanceof DoricLinearLayoutCompat.LayoutParams && ((DoricLinearLayoutCompat.LayoutParams) mLayoutParams).weight > 0) { if (mSuperNode instanceof VLayoutNode) { params.height = ViewGroup.LayoutParams.MATCH_PARENT; } else if (mSuperNode instanceof HLayoutNode) {