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