diff --git a/doric-android/doric/src/main/java/pub/doric/shader/SuperNode.java b/doric-android/doric/src/main/java/pub/doric/shader/SuperNode.java index 7746482e..32ce214d 100644 --- a/doric-android/doric/src/main/java/pub/doric/shader/SuperNode.java +++ b/doric-android/doric/src/main/java/pub/doric/shader/SuperNode.java @@ -22,8 +22,10 @@ import com.github.pengfeizhou.jscore.JSArray; import com.github.pengfeizhou.jscore.JSObject; import com.github.pengfeizhou.jscore.JSValue; +import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.Set; @@ -118,20 +120,37 @@ public abstract class SuperNode extends ViewNode { JSObject srcProps = src.getProperty("props").asObject(); JSObject targetProps = target.getProperty("props").asObject(); JSValue oriSubviews = targetProps.getProperty("subviews"); + for (String key : srcProps.propertySet()) { JSValue jsValue = srcProps.getProperty(key); if ("subviews".equals(key) && jsValue.isArray()) { JSValue[] subviews = jsValue.asArray().toArray(); + + List finalTarget = new ArrayList<>(); + for (JSValue subview : subviews) { + boolean find = false; if (oriSubviews.isArray()) { for (JSValue targetSubview : oriSubviews.asArray().toArray()) { if (viewIdIsEqual(subview.asObject(), targetSubview.asObject())) { + find = true; recursiveMixin(subview.asObject(), targetSubview.asObject()); + finalTarget.add(targetSubview); break; } } } + + if (!find) { + finalTarget.add(subview); + } } + + JSArray jsArray = new JSArray(finalTarget.size()); + for (int i = 0; i < jsArray.size(); i++) { + jsArray.put(i, finalTarget.get(i)); + } + targetProps.asObject().setProperty(key, jsArray); continue; } targetProps.asObject().setProperty(key, jsValue); diff --git a/doric-android/doric/src/main/java/pub/doric/shader/flowlayout/FlowLayoutNode.java b/doric-android/doric/src/main/java/pub/doric/shader/flowlayout/FlowLayoutNode.java index c6cd6c7a..8160cf0d 100644 --- a/doric-android/doric/src/main/java/pub/doric/shader/flowlayout/FlowLayoutNode.java +++ b/doric-android/doric/src/main/java/pub/doric/shader/flowlayout/FlowLayoutNode.java @@ -378,13 +378,13 @@ public class FlowLayoutNode extends SuperNode implements IDoricScr protected void blendSubNode(JSObject subProperties) { String viewId = subProperties.getProperty("id").asString().value(); ViewNode node = getSubNodeById(viewId); + JSObject oldModel = getSubModel(viewId); + if (oldModel != null) { + recursiveMixin(subProperties, oldModel); + } if (node != null) { node.blend(subProperties.getProperty("props").asObject()); } else { - JSObject oldModel = getSubModel(viewId); - if (oldModel != null) { - recursiveMixin(subProperties, oldModel); - } flowAdapter.blendSubNode(subProperties); } } diff --git a/doric-android/doric/src/main/java/pub/doric/shader/horizontallist/HorizontalListNode.java b/doric-android/doric/src/main/java/pub/doric/shader/horizontallist/HorizontalListNode.java index f546d934..9aae0fa4 100644 --- a/doric-android/doric/src/main/java/pub/doric/shader/horizontallist/HorizontalListNode.java +++ b/doric-android/doric/src/main/java/pub/doric/shader/horizontallist/HorizontalListNode.java @@ -160,13 +160,13 @@ public class HorizontalListNode extends SuperNode implements IDori protected void blendSubNode(JSObject subProperties) { String viewId = subProperties.getProperty("id").asString().value(); ViewNode node = getSubNodeById(viewId); + JSObject oldModel = getSubModel(viewId); + if (oldModel != null) { + recursiveMixin(subProperties, oldModel); + } if (node != null) { node.blend(subProperties.getProperty("props").asObject()); } else { - JSObject oldModel = getSubModel(viewId); - if (oldModel != null) { - recursiveMixin(subProperties, oldModel); - } horizontalListAdapter.blendSubNode(subProperties); } } diff --git a/doric-android/doric/src/main/java/pub/doric/shader/list/ListNode.java b/doric-android/doric/src/main/java/pub/doric/shader/list/ListNode.java index 7e73f6ef..8dc45d90 100644 --- a/doric-android/doric/src/main/java/pub/doric/shader/list/ListNode.java +++ b/doric-android/doric/src/main/java/pub/doric/shader/list/ListNode.java @@ -160,13 +160,13 @@ public class ListNode extends SuperNode implements IDoricScrollabl protected void blendSubNode(JSObject subProperties) { String viewId = subProperties.getProperty("id").asString().value(); ViewNode node = getSubNodeById(viewId); + JSObject oldModel = getSubModel(viewId); + if (oldModel != null) { + recursiveMixin(subProperties, oldModel); + } if (node != null) { node.blend(subProperties.getProperty("props").asObject()); } else { - JSObject oldModel = getSubModel(viewId); - if (oldModel != null) { - recursiveMixin(subProperties, oldModel); - } listAdapter.blendSubNode(subProperties); } } diff --git a/doric-android/doric/src/main/java/pub/doric/shader/slider/SliderNode.java b/doric-android/doric/src/main/java/pub/doric/shader/slider/SliderNode.java index 41be3e36..16e2dce5 100644 --- a/doric-android/doric/src/main/java/pub/doric/shader/slider/SliderNode.java +++ b/doric-android/doric/src/main/java/pub/doric/shader/slider/SliderNode.java @@ -170,13 +170,13 @@ public class SliderNode extends SuperNode { protected void blendSubNode(JSObject subProperties) { String viewId = subProperties.getProperty("id").asString().value(); ViewNode node = getSubNodeById(viewId); + JSObject oldModel = getSubModel(viewId); + if (oldModel != null) { + recursiveMixin(subProperties, oldModel); + } if (node != null) { node.blend(subProperties.getProperty("props").asObject()); } else { - JSObject oldModel = getSubModel(viewId); - if (oldModel != null) { - recursiveMixin(subProperties, oldModel); - } slideAdapter.blendSubNode(subProperties); } }