From af113619fe462e4c95fb4e5341806204eec28f0a Mon Sep 17 00:00:00 2001 From: lisonge Date: Tue, 24 Oct 2023 15:31:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BF=AB=E7=85=A7=20explicitNulls=3Dtru?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/li/songe/gkd/data/NodeInfo.kt | 2 +- app/src/main/java/li/songe/gkd/debug/SnapshotExt.kt | 2 +- app/src/main/java/li/songe/gkd/util/Singleton.kt | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/li/songe/gkd/data/NodeInfo.kt b/app/src/main/java/li/songe/gkd/data/NodeInfo.kt index 8f18063..9113af6 100644 --- a/app/src/main/java/li/songe/gkd/data/NodeInfo.kt +++ b/app/src/main/java/li/songe/gkd/data/NodeInfo.kt @@ -32,7 +32,7 @@ data class NodeInfo( quickFind: Boolean?, ): Boolean? { // 如果父节点是无法查找的, 则所有子节点都是无法查找的 - // 如果一个节点是可查找的, 则所有兄弟节点都是可查找的(如果满足条件) + // 如果一个节点是可查找的, 则所有兄弟节点及其祖先节点都是可查找的(如果满足条件) return if (nodeInfo != null) { val viewId = nodeInfo.viewIdResourceName if (viewId != null && viewId.isNotEmpty()) { // id='' 不满足查找 diff --git a/app/src/main/java/li/songe/gkd/debug/SnapshotExt.kt b/app/src/main/java/li/songe/gkd/debug/SnapshotExt.kt index 6ada029..2dfe4c8 100644 --- a/app/src/main/java/li/songe/gkd/debug/SnapshotExt.kt +++ b/app/src/main/java/li/songe/gkd/debug/SnapshotExt.kt @@ -112,7 +112,7 @@ object SnapshotExt { val stream = File(getScreenshotPath(snapshot.id)).outputStream() bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream) stream.close() - val text = Singleton.json.encodeToString(snapshot) + val text = Singleton.keepNullJson.encodeToString(snapshot) File(getSnapshotPath(snapshot.id)).writeText(text) DbSet.snapshotDao.insert(snapshot.toSnapshot()) } diff --git a/app/src/main/java/li/songe/gkd/util/Singleton.kt b/app/src/main/java/li/songe/gkd/util/Singleton.kt index 71dfcef..655caad 100644 --- a/app/src/main/java/li/songe/gkd/util/Singleton.kt +++ b/app/src/main/java/li/songe/gkd/util/Singleton.kt @@ -20,6 +20,14 @@ object Singleton { } } + val keepNullJson by lazy { + Json { + isLenient = true + ignoreUnknownKeys = true + encodeDefaults = true + } + } + val client by lazy { HttpClient(OkHttp) { install(ContentNegotiation) {