pull/32/head
kunfei 5 years ago
parent 507df7f39d
commit 9a8cb5beb0
  1. 22
      app/src/main/java/io/legado/app/help/ReadBookConfig.kt

@ -1,9 +1,9 @@
package io.legado.app.help package io.legado.app.help
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import com.jayway.jsonpath.JsonPath
import io.legado.app.App import io.legado.app.App
import io.legado.app.utils.GSON import io.legado.app.utils.GSON
import io.legado.app.utils.fromJsonArray
import io.legado.app.utils.getPrefInt import io.legado.app.utils.getPrefInt
import io.legado.app.utils.putPrefInt import io.legado.app.utils.putPrefInt
import java.io.BufferedWriter import java.io.BufferedWriter
@ -25,16 +25,24 @@ object ReadBookConfig {
} else { } else {
String(App.INSTANCE.assets.open("readConfig.json").readBytes()) String(App.INSTANCE.assets.open("readConfig.json").readBytes())
} }
JsonPath.parse(json).let { GSON.fromJsonArray<Config>(json)?.let {
configList.clear() configList.clear()
configList.addAll(it.read<Array<Config>>("$")) configList.addAll(it)
} } ?: reset()
} }
fun getConfig(): Config { fun getConfig(): Config {
return configList[styleSelect] return configList[styleSelect]
} }
fun upBg() {
getConfig().apply {
when (bgType) {
}
}
}
fun save() { fun save() {
val json = GSON.toJson(configList) val json = GSON.toJson(configList)
val configFile = File(App.INSTANCE.filesDir.absolutePath + File.separator + "config") val configFile = File(App.INSTANCE.filesDir.absolutePath + File.separator + "config")
@ -50,7 +58,11 @@ object ReadBookConfig {
} }
fun reset() { fun reset() {
val json = String(App.INSTANCE.assets.open("readConfig.json").readBytes())
GSON.fromJsonArray<Config>(json)?.let {
configList.clear()
configList.addAll(it)
}
} }
data class Config( data class Config(

Loading…
Cancel
Save