|
|
@ -20,6 +20,8 @@ import java.io.IOException |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
object ReadBookConfig { |
|
|
|
object ReadBookConfig { |
|
|
|
const val readConfigFileName = "readConfig.json" |
|
|
|
const val readConfigFileName = "readConfig.json" |
|
|
|
|
|
|
|
private val configFilePath = |
|
|
|
|
|
|
|
App.INSTANCE.filesDir.absolutePath + File.separator + readConfigFileName |
|
|
|
val configList: ArrayList<Config> = arrayListOf() |
|
|
|
val configList: ArrayList<Config> = arrayListOf() |
|
|
|
|
|
|
|
|
|
|
|
var styleSelect |
|
|
|
var styleSelect |
|
|
@ -40,8 +42,7 @@ object ReadBookConfig { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun upConfig() { |
|
|
|
fun upConfig() { |
|
|
|
val configFile = |
|
|
|
val configFile = File(configFilePath) |
|
|
|
File(App.INSTANCE.filesDir.absolutePath + File.separator + readConfigFileName) |
|
|
|
|
|
|
|
val json = if (configFile.exists()) { |
|
|
|
val json = if (configFile.exists()) { |
|
|
|
configFile.readText() |
|
|
|
configFile.readText() |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -68,8 +69,7 @@ object ReadBookConfig { |
|
|
|
fun save() { |
|
|
|
fun save() { |
|
|
|
GlobalScope.launch(IO) { |
|
|
|
GlobalScope.launch(IO) { |
|
|
|
val json = GSON.toJson(configList) |
|
|
|
val json = GSON.toJson(configList) |
|
|
|
val configFile = |
|
|
|
val configFile = File(configFilePath) |
|
|
|
File(App.INSTANCE.filesDir.absolutePath + File.separator + readConfigFileName) |
|
|
|
|
|
|
|
//获取流并存储 |
|
|
|
//获取流并存储 |
|
|
|
try { |
|
|
|
try { |
|
|
|
BufferedWriter(FileWriter(configFile)).use { writer -> |
|
|
|
BufferedWriter(FileWriter(configFile)).use { writer -> |
|
|
|