Android: fix props mixin in blend sub node
This commit is contained in:
parent
875f3a5066
commit
44d971b870
@ -22,8 +22,10 @@ import com.github.pengfeizhou.jscore.JSArray;
|
|||||||
import com.github.pengfeizhou.jscore.JSObject;
|
import com.github.pengfeizhou.jscore.JSObject;
|
||||||
import com.github.pengfeizhou.jscore.JSValue;
|
import com.github.pengfeizhou.jscore.JSValue;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
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 srcProps = src.getProperty("props").asObject();
|
||||||
JSObject targetProps = target.getProperty("props").asObject();
|
JSObject targetProps = target.getProperty("props").asObject();
|
||||||
JSValue oriSubviews = targetProps.getProperty("subviews");
|
JSValue oriSubviews = targetProps.getProperty("subviews");
|
||||||
|
|
||||||
for (String key : srcProps.propertySet()) {
|
for (String key : srcProps.propertySet()) {
|
||||||
JSValue jsValue = srcProps.getProperty(key);
|
JSValue jsValue = srcProps.getProperty(key);
|
||||||
if ("subviews".equals(key) && jsValue.isArray()) {
|
if ("subviews".equals(key) && jsValue.isArray()) {
|
||||||
JSValue[] subviews = jsValue.asArray().toArray();
|
JSValue[] subviews = jsValue.asArray().toArray();
|
||||||
|
|
||||||
|
List<JSValue> finalTarget = new ArrayList<>();
|
||||||
|
|
||||||
for (JSValue subview : subviews) {
|
for (JSValue subview : subviews) {
|
||||||
|
boolean find = false;
|
||||||
if (oriSubviews.isArray()) {
|
if (oriSubviews.isArray()) {
|
||||||
for (JSValue targetSubview : oriSubviews.asArray().toArray()) {
|
for (JSValue targetSubview : oriSubviews.asArray().toArray()) {
|
||||||
if (viewIdIsEqual(subview.asObject(), targetSubview.asObject())) {
|
if (viewIdIsEqual(subview.asObject(), targetSubview.asObject())) {
|
||||||
|
find = true;
|
||||||
recursiveMixin(subview.asObject(), targetSubview.asObject());
|
recursiveMixin(subview.asObject(), targetSubview.asObject());
|
||||||
|
finalTarget.add(targetSubview);
|
||||||
break;
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
targetProps.asObject().setProperty(key, jsValue);
|
targetProps.asObject().setProperty(key, jsValue);
|
||||||
|
@ -378,13 +378,13 @@ public class FlowLayoutNode extends SuperNode<RecyclerView> implements IDoricScr
|
|||||||
protected void blendSubNode(JSObject subProperties) {
|
protected void blendSubNode(JSObject subProperties) {
|
||||||
String viewId = subProperties.getProperty("id").asString().value();
|
String viewId = subProperties.getProperty("id").asString().value();
|
||||||
ViewNode<?> node = getSubNodeById(viewId);
|
ViewNode<?> node = getSubNodeById(viewId);
|
||||||
if (node != null) {
|
|
||||||
node.blend(subProperties.getProperty("props").asObject());
|
|
||||||
} else {
|
|
||||||
JSObject oldModel = getSubModel(viewId);
|
JSObject oldModel = getSubModel(viewId);
|
||||||
if (oldModel != null) {
|
if (oldModel != null) {
|
||||||
recursiveMixin(subProperties, oldModel);
|
recursiveMixin(subProperties, oldModel);
|
||||||
}
|
}
|
||||||
|
if (node != null) {
|
||||||
|
node.blend(subProperties.getProperty("props").asObject());
|
||||||
|
} else {
|
||||||
flowAdapter.blendSubNode(subProperties);
|
flowAdapter.blendSubNode(subProperties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,13 +160,13 @@ public class HorizontalListNode extends SuperNode<RecyclerView> implements IDori
|
|||||||
protected void blendSubNode(JSObject subProperties) {
|
protected void blendSubNode(JSObject subProperties) {
|
||||||
String viewId = subProperties.getProperty("id").asString().value();
|
String viewId = subProperties.getProperty("id").asString().value();
|
||||||
ViewNode<?> node = getSubNodeById(viewId);
|
ViewNode<?> node = getSubNodeById(viewId);
|
||||||
if (node != null) {
|
|
||||||
node.blend(subProperties.getProperty("props").asObject());
|
|
||||||
} else {
|
|
||||||
JSObject oldModel = getSubModel(viewId);
|
JSObject oldModel = getSubModel(viewId);
|
||||||
if (oldModel != null) {
|
if (oldModel != null) {
|
||||||
recursiveMixin(subProperties, oldModel);
|
recursiveMixin(subProperties, oldModel);
|
||||||
}
|
}
|
||||||
|
if (node != null) {
|
||||||
|
node.blend(subProperties.getProperty("props").asObject());
|
||||||
|
} else {
|
||||||
horizontalListAdapter.blendSubNode(subProperties);
|
horizontalListAdapter.blendSubNode(subProperties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -160,13 +160,13 @@ public class ListNode extends SuperNode<RecyclerView> implements IDoricScrollabl
|
|||||||
protected void blendSubNode(JSObject subProperties) {
|
protected void blendSubNode(JSObject subProperties) {
|
||||||
String viewId = subProperties.getProperty("id").asString().value();
|
String viewId = subProperties.getProperty("id").asString().value();
|
||||||
ViewNode<?> node = getSubNodeById(viewId);
|
ViewNode<?> node = getSubNodeById(viewId);
|
||||||
if (node != null) {
|
|
||||||
node.blend(subProperties.getProperty("props").asObject());
|
|
||||||
} else {
|
|
||||||
JSObject oldModel = getSubModel(viewId);
|
JSObject oldModel = getSubModel(viewId);
|
||||||
if (oldModel != null) {
|
if (oldModel != null) {
|
||||||
recursiveMixin(subProperties, oldModel);
|
recursiveMixin(subProperties, oldModel);
|
||||||
}
|
}
|
||||||
|
if (node != null) {
|
||||||
|
node.blend(subProperties.getProperty("props").asObject());
|
||||||
|
} else {
|
||||||
listAdapter.blendSubNode(subProperties);
|
listAdapter.blendSubNode(subProperties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,13 +170,13 @@ public class SliderNode extends SuperNode<RecyclerView> {
|
|||||||
protected void blendSubNode(JSObject subProperties) {
|
protected void blendSubNode(JSObject subProperties) {
|
||||||
String viewId = subProperties.getProperty("id").asString().value();
|
String viewId = subProperties.getProperty("id").asString().value();
|
||||||
ViewNode<?> node = getSubNodeById(viewId);
|
ViewNode<?> node = getSubNodeById(viewId);
|
||||||
if (node != null) {
|
|
||||||
node.blend(subProperties.getProperty("props").asObject());
|
|
||||||
} else {
|
|
||||||
JSObject oldModel = getSubModel(viewId);
|
JSObject oldModel = getSubModel(viewId);
|
||||||
if (oldModel != null) {
|
if (oldModel != null) {
|
||||||
recursiveMixin(subProperties, oldModel);
|
recursiveMixin(subProperties, oldModel);
|
||||||
}
|
}
|
||||||
|
if (node != null) {
|
||||||
|
node.blend(subProperties.getProperty("props").asObject());
|
||||||
|
} else {
|
||||||
slideAdapter.blendSubNode(subProperties);
|
slideAdapter.blendSubNode(subProperties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user