Skip to content

Commit

Permalink
fix: 快照 explicitNulls=true
Browse files Browse the repository at this point in the history
  • Loading branch information
lisonge committed Oct 24, 2023
1 parent 83677ea commit af11361
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/li/songe/gkd/data/NodeInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ data class NodeInfo(
quickFind: Boolean?,
): Boolean? {
// 如果父节点是无法查找的, 则所有子节点都是无法查找的
// 如果一个节点是可查找的, 则所有兄弟节点都是可查找的(如果满足条件)
// 如果一个节点是可查找的, 则所有兄弟节点及其祖先节点都是可查找的(如果满足条件)
return if (nodeInfo != null) {
val viewId = nodeInfo.viewIdResourceName
if (viewId != null && viewId.isNotEmpty()) { // id='' 不满足查找
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/li/songe/gkd/debug/SnapshotExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/java/li/songe/gkd/util/Singleton.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit af11361

Please sign in to comment.