From ca57577711f1fe550dd07b350b0edaebeced51f9 Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 9 Jul 2021 17:26:19 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/model/analyzeRule/RuleAnalyzer.kt | 39 +++++++++---------- 1 file changed, 18 insertions(+), 21 deletions(-) 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 a464ea746..a6019cc2c 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 @@ -115,13 +115,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 //嵌套深度 @@ -139,11 +139,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) { @@ -323,10 +323,10 @@ 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) @@ -383,10 +383,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) @@ -409,10 +406,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 { startX = pos //设置规则起点 From f75738f685ccb16128eaa099650276858ba73ceb Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 9 Jul 2021 17:28:53 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/io/legado/app/model/analyzeRule/RuleAnalyzer.kt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) 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 a6019cc2c..ebc07b6b6 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 @@ -323,10 +323,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) From 8b8f362248df611b39851059271f4ca97de66d5e Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 9 Jul 2021 18:11:34 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 +- app/src/main/java/io/legado/app/App.kt | 1 - app/src/main/java/io/legado/app/utils/EventBusExtensions.kt | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) 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/utils/EventBusExtensions.kt b/app/src/main/java/io/legado/app/utils/EventBusExtensions.kt index c0aedf8b3..fb47cde54 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,11 @@ 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 AppCompatActivity.observeEvent( From 4b3750519d678d1563adc1e5ef649b037ebb900c Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 9 Jul 2021 18:21:27 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/utils/EventBusExtensions.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 fb47cde54..a94e7d1aa 100644 --- a/app/src/main/java/io/legado/app/utils/EventBusExtensions.kt +++ b/app/src/main/java/io/legado/app/utils/EventBusExtensions.kt @@ -20,6 +20,10 @@ inline fun postEventDelay(tag: String, event: EVENT, delay: Long LiveEventBus.get(tag).postDelay(event, delay) } +inline fun postEventOrderly(tag: String, event: EVENT) { + LiveEventBus.get(tag).postOrderly(event) +} + inline fun AppCompatActivity.observeEvent( vararg tags: String, noinline observer: (EVENT) -> Unit @@ -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 From 457b864b63af32cc2e08b50b47086b6a35f8d3e4 Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 9 Jul 2021 20:53:26 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/utils/EventBusExtensions.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 a94e7d1aa..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,15 +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) + LiveEventBus.get(tag).postOrderly(event) } inline fun AppCompatActivity.observeEvent(