pull/478/head
gedoor 4 years ago
parent 8728d4cba1
commit 4c74c85566
  1. 22
      app/src/main/java/io/legado/app/help/ContentProcessor.kt

@ -31,18 +31,16 @@ class ContentProcessor(private val bookName: String, private val bookOrigin: Str
var content1 = content
if (book.getUseReplaceRule()) {
replaceRules.forEach { item ->
item.pattern.let {
if (it.isNotEmpty()) {
try {
content1 = if (item.isRegex) {
content1.replace(it.toRegex(), item.replacement)
} else {
content1.replace(it, item.replacement)
}
} catch (e: Exception) {
withContext(Dispatchers.Main) {
App.INSTANCE.toast("${item.name}替换出错")
}
if (item.pattern.isNotEmpty()) {
try {
content1 = if (item.isRegex) {
content1.replace(item.pattern.toRegex(), item.replacement)
} else {
content1.replace(item.pattern, item.replacement)
}
} catch (e: Exception) {
withContext(Dispatchers.Main) {
App.INSTANCE.toast("${item.name}替换出错")
}
}
}

Loading…
Cancel
Save