listview enable cell refresh
This commit is contained in:
@@ -105,8 +105,21 @@ public abstract class GroupNode<F extends ViewGroup> extends SuperNode<F> {
|
||||
for (ViewNode node : tobeRemoved) {
|
||||
mChildrenNode.remove(node.getId());
|
||||
}
|
||||
} else if ("subviews".equals(name)) {
|
||||
// Currently do nothing,because its subview always contained in props.children
|
||||
// super.blend(view, layoutParams, name, prop);
|
||||
} else {
|
||||
super.blend(view, layoutParams, name, prop);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void blendSubNode(JSObject subProp) {
|
||||
String subNodeId = subProp.getProperty("id").asString().value();
|
||||
for (ViewNode node : mChildrenNode.values()) {
|
||||
if (subNodeId.equals(node.getId())) {
|
||||
node.blend(subProp, node.getLayoutParams());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -18,6 +18,7 @@ package pub.doric.shader;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.github.pengfeizhou.jscore.JSArray;
|
||||
import com.github.pengfeizhou.jscore.JSObject;
|
||||
import com.github.pengfeizhou.jscore.JSValue;
|
||||
|
||||
@@ -38,6 +39,21 @@ public abstract class SuperNode<V extends View> extends ViewNode<V> {
|
||||
return new ViewGroup.LayoutParams(0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void blend(V view, ViewGroup.LayoutParams layoutParams, String name, JSValue prop) {
|
||||
if (name.equals("subviews")) {
|
||||
JSArray subviews = prop.asArray();
|
||||
for (int i = 0; i < subviews.size(); i++) {
|
||||
JSObject subProp = subviews.get(i).asObject();
|
||||
blendSubNode(subProp);
|
||||
}
|
||||
} else {
|
||||
super.blend(view, layoutParams, name, prop);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void blendSubNode(JSObject subProperties);
|
||||
|
||||
protected void blendSubLayoutConfig(ViewNode viewNode, JSObject jsObject) {
|
||||
JSValue jsValue = jsObject.getProperty("margin");
|
||||
JSValue widthSpec = jsObject.getProperty("widthSpec");
|
||||
|
@@ -26,6 +26,9 @@ import com.github.pengfeizhou.jscore.JSDecoder;
|
||||
import com.github.pengfeizhou.jscore.JSObject;
|
||||
import com.github.pengfeizhou.jscore.JSValue;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import pub.doric.async.AsyncResult;
|
||||
import pub.doric.shader.ViewNode;
|
||||
|
||||
@@ -58,7 +61,7 @@ public class ListAdapter extends RecyclerView.Adapter<ListAdapter.DoricViewHolde
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull DoricViewHolder holder, int position) {
|
||||
JSObject jsObject = getItemModel(position);
|
||||
holder.listItemNode.setId(String.valueOf(position));
|
||||
holder.listItemNode.setId(jsObject.getProperty("id").asString().value());
|
||||
holder.listItemNode.blend(jsObject.getProperty("props").asObject(), holder.itemView.getLayoutParams());
|
||||
}
|
||||
|
||||
@@ -101,6 +104,22 @@ public class ListAdapter extends RecyclerView.Adapter<ListAdapter.DoricViewHolde
|
||||
}
|
||||
|
||||
|
||||
public void blendSubNode(JSObject subProperties) {
|
||||
String subNodeId = subProperties.getProperty("id").asString().value();
|
||||
for (int i = 0; i < itemObjects.size(); i++) {
|
||||
JSObject jsObject = itemObjects.valueAt(i);
|
||||
if (subNodeId.equals(jsObject.getProperty("id").asString().value())) {
|
||||
for (String key : subProperties.propertySet()) {
|
||||
jsObject.setProperty(key, subProperties.getProperty(key));
|
||||
}
|
||||
int position = itemObjects.keyAt(i);
|
||||
notifyItemChanged(position);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static class DoricViewHolder extends RecyclerView.ViewHolder {
|
||||
ListItemNode listItemNode;
|
||||
|
||||
|
@@ -42,6 +42,11 @@ public class ListNode extends SuperNode<RecyclerView> {
|
||||
this.listAdapter = new ListAdapter(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void blendSubNode(JSObject subProperties) {
|
||||
listAdapter.blendSubNode(subProperties);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RecyclerView build(JSObject jsObject) {
|
||||
RecyclerView recyclerView = new RecyclerView(getContext());
|
||||
|
Reference in New Issue
Block a user