优化
This commit is contained in:
@@ -16,6 +16,7 @@ import io.legado.app.help.config.AppConfig
|
|||||||
import io.legado.app.model.analyzeRule.AnalyzeUrl
|
import io.legado.app.model.analyzeRule.AnalyzeUrl
|
||||||
import io.legado.app.model.analyzeRule.RuleDataInterface
|
import io.legado.app.model.analyzeRule.RuleDataInterface
|
||||||
import io.legado.app.utils.*
|
import io.legado.app.utils.*
|
||||||
|
import kotlinx.coroutines.CancellationException
|
||||||
import kotlinx.parcelize.IgnoredOnParcel
|
import kotlinx.parcelize.IgnoredOnParcel
|
||||||
import kotlinx.parcelize.Parcelize
|
import kotlinx.parcelize.Parcelize
|
||||||
import splitties.init.appCtx
|
import splitties.init.appCtx
|
||||||
@@ -113,6 +114,8 @@ data class BookChapter(
|
|||||||
} catch (e: RegexTimeoutException) {
|
} catch (e: RegexTimeoutException) {
|
||||||
item.isEnabled = false
|
item.isEnabled = false
|
||||||
appDb.replaceRuleDao.update(item)
|
appDb.replaceRuleDao.update(item)
|
||||||
|
} catch (e: CancellationException) {
|
||||||
|
return displayTitle
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
AppLog.put("${item.name}替换出错\n替换内容\n${displayTitle}", e)
|
AppLog.put("${item.name}替换出错\n替换内容\n${displayTitle}", e)
|
||||||
appCtx.toastOnUi("${item.name}替换出错")
|
appCtx.toastOnUi("${item.name}替换出错")
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import io.legado.app.help.config.ReadBookConfig
|
|||||||
import io.legado.app.utils.msg
|
import io.legado.app.utils.msg
|
||||||
import io.legado.app.utils.replace
|
import io.legado.app.utils.replace
|
||||||
import io.legado.app.utils.toastOnUi
|
import io.legado.app.utils.toastOnUi
|
||||||
|
import kotlinx.coroutines.CancellationException
|
||||||
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
|
||||||
@@ -135,7 +136,7 @@ class ContentProcessor private constructor(
|
|||||||
var mContent = content
|
var mContent = content
|
||||||
getContentReplaceRules().forEach { item ->
|
getContentReplaceRules().forEach { item ->
|
||||||
if (item.pattern.isNotEmpty()) {
|
if (item.pattern.isNotEmpty()) {
|
||||||
kotlin.runCatching {
|
try {
|
||||||
mContent = if (item.isRegex) {
|
mContent = if (item.isRegex) {
|
||||||
mContent.replace(
|
mContent.replace(
|
||||||
item.pattern.toRegex(),
|
item.pattern.toRegex(),
|
||||||
@@ -145,21 +146,18 @@ class ContentProcessor private constructor(
|
|||||||
} else {
|
} else {
|
||||||
mContent.replace(item.pattern, item.replacement)
|
mContent.replace(item.pattern, item.replacement)
|
||||||
}
|
}
|
||||||
}.onFailure {
|
} catch (e: RegexTimeoutException) {
|
||||||
when (it) {
|
|
||||||
is RegexTimeoutException -> {
|
|
||||||
item.isEnabled = false
|
item.isEnabled = false
|
||||||
appDb.replaceRuleDao.update(item)
|
appDb.replaceRuleDao.update(item)
|
||||||
return item.name + it.msg
|
return item.name + e.msg
|
||||||
}
|
} catch (e: CancellationException) {
|
||||||
else -> {
|
return mContent
|
||||||
AppLog.put("${item.name}替换出错\n替换内容\n${mContent}", it)
|
} catch (e: Exception) {
|
||||||
|
AppLog.put("${item.name}替换出错\n替换内容\n${mContent}", e)
|
||||||
appCtx.toastOnUi("${item.name}替换出错")
|
appCtx.toastOnUi("${item.name}替换出错")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return mContent
|
return mContent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user