From 9a8cb5beb0cab0f77ef0381982560671f90258cc Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 20 Aug 2019 21:53:52 +0800 Subject: [PATCH] up --- .../java/io/legado/app/help/ReadBookConfig.kt | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt index 1d71b603f..e94321e42 100644 --- a/app/src/main/java/io/legado/app/help/ReadBookConfig.kt +++ b/app/src/main/java/io/legado/app/help/ReadBookConfig.kt @@ -1,9 +1,9 @@ package io.legado.app.help import android.graphics.drawable.Drawable -import com.jayway.jsonpath.JsonPath import io.legado.app.App import io.legado.app.utils.GSON +import io.legado.app.utils.fromJsonArray import io.legado.app.utils.getPrefInt import io.legado.app.utils.putPrefInt import java.io.BufferedWriter @@ -25,16 +25,24 @@ object ReadBookConfig { } else { String(App.INSTANCE.assets.open("readConfig.json").readBytes()) } - JsonPath.parse(json).let { + GSON.fromJsonArray(json)?.let { configList.clear() - configList.addAll(it.read>("$")) - } + configList.addAll(it) + } ?: reset() } fun getConfig(): Config { return configList[styleSelect] } + fun upBg() { + getConfig().apply { + when (bgType) { + + } + } + } + fun save() { val json = GSON.toJson(configList) val configFile = File(App.INSTANCE.filesDir.absolutePath + File.separator + "config") @@ -50,7 +58,11 @@ object ReadBookConfig { } fun reset() { - + val json = String(App.INSTANCE.assets.open("readConfig.json").readBytes()) + GSON.fromJsonArray(json)?.let { + configList.clear() + configList.addAll(it) + } } data class Config(