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
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<Config>(json)?.let {
configList.clear()
configList.addAll(it.read<Array<Config>>("$"))
}
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<Config>(json)?.let {
configList.clear()
configList.addAll(it)
}
}
data class Config(

Loading…
Cancel
Save