diff --git a/doric-android/devkit/src/main/java/pub/doric/devkit/ui/DoricShowNodeTreeActivity.java b/doric-android/devkit/src/main/java/pub/doric/devkit/ui/DoricShowNodeTreeActivity.java index 83782595..dc25d2a4 100644 --- a/doric-android/devkit/src/main/java/pub/doric/devkit/ui/DoricShowNodeTreeActivity.java +++ b/doric-android/devkit/src/main/java/pub/doric/devkit/ui/DoricShowNodeTreeActivity.java @@ -25,6 +25,7 @@ import java.util.Collections; import java.util.LinkedList; import java.util.List; import java.util.Queue; +import java.util.Set; import pub.doric.devkit.R; import pub.doric.devkit.ui.treeview.DoricViewNodeLayoutItemType; @@ -32,6 +33,7 @@ import pub.doric.devkit.ui.treeview.DoricViewNodeTreeViewBinder; import pub.doric.devkit.ui.treeview.TreeNode; import pub.doric.devkit.ui.treeview.TreeViewAdapter; import pub.doric.shader.GroupNode; +import pub.doric.shader.SuperNode; import pub.doric.shader.ViewNode; public class DoricShowNodeTreeActivity extends DoricDevBaseActivity { @@ -71,6 +73,17 @@ public class DoricShowNodeTreeActivity extends DoricDevBaseActivity { viewQueue.offer((ViewNode) groupNode.getChildNodes().get(i)); treeQueue.offer(temp); } + } else if (viewNode instanceof SuperNode) { + SuperNode superNode = (SuperNode) viewNode; + Set viewIds = superNode.getSubNodeViewIds(); + for (String viewId : viewIds) { + assert treeNode != null; + TreeNode temp = new TreeNode(new DoricViewNodeLayoutItemType(superNode.getSubNodeById(viewId))); + treeNode.addChild(temp); + + viewQueue.offer(superNode.getSubNodeById(viewId)); + treeQueue.offer(temp); + } } } diff --git a/doric-android/devkit/src/main/java/pub/doric/devkit/ui/treeview/DoricViewNodeLayoutItemType.java b/doric-android/devkit/src/main/java/pub/doric/devkit/ui/treeview/DoricViewNodeLayoutItemType.java index ed832ffc..48c87fc2 100644 --- a/doric-android/devkit/src/main/java/pub/doric/devkit/ui/treeview/DoricViewNodeLayoutItemType.java +++ b/doric-android/devkit/src/main/java/pub/doric/devkit/ui/treeview/DoricViewNodeLayoutItemType.java @@ -4,7 +4,7 @@ import pub.doric.devkit.R; import pub.doric.shader.ViewNode; public class DoricViewNodeLayoutItemType implements LayoutItemType { - private final ViewNode viewNode; + public final ViewNode viewNode; public DoricViewNodeLayoutItemType(ViewNode viewNode) { this.viewNode = viewNode; diff --git a/doric-android/devkit/src/main/java/pub/doric/devkit/ui/treeview/DoricViewNodeTreeViewBinder.java b/doric-android/devkit/src/main/java/pub/doric/devkit/ui/treeview/DoricViewNodeTreeViewBinder.java index 8ae12939..40798876 100644 --- a/doric-android/devkit/src/main/java/pub/doric/devkit/ui/treeview/DoricViewNodeTreeViewBinder.java +++ b/doric-android/devkit/src/main/java/pub/doric/devkit/ui/treeview/DoricViewNodeTreeViewBinder.java @@ -1,8 +1,15 @@ package pub.doric.devkit.ui.treeview; import android.view.View; +import android.widget.TextView; + +import java.util.Set; import pub.doric.devkit.R; +import pub.doric.shader.GroupNode; +import pub.doric.shader.RootNode; +import pub.doric.shader.SuperNode; +import pub.doric.shader.ViewNode; public class DoricViewNodeTreeViewBinder extends TreeViewBinder { @@ -14,6 +21,26 @@ public class DoricViewNodeTreeViewBinder extends TreeViewBinder "; + + String value = type + viewId; + if (viewNode instanceof GroupNode) { + GroupNode groupNode = (GroupNode) viewNode; + String childDesc = "(" + groupNode.getChildNodes().size() + " Child)"; + value = value + childDesc; + } else if (viewNode instanceof SuperNode) { + SuperNode superNode = (SuperNode) viewNode; + Set viewIds = superNode.getSubNodeViewIds(); + String childDesc = "(" + viewIds.size() + " Child)"; + value = value + childDesc; + } + holder.nodeName.setText(value); } @Override @@ -23,8 +50,12 @@ public class DoricViewNodeTreeViewBinder extends TreeViewBinder { private static final String KEY_IS_EXPAND = "IS_EXPAND"; private final List viewBinders; private List displayNodes; - private int padding = 30; + private int padding = DoricUtils.dp2px(15); private OnTreeNodeListener onTreeNodeListener; private boolean toCollapseChild; diff --git a/doric-android/devkit/src/main/res/drawable-xhdpi/icon_doric_dev_info.png b/doric-android/devkit/src/main/res/drawable-xhdpi/icon_doric_dev_info.png new file mode 100644 index 00000000..a2048584 Binary files /dev/null and b/doric-android/devkit/src/main/res/drawable-xhdpi/icon_doric_dev_info.png differ diff --git a/doric-android/devkit/src/main/res/layout/layout_show_node_tree_cell.xml b/doric-android/devkit/src/main/res/layout/layout_show_node_tree_cell.xml index 4aadd3cc..42fb1ffc 100644 --- a/doric-android/devkit/src/main/res/layout/layout_show_node_tree_cell.xml +++ b/doric-android/devkit/src/main/res/layout/layout_show_node_tree_cell.xml @@ -1,10 +1,24 @@ + android:layout_height="50dp" + android:orientation="horizontal"> + + + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:layout_marginStart="5dp" + android:layout_marginLeft="5dp" + tools:text="Node Name" /> \ No newline at end of file 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 0a12356a..e1cca45b 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 @@ -23,10 +23,11 @@ import com.github.pengfeizhou.jscore.JSObject; import com.github.pengfeizhou.jscore.JSValue; import java.util.HashMap; +import java.util.Iterator; import java.util.Map; +import java.util.Set; import pub.doric.DoricContext; -import pub.doric.utils.DoricUtils; /** * @Description: pub.doric.shader @@ -136,4 +137,17 @@ public abstract class SuperNode extends ViewNode { targetProps.asObject().setProperty(key, jsValue); } } + + public Set getSubNodeViewIds() { + Set allKeys = subNodes.keySet(); + Iterator iterator = allKeys.iterator(); + while (iterator.hasNext()) { + String element = iterator.next(); + if (getSubNodeById(element) == null) { + iterator.remove(); + } + } + + return allKeys; + } }