diff --git a/app/build.gradle b/app/build.gradle index 71aab6b30..6fffeb722 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -162,7 +162,7 @@ dependencies { testImplementation "androidx.room:room-testing:$room_version" //liveEventBus - implementation 'com.jeremyliao:live-event-bus-x:1.5.7' + implementation 'io.github.jeremyliao:live-event-bus-x:1.8.0' //协程 def coroutines_version = '1.4.3' diff --git a/app/src/main/java/io/legado/app/App.kt b/app/src/main/java/io/legado/app/App.kt index 5791d7007..019325cd0 100644 --- a/app/src/main/java/io/legado/app/App.kt +++ b/app/src/main/java/io/legado/app/App.kt @@ -26,7 +26,6 @@ class App : MultiDexApplication() { createNotificationChannels() applyDayNight(this) LiveEventBus.config() - .supportBroadcast(this) .lifecycleObserverAlwaysActive(true) .autoClear(false) registerActivityLifecycleCallbacks(ActivityHelp) diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/RuleAnalyzer.kt b/app/src/main/java/io/legado/app/model/analyzeRule/RuleAnalyzer.kt index 414b0d891..d4b220f04 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/RuleAnalyzer.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/RuleAnalyzer.kt @@ -92,13 +92,13 @@ class RuleAnalyzer(data: String, code: Boolean = false) { //其中js只要符合语法,就不用避开任何阅读关键字,自由发挥 fun chompJsBalanced( - f: ((Char) -> Boolean?) = { - when (it) { - '{' -> true //开始嵌套一层 - '}' -> false //闭合一层嵌套 - else -> null - } + f: ((Char) -> Boolean?) = { + when (it) { + '{' -> true //开始嵌套一层 + '}' -> false //闭合一层嵌套 + else -> null } + } ): Boolean { var pos = pos //声明变量记录临时处理位置 var depth = 0 //嵌套深度 @@ -116,11 +116,11 @@ class RuleAnalyzer(data: String, code: Boolean = false) { var c = queue[pos++] if (c != '\\') { //非转义字符 if (c == '\'' && !commits && !commit && !regex && !inDoubleQuote && !inOtherQuote) inSingleQuote = - !inSingleQuote //匹配具有语法功能的单引号 + !inSingleQuote //匹配具有语法功能的单引号 else if (c == '"' && !commits && !commit && !regex && !inSingleQuote && !inOtherQuote) inDoubleQuote = - !inDoubleQuote //匹配具有语法功能的双引号 + !inDoubleQuote //匹配具有语法功能的双引号 else if (c == '`' && !commits && !commit && !regex && !inSingleQuote && !inDoubleQuote) inOtherQuote = - !inOtherQuote //匹配具有语法功能的'`' + !inOtherQuote //匹配具有语法功能的'`' else if (c == '/' && !commits && !commit && !regex && !inSingleQuote && !inDoubleQuote && !inOtherQuote) { //匹配注释或正则起点 c = queue[pos++] when (c) { @@ -300,10 +300,7 @@ class RuleAnalyzer(data: String, code: Boolean = false) { val next = if (queue[pos] == '[') ']' else ')' //平衡组末尾字符 if (!chompBalanced(queue[pos], next)) throw Error( - queue.substring( - 0, - start - ) + "后未平衡" + queue.substring(0, start) + "后未平衡" ) //拉出一个筛选器,不平衡则报错 } while (end > pos) @@ -360,10 +357,7 @@ class RuleAnalyzer(data: String, code: Boolean = false) { val next = if (queue[pos] == '[') ']' else ')' //平衡组末尾字符 if (!chompBalanced(queue[pos], next)) throw Error( - queue.substring( - 0, - start - ) + "后未平衡" + queue.substring(0, start) + "后未平衡" ) //拉出一个筛选器,不平衡则报错 } while (end > pos) @@ -386,10 +380,10 @@ class RuleAnalyzer(data: String, code: Boolean = false) { * * */ fun innerRule( - inner: String, - startStep: Int = 1, - endStep: Int = 1, - fr: (String) -> String? + inner: String, + startStep: Int = 1, + endStep: Int = 1, + fr: (String) -> String? ): String { val st = StringBuilder() diff --git a/app/src/main/java/io/legado/app/utils/EventBusExtensions.kt b/app/src/main/java/io/legado/app/utils/EventBusExtensions.kt index c0aedf8b3..0293e4893 100644 --- a/app/src/main/java/io/legado/app/utils/EventBusExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/EventBusExtensions.kt @@ -13,11 +13,15 @@ inline fun eventObservable(tag: String): Observable { } inline fun postEvent(tag: String, event: EVENT) { - LiveEventBus.get(tag).post(event) + LiveEventBus.get(tag).post(event) } inline fun postEventDelay(tag: String, event: EVENT, delay: Long) { - LiveEventBus.get(tag).postDelay(event, delay) + LiveEventBus.get(tag).postDelay(event, delay) +} + +inline fun postEventOrderly(tag: String, event: EVENT) { + LiveEventBus.get(tag).postOrderly(event) } inline fun AppCompatActivity.observeEvent( @@ -32,7 +36,6 @@ inline fun AppCompatActivity.observeEvent( } } - inline fun AppCompatActivity.observeEventSticky( vararg tags: String, noinline observer: (EVENT) -> Unit @@ -67,5 +70,4 @@ inline fun Fragment.observeEventSticky( tags.forEach { eventObservable(it).observeSticky(this, o) } -} - +} \ No newline at end of file