|
|
@ -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 titleReplaceRules = CopyOnWriteArrayList<ReplaceRule>() |
|
|
|
private val contentReplaceRules = arrayListOf<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(): List<ReplaceRule> { |
|
|
|
fun getTitleReplaceRules(): Array<ReplaceRule> { |
|
|
|
return titleReplaceRules |
|
|
|
return titleReplaceRules.toTypedArray() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Synchronized |
|
|
|
fun getContentReplaceRules(): List<ReplaceRule> { |
|
|
|
fun getContentReplaceRules(): Array<ReplaceRule> { |
|
|
|
return contentReplaceRules |
|
|
|
return contentReplaceRules.toTypedArray() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun getContent( |
|
|
|
fun getContent( |
|
|
|