feat: 优化代码

pull/133/head
kunfei 5 years ago
parent 0ec2172359
commit 5f6e39bc9a
  1. 11
      app/src/main/java/io/legado/app/help/storage/ImportOldData.kt

@ -36,7 +36,7 @@ object ImportOldData {
try {// Book source
val sourceFile =
FileUtils.createFileIfNotExist(file, "myBookSource.json")
FileUtils.getFile(file, "myBookSource.json")
val json = sourceFile.readText()
val importCount = importOldSource(json)
withContext(Dispatchers.Main) {
@ -49,13 +49,18 @@ object ImportOldData {
}
try {// Replace rules
val ruleFile =
FileUtils.createFileIfNotExist(file, "myBookReplaceRule.json")
val ruleFile = FileUtils.getFile(file, "myBookReplaceRule.json")
if (ruleFile.exists()) {
val json = ruleFile.readText()
val importCount = importOldReplaceRule(json)
withContext(Dispatchers.Main) {
context.toast("成功导入替换规则${importCount}")
}
} else {
withContext(Dispatchers.Main) {
context.toast("未找到替换规则")
}
}
} catch (e: Exception) {
withContext(Dispatchers.Main) {
context.toast("导入替换规则失败\n${e.localizedMessage}")

Loading…
Cancel
Save