|
@@ -9,6 +9,7 @@ import io.legado.app.data.entities.ReplaceRule
|
|
|
import io.legado.app.utils.toastOnUi
|
|
import io.legado.app.utils.toastOnUi
|
|
|
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.regex.Pattern
|
|
import java.util.regex.Pattern
|
|
|
|
|
|
|
|
class ContentProcessor private constructor(
|
|
class ContentProcessor private constructor(
|
|
@@ -37,14 +38,13 @@ class ContentProcessor private constructor(
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private val titleReplaceRules = arrayListOf<ReplaceRule>()
|
|
|
|
|
- private val contentReplaceRules = arrayListOf<ReplaceRule>()
|
|
|
|
|
|
|
+ private val titleReplaceRules = CopyOnWriteArrayList<ReplaceRule>()
|
|
|
|
|
+ private val contentReplaceRules = CopyOnWriteArrayList<ReplaceRule>()
|
|
|
|
|
|
|
|
init {
|
|
init {
|
|
|
upReplaceRules()
|
|
upReplaceRules()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Synchronized
|
|
|
|
|
fun upReplaceRules() {
|
|
fun upReplaceRules() {
|
|
|
titleReplaceRules.run {
|
|
titleReplaceRules.run {
|
|
|
clear()
|
|
clear()
|
|
@@ -56,14 +56,12 @@ class ContentProcessor private constructor(
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Synchronized
|
|
|
|
|
- fun getTitleReplaceRules(): Array<ReplaceRule> {
|
|
|
|
|
- return titleReplaceRules.toTypedArray()
|
|
|
|
|
|
|
+ fun getTitleReplaceRules(): List<ReplaceRule> {
|
|
|
|
|
+ return titleReplaceRules
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Synchronized
|
|
|
|
|
- fun getContentReplaceRules(): Array<ReplaceRule> {
|
|
|
|
|
- return contentReplaceRules.toTypedArray()
|
|
|
|
|
|
|
+ fun getContentReplaceRules(): List<ReplaceRule> {
|
|
|
|
|
+ return contentReplaceRules
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
fun getContent(
|
|
fun getContent(
|