From 844908bdc68265152d5c77d1bc85d277bbeb3a57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=8A=B2=E9=B9=8F?= Date: Wed, 21 Jul 2021 18:42:34 +0800 Subject: [PATCH] Android: impl show node tree view --- .../devkit/ui/DoricShowNodeTreeActivity.java | 13 ++++++++ .../treeview/DoricViewNodeLayoutItemType.java | 2 +- .../treeview/DoricViewNodeTreeViewBinder.java | 31 ++++++++++++++++++ .../devkit/ui/treeview/TreeViewAdapter.java | 4 ++- .../drawable-xhdpi/icon_doric_dev_info.png | Bin 0 -> 6814 bytes .../res/layout/layout_show_node_tree_cell.xml | 18 ++++++++-- .../main/java/pub/doric/shader/SuperNode.java | 16 ++++++++- 7 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 doric-android/devkit/src/main/res/drawable-xhdpi/icon_doric_dev_info.png 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 0000000000000000000000000000000000000000..a204858437b314e9f744aa0e2e62690bb66300f7 GIT binary patch literal 6814 zcmYj$c{tQx^#6P8+hmOF(!>l|OD3f#yBW(^lAW@Lh{>95EQMre5C$1r_AMoQB1V?6 zMcKC|Tb4$){Cs}jKfd2T?!C{wuk$*0JI`~^IXA`tqXlN+X8`~Jj7F&&owZ;7D@+V$ zb%j|a0RZ?N(dsJ3{x%yq%+)d)K0T)n9DPQ^s#l@3>T$wGpaPgj9+W3q(xXJBi=K@i ztZ4=Hle)w^5iR=C(vwG{fZ4A7vMlpUO<8?oVTt$jk=IHb!|xj#wH-YZnmyWV%pMt0 znhla$HP)Lx+PodybhLL|+*r4sm-m|geG8n>g4htIXeN6o{&{-%q<+;oIpogv)1Cd5 z(@Ojv7(J`2|25>53H4mTM!<*oS;er2P`0mI%dX}!rJz3eqrczplVTZq6v1@L$6MVt z$(z!Y#J!Zz{mfQrO7q@vEOBf9Lrt)oCE#!n4FK()347~x&8R8`ndChe^eLVI^oP&0 z;QCDlg5gSLWF^Ffp|y#Y;61zrC{`4IGq zC1dj`;IO7U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_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; + } }