Android: fix props mixin in blend sub node
This commit is contained in:
		| @@ -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<V extends View> extends ViewNode<V> { | ||||
|         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<JSValue> 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); | ||||
|   | ||||
| @@ -378,13 +378,13 @@ public class FlowLayoutNode extends SuperNode<RecyclerView> 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); | ||||
|         } | ||||
|     } | ||||
|   | ||||
| @@ -160,13 +160,13 @@ public class HorizontalListNode extends SuperNode<RecyclerView> 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); | ||||
|         } | ||||
|     } | ||||
|   | ||||
| @@ -160,13 +160,13 @@ public class ListNode extends SuperNode<RecyclerView> 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); | ||||
|         } | ||||
|     } | ||||
|   | ||||
| @@ -170,13 +170,13 @@ public class SliderNode extends SuperNode<RecyclerView> { | ||||
|     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); | ||||
|         } | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user