|
@@ -8,8 +8,8 @@ import io.legado.app.data.entities.BookChapter
|
|
|
import io.legado.app.data.entities.ReplaceRule
|
|
import io.legado.app.data.entities.ReplaceRule
|
|
|
import io.legado.app.help.config.AppConfig
|
|
import io.legado.app.help.config.AppConfig
|
|
|
import io.legado.app.help.config.ReadBookConfig
|
|
import io.legado.app.help.config.ReadBookConfig
|
|
|
|
|
+import io.legado.app.utils.regexReplace
|
|
|
import io.legado.app.utils.toastOnUi
|
|
import io.legado.app.utils.toastOnUi
|
|
|
-import kotlinx.coroutines.withTimeout
|
|
|
|
|
import splitties.init.appCtx
|
|
import splitties.init.appCtx
|
|
|
import java.lang.ref.WeakReference
|
|
import java.lang.ref.WeakReference
|
|
|
import java.util.concurrent.CopyOnWriteArrayList
|
|
import java.util.concurrent.CopyOnWriteArrayList
|
|
@@ -134,12 +134,10 @@ class ContentProcessor private constructor(
|
|
|
getContentReplaceRules().forEach { item ->
|
|
getContentReplaceRules().forEach { item ->
|
|
|
if (item.pattern.isNotEmpty()) {
|
|
if (item.pattern.isNotEmpty()) {
|
|
|
kotlin.runCatching {
|
|
kotlin.runCatching {
|
|
|
- withTimeout(1000) {
|
|
|
|
|
- mContent = if (item.isRegex) {
|
|
|
|
|
- mContent.replace(item.pattern.toRegex(), item.replacement)
|
|
|
|
|
- } else {
|
|
|
|
|
- mContent.replace(item.pattern, item.replacement)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ mContent = if (item.isRegex) {
|
|
|
|
|
+ mContent.regexReplace(item.pattern, item.replacement, 1000L)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ mContent.replace(item.pattern, item.replacement)
|
|
|
}
|
|
}
|
|
|
}.onFailure {
|
|
}.onFailure {
|
|
|
AppLog.put("${item.name}替换出错\n${it.localizedMessage}")
|
|
AppLog.put("${item.name}替换出错\n${it.localizedMessage}")
|