From 3634859e51c70f22ff59e873f11d81a859c05bf4 Mon Sep 17 00:00:00 2001 From: lisonge Date: Wed, 6 Dec 2023 17:21:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E8=AF=86=E5=88=AB=20q?= =?UTF-8?q?uickFind=20=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/kotlin/li/songe/gkd/data/NodeInfo.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/kotlin/li/songe/gkd/data/NodeInfo.kt b/app/src/main/kotlin/li/songe/gkd/data/NodeInfo.kt index 05fe2f159..a485003bf 100644 --- a/app/src/main/kotlin/li/songe/gkd/data/NodeInfo.kt +++ b/app/src/main/kotlin/li/songe/gkd/data/NodeInfo.kt @@ -28,30 +28,30 @@ data class NodeInfo( companion object { private fun getIdQf( - parent: AccessibilityNodeInfo, + root: AccessibilityNodeInfo, node: AccessibilityNodeInfo, idQf: Boolean?, ): Boolean? { val viewId = node.viewIdResourceName if (viewId == null || viewId.isEmpty()) return null if (idQf == false) return false - return parent.findAccessibilityNodeInfosByViewId(viewId).any { n -> n == node } + return root.findAccessibilityNodeInfosByViewId(viewId).any { n -> n == node } } private fun getTextQf( - parent: AccessibilityNodeInfo, + root: AccessibilityNodeInfo, node: AccessibilityNodeInfo, textQf: Boolean?, ): Boolean? { val viewText = node.text if (viewText == null || viewText.isEmpty()) return null if (textQf == false) return false - return parent.findAccessibilityNodeInfosByText(viewText.toString()) + return root.findAccessibilityNodeInfosByText(viewText.toString()) .any { n -> n == node } } fun abNodeToNode( - parentAbNode: AccessibilityNodeInfo, + rootNodeInfo: AccessibilityNodeInfo, abNode: AccessibilityNodeInfo, id: Int = 0, pid: Int = -1, @@ -64,13 +64,13 @@ data class NodeInfo( // 兄弟节点的可查找性一致 // id 和 text 的可查找性独立 val idQf = getIdQf( - parentAbNode, + rootNodeInfo, abNode, if (parent?.idQf == false) false else brother?.idQf, ) return NodeInfo( id = id, pid = pid, index = index, idQf = idQf, textQf = getTextQf( - parentAbNode, abNode, + rootNodeInfo, abNode, idQf, ), attr = AttrInfo.info2data(abNode, index, depth) ) @@ -101,7 +101,7 @@ data class NodeInfo( val id = list.size stack.push(Tuple3(childNode, id, childDepth)) val simpleNode = abNodeToNode( - top.t0, childNode, id, pid, index, childDepth, list[pid], brother + rootNodeInfo, childNode, id, pid, index, childDepth, list[pid], brother ) list.add(simpleNode) brother = if (simpleNode.idQf != null) {