From 59c42c4506aff0558a25dd1a27086c02eb2f1c6d Mon Sep 17 00:00:00 2001 From: Jason Yao Date: Fri, 20 Aug 2021 16:14:04 -0400 Subject: [PATCH 1/6] =?UTF-8?q?=E5=A4=9A=E7=BA=BF=E7=A8=8B=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=A0=A1=E9=AA=8C=E8=AF=A6=E7=BB=86=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 用flow每300ms刷新,去除eventbus的使用 --- .../main/java/io/legado/app/model/Debug.kt | 53 +++++++++++-------- .../legado/app/service/CheckSourceService.kt | 23 ++------ .../book/source/debug/BookSourceDebugModel.kt | 2 - .../book/source/manage/BookSourceActivity.kt | 31 +++++++---- .../book/source/manage/BookSourceAdapter.kt | 15 +++--- .../rss/source/debug/RssSourceDebugModel.kt | 2 - .../io/legado/app/web/SourceDebugWebSocket.kt | 4 -- 7 files changed, 66 insertions(+), 64 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/Debug.kt b/app/src/main/java/io/legado/app/model/Debug.kt index cb08cf6f9..36a9ff22d 100644 --- a/app/src/main/java/io/legado/app/model/Debug.kt +++ b/app/src/main/java/io/legado/app/model/Debug.kt @@ -2,6 +2,7 @@ package io.legado.app.model import android.annotation.SuppressLint import io.legado.app.data.entities.* +import io.legado.app.help.AppConfig import io.legado.app.help.coroutine.CompositeCoroutine import io.legado.app.model.rss.Rss import io.legado.app.model.webBook.WebBook @@ -11,14 +12,15 @@ import io.legado.app.utils.msg import kotlinx.coroutines.CoroutineScope import java.text.SimpleDateFormat import java.util.* -import java.util.concurrent.ConcurrentHashMap +import kotlin.collections.HashMap object Debug { var callback: Callback? = null private var debugSource: String? = null private val tasks: CompositeCoroutine = CompositeCoroutine() - val debugMessageMap = ConcurrentHashMap() - private var isChecking: Boolean = false + val debugMessageMap = HashMap() + private val debugTimeMap = HashMap() + var isChecking: Boolean = false @SuppressLint("ConstantLocale") private val DEBUG_TIME_FORMAT = SimpleDateFormat("[mm:ss.SSS]", Locale.getDefault()) @@ -33,20 +35,30 @@ object Debug { showTime: Boolean = true, state: Int = 1 ) { - callback?.let { - if ((debugSource != sourceUrl || !print) && !isChecking) return - var printMsg = msg ?: "" - if (isHtml) { - printMsg = HtmlFormatter.format(msg) - } - if (showTime) { - val time = DEBUG_TIME_FORMAT.format(Date(System.currentTimeMillis() - startTime)) - printMsg = "$time $printMsg" - } - it.printLog(state, printMsg) - if (sourceUrl != null && printMsg.length < 30) { - debugMessageMap[sourceUrl] = printMsg - callback?.postCheckMessageEvent(sourceUrl) + if (AppConfig.checkSourceMessage) { + if (isChecking && sourceUrl != null && (msg ?: "").length < 30) { + var printMsg = msg ?: "" + if (isHtml) { + printMsg = HtmlFormatter.format(msg) + } + if (showTime && debugTimeMap[sourceUrl] != null) { + val time = DEBUG_TIME_FORMAT.format(Date(System.currentTimeMillis() - debugTimeMap[sourceUrl]!!)) + printMsg = "$time $printMsg" + debugMessageMap[sourceUrl] = printMsg + } + } else { + callback?.let { + if ((debugSource != sourceUrl || !print)) return + var printMsg = msg ?: "" + if (isHtml) { + printMsg = HtmlFormatter.format(msg) + } + if (showTime) { + val time = DEBUG_TIME_FORMAT.format(Date(System.currentTimeMillis() - startTime)) + printMsg = "$time $printMsg" + } + it.printLog(state, printMsg) + } } } } @@ -66,13 +78,12 @@ object Debug { } fun startChecking(source: BookSource) { - startTime = System.currentTimeMillis() isChecking = true - debugMessageMap[source.bookSourceUrl] = "开始校验" + debugTimeMap[source.bookSourceUrl] = System.currentTimeMillis() + debugMessageMap[source.bookSourceUrl] = "${DEBUG_TIME_FORMAT.format(Date(0))} 开始校验" } fun finishChecking() { - callback = null isChecking = false } @@ -261,7 +272,5 @@ object Debug { interface Callback { fun printLog(state: Int, msg: String) - fun postCheckMessageEvent(sourceUrl: String) } - } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/service/CheckSourceService.kt b/app/src/main/java/io/legado/app/service/CheckSourceService.kt index c788fae58..945f0eda3 100644 --- a/app/src/main/java/io/legado/app/service/CheckSourceService.kt +++ b/app/src/main/java/io/legado/app/service/CheckSourceService.kt @@ -30,7 +30,7 @@ class CheckSourceService : BaseService() { private val checkedIds = ArrayList() private var processIndex = 0 private var notificationMsg = "" - private var debugCallback : Debug.Callback? = null + private val showCheckSourceMessage = AppConfig.checkSourceMessage private val notificationBuilder by lazy { NotificationCompat.Builder(this, AppConst.channelIdReadAloud) .setSmallIcon(R.drawable.ic_network_check) @@ -50,18 +50,6 @@ class CheckSourceService : BaseService() { override fun onCreate() { super.onCreate() notificationMsg = getString(R.string.start) - if (AppConfig.checkSourceMessage) { - debugCallback = object : Debug.Callback { - override fun printLog(state: Int, msg: String) {} - - @Synchronized - override fun postCheckMessageEvent(sourceUrl: String) { - postEvent(EventBus.CHECK_SOURCE_MESSAGE, sourceUrl) - } - } - Debug.callback = debugCallback - threadCount = 1 - } upNotification() } @@ -120,7 +108,7 @@ class CheckSourceService : BaseService() { fun check(source: BookSource) { execute(context = searchCoroutine) { - if (AppConfig.checkSourceMessage) { + if (showCheckSourceMessage) { Debug.startChecking(source) } val webBook = WebBook(source) @@ -152,9 +140,8 @@ class CheckSourceService : BaseService() { "error:${it.localizedMessage} ${source.bookSourceComment}" """.trimIndent() - debugCallback?.let { + if (showCheckSourceMessage) { Debug.debugMessageMap[source.bookSourceUrl] = Debug.debugMessageMap[source.bookSourceUrl] + " 失败" - postEvent(EventBus.CHECK_SOURCE_MESSAGE, source.bookSourceUrl) } appDb.bookSourceDao.update(source) }.onSuccess(searchCoroutine) { @@ -164,11 +151,9 @@ class CheckSourceService : BaseService() { ?.filterNot { it.startsWith("error:") }?.joinToString("\n") - debugCallback?.let { debugCallback + if (showCheckSourceMessage) { Debug.debugMessageMap[source.bookSourceUrl] = Debug.debugMessageMap[source.bookSourceUrl] + " 成功" - postEvent(EventBus.CHECK_SOURCE_MESSAGE, source.bookSourceUrl) } - appDb.bookSourceDao.update(source) }.onFinally(searchCoroutine) { onNext(source.bookSourceUrl, source.bookSourceName) diff --git a/app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugModel.kt b/app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugModel.kt index 7d79dfca2..991591029 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/debug/BookSourceDebugModel.kt @@ -51,8 +51,6 @@ class BookSourceDebugModel(application: Application) : BaseViewModel(application } } - override fun postCheckMessageEvent(sourceUrl: String) {} - override fun onCleared() { super.onCleared() Debug.cancelDebug(true) diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt index a107c178b..108aaa387 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt @@ -21,6 +21,7 @@ import io.legado.app.data.appDb import io.legado.app.data.entities.BookSource import io.legado.app.databinding.ActivityBookSourceBinding import io.legado.app.databinding.DialogEditTextBinding +import io.legado.app.help.AppConfig import io.legado.app.help.LocalConfig import io.legado.app.lib.dialogs.alert import io.legado.app.lib.theme.ATH @@ -40,9 +41,8 @@ import io.legado.app.ui.widget.recycler.ItemTouchCallback import io.legado.app.ui.widget.recycler.VerticalDivider import io.legado.app.utils.* import io.legado.app.utils.viewbindingdelegate.viewBinding -import kotlinx.coroutines.Job +import kotlinx.coroutines.* import kotlinx.coroutines.flow.* -import kotlinx.coroutines.launch import java.io.File class BookSourceActivity : VMBaseActivity(), @@ -340,6 +340,9 @@ class BookSourceActivity : VMBaseActivity(EventBus.CHECK_SOURCE_MESSAGE) { bookSourceUrl -> - sourceFlowJob?.cancel() - sourceFlowJob = launch { - appDb.bookSourceDao.flowSearch(bookSourceUrl) - .map { adapter.getItems().indexOf(it[0]) } - .collect { - adapter.notifyItemChanged(it, bundleOf(Pair(EventBus.CHECK_SOURCE_MESSAGE, null))) } + } + + private fun checkMessageRefreshJob(): Job { + val firstIndex = adapter.getItems().indexOf(adapter.selection.first()) + val lastIndex = adapter.getItems().indexOf(adapter.selection.last()) + Debug.isChecking = true + return async(start = CoroutineStart.LAZY) { + flow { + while (true) { + emit(Debug.isChecking) + delay(300L) } + }.collect { + adapter.notifyItemRangeChanged(firstIndex, lastIndex + 1, bundleOf(Pair("checkSourceMessage", null))) + if (!it) { + this.cancel() + } + } } } diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt index 7e0937b3c..4a20c7818 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt @@ -13,7 +13,6 @@ import androidx.recyclerview.widget.RecyclerView import io.legado.app.R import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.RecyclerAdapter -import io.legado.app.constant.EventBus import io.legado.app.data.entities.BookSource import io.legado.app.databinding.ItemBookSourceBinding import io.legado.app.lib.theme.backgroundColor @@ -115,11 +114,15 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) : } else { payload.keySet().map { when (it) { - "selected" -> cbBookSource.isChecked = selected.contains(item) - EventBus.CHECK_SOURCE_MESSAGE -> { - ivDebugText.text = Debug.debugMessageMap[item.bookSourceUrl] ?: "" - ivDebugText.visibility = if(ivDebugText.text.toString().length > 1) View.VISIBLE else View.GONE - ivProgressBar.visibility = if(ivDebugText.text.toString().contains(Regex("成功|失败"))) View.GONE else View.VISIBLE + "selected" -> cbBookSource.isChecked = selected.contains(item) + "checkSourceMessage" -> { + ivDebugText.text = Debug.debugMessageMap[item.bookSourceUrl] ?: "" + val isEmpty = ivDebugText.text.toString().isEmpty() + ivDebugText.visibility = + if (!isEmpty) View.VISIBLE else View.GONE + ivProgressBar.visibility = + if (ivDebugText.text.toString().contains(Regex("成功|失败")) || isEmpty) View.GONE + else View.VISIBLE } } } diff --git a/app/src/main/java/io/legado/app/ui/rss/source/debug/RssSourceDebugModel.kt b/app/src/main/java/io/legado/app/ui/rss/source/debug/RssSourceDebugModel.kt index 5d0ada568..23892dc6f 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/debug/RssSourceDebugModel.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/debug/RssSourceDebugModel.kt @@ -44,8 +44,6 @@ class RssSourceDebugModel(application: Application) : BaseViewModel(application) } } - override fun postCheckMessageEvent(sourceUrl: String) {} - override fun onCleared() { super.onCleared() Debug.cancelDebug(true) diff --git a/app/src/main/java/io/legado/app/web/SourceDebugWebSocket.kt b/app/src/main/java/io/legado/app/web/SourceDebugWebSocket.kt index 534a68b47..c2c2f893f 100644 --- a/app/src/main/java/io/legado/app/web/SourceDebugWebSocket.kt +++ b/app/src/main/java/io/legado/app/web/SourceDebugWebSocket.kt @@ -95,8 +95,4 @@ class SourceDebugWebSocket(handshakeRequest: NanoHTTPD.IHTTPSession) : } } - override fun postCheckMessageEvent(sourceUrl: String) { - TODO("Not yet implemented") - } - } From 4e33e262ff271b57345f678137332552f7883fd9 Mon Sep 17 00:00:00 2001 From: Jason Yao Date: Fri, 20 Aug 2021 17:00:31 -0400 Subject: [PATCH 2/6] =?UTF-8?q?snack=20bar=20=E5=8F=96=E6=B6=88=E6=97=B6?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/model/Debug.kt | 8 ++++++++ .../java/io/legado/app/service/CheckSourceService.kt | 5 +++-- .../app/ui/book/source/manage/BookSourceActivity.kt | 5 ++++- .../app/ui/book/source/manage/BookSourceAdapter.kt | 9 +++++++-- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/Debug.kt b/app/src/main/java/io/legado/app/model/Debug.kt index 36a9ff22d..e30373143 100644 --- a/app/src/main/java/io/legado/app/model/Debug.kt +++ b/app/src/main/java/io/legado/app/model/Debug.kt @@ -87,6 +87,14 @@ object Debug { isChecking = false } + fun updateFinalMessage(sourceUrl: String, state: String) { + if (debugTimeMap[sourceUrl] != null && debugMessageMap[sourceUrl] != null) { + val time = DEBUG_TIME_FORMAT.format(Date(System.currentTimeMillis() - debugTimeMap[sourceUrl]!!)) + val originalMessage = debugMessageMap[sourceUrl]!!.substringAfter("] ") + debugMessageMap[sourceUrl] = "$time $originalMessage $state" + } + } + fun startDebug(scope: CoroutineScope, rssSource: RssSource) { cancelDebug() debugSource = rssSource.sourceUrl diff --git a/app/src/main/java/io/legado/app/service/CheckSourceService.kt b/app/src/main/java/io/legado/app/service/CheckSourceService.kt index 945f0eda3..66fcf24fc 100644 --- a/app/src/main/java/io/legado/app/service/CheckSourceService.kt +++ b/app/src/main/java/io/legado/app/service/CheckSourceService.kt @@ -65,6 +65,7 @@ class CheckSourceService : BaseService() { override fun onDestroy() { super.onDestroy() + Debug.finishChecking() tasks.clear() searchCoroutine.close() postEvent(EventBus.CHECK_SOURCE_DONE, 0) @@ -141,7 +142,7 @@ class CheckSourceService : BaseService() { ${source.bookSourceComment}" """.trimIndent() if (showCheckSourceMessage) { - Debug.debugMessageMap[source.bookSourceUrl] = Debug.debugMessageMap[source.bookSourceUrl] + " 失败" + Debug.updateFinalMessage(source.bookSourceUrl, "失败") } appDb.bookSourceDao.update(source) }.onSuccess(searchCoroutine) { @@ -152,7 +153,7 @@ class CheckSourceService : BaseService() { it.startsWith("error:") }?.joinToString("\n") if (showCheckSourceMessage) { - Debug.debugMessageMap[source.bookSourceUrl] = Debug.debugMessageMap[source.bookSourceUrl] + " 成功" + Debug.updateFinalMessage(source.bookSourceUrl, "成功") } appDb.bookSourceDao.update(source) }.onFinally(searchCoroutine) { diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt index 108aaa387..b16753e0a 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt @@ -435,11 +435,14 @@ class BookSourceActivity : VMBaseActivity(EventBus.CHECK_SOURCE_DONE) { - Debug.finishChecking() snackBar?.dismiss() snackBar = null groups.map { group -> diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt index 4a20c7818..6b5b8e845 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceAdapter.kt @@ -118,11 +118,16 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) : "checkSourceMessage" -> { ivDebugText.text = Debug.debugMessageMap[item.bookSourceUrl] ?: "" val isEmpty = ivDebugText.text.toString().isEmpty() + var isFinalMessage = ivDebugText.text.toString().contains(Regex("成功|失败")) + if (!isEmpty && !Debug.isChecking && !isFinalMessage){ + Debug.updateFinalMessage(item.bookSourceUrl, "失败") + ivDebugText.text = Debug.debugMessageMap[item.bookSourceUrl] ?: "" + isFinalMessage = true + } ivDebugText.visibility = if (!isEmpty) View.VISIBLE else View.GONE ivProgressBar.visibility = - if (ivDebugText.text.toString().contains(Regex("成功|失败")) || isEmpty) View.GONE - else View.VISIBLE + if (isFinalMessage || isEmpty) View.GONE else View.VISIBLE } } } From eba8d353cfb17fa2decf3de90a3b108632b3966f Mon Sep 17 00:00:00 2001 From: Jason Yao Date: Fri, 20 Aug 2021 17:06:15 -0400 Subject: [PATCH 3/6] =?UTF-8?q?=E6=9B=B4=E6=96=B0string?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/res/values-es-rES/strings.xml | 2 +- app/src/main/res/values-ja-rJP/strings.xml | 2 +- app/src/main/res/values-pt-rBR/strings.xml | 2 +- app/src/main/res/values-zh-rHK/strings.xml | 2 +- app/src/main/res/values-zh-rTW/strings.xml | 2 +- app/src/main/res/values-zh/strings.xml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/res/values-es-rES/strings.xml b/app/src/main/res/values-es-rES/strings.xml index 216dd64f1..f7d66e2cc 100644 --- a/app/src/main/res/values-es-rES/strings.xml +++ b/app/src/main/res/values-es-rES/strings.xml @@ -854,5 +854,5 @@ 上一段|下一段/上一章|下一章 及时翻页,翻页时会停顿一下 La fuente del libro de cheques muestra un mensaje de depuración - Muestra los pasos y el tiempo de la solicitud de red durante la verificación de la fuente del libro; actualmente solo admite la verificación de un solo hilo + Muestra los pasos y el tiempo de la solicitud de red durante la verificación de la fuente del libro diff --git a/app/src/main/res/values-ja-rJP/strings.xml b/app/src/main/res/values-ja-rJP/strings.xml index 081b09ee5..b97574e03 100644 --- a/app/src/main/res/values-ja-rJP/strings.xml +++ b/app/src/main/res/values-ja-rJP/strings.xml @@ -855,5 +855,5 @@ 上一段|下一段/上一章|下一章 及时翻页,翻页时会停顿一下 Check book source shows debug message - Show network status and timestamp during source checking, currently only supports single-thread + Show network status and timestamp during source checking diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 03cdc19b9..b043ada60 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -854,5 +854,5 @@ 上一段|下一段/上一章|下一章 及时翻页,翻页时会停顿一下 Verificar a fonte do livro mostra uma mensagem de depuração - Exibir etapas de solicitação de rede e tempo durante a verificação da fonte do livro; atualmente, oferece suporte apenas à verificação de thread único + Exibir etapas de solicitação de rede e tempo durante a verificação da fonte do livro diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index aea6f7aae..ae8c19bce 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -856,6 +856,6 @@ 上一段|下一段/上一章|下一章 及时翻页,翻页时会停顿一下 校驗書源顯示詳細信息 - 書源校驗時顯示網絡請求步驟和時間,當前只支持單線程校驗 + 書源校驗時顯示網絡請求步驟和時間 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index d5984a40f..13f7cd8e6 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -857,6 +857,6 @@ 上一段|下一段/上一章|下一章 及时翻页,翻页时会停顿一下 校驗書源顯示詳細信息 - 書源校驗時顯示網絡請求步驟和時間,當前只支持單線程校驗 + 書源校驗時顯示網絡請求步驟和時間 diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index bae9c5131..cfb947d90 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -858,6 +858,6 @@ 上一段|下一段/上一章|下一章 及时翻页,翻页时会停顿一下 校验显示详细信息 - 书源校验时显示网络请求步骤和时间,当前只支持单线程校验 + 书源校验时显示网络请求步骤和时间 From 0531c88a6daca6c8dc9c0552c8e97751bc8de300 Mon Sep 17 00:00:00 2001 From: Jason Yao Date: Fri, 20 Aug 2021 17:06:42 -0400 Subject: [PATCH 4/6] Update strings.xml --- app/src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b721a2de9..92ca027b1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -859,6 +859,6 @@ 上一段|下一段/上一章|下一章 及时翻页,翻页时会停顿一下 Check book source shows debug message - Show network status and timestamp during source checking, currently only supports single-thread + Show network status and timestamp during source checking From c7983b8d449aa1eda3255e25e2807bb7c2f685a5 Mon Sep 17 00:00:00 2001 From: Jason Yao Date: Fri, 20 Aug 2021 17:12:55 -0400 Subject: [PATCH 5/6] Update Debug.kt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 防止影响到调试功能 --- app/src/main/java/io/legado/app/model/Debug.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/Debug.kt b/app/src/main/java/io/legado/app/model/Debug.kt index e30373143..12e99d95b 100644 --- a/app/src/main/java/io/legado/app/model/Debug.kt +++ b/app/src/main/java/io/legado/app/model/Debug.kt @@ -35,8 +35,8 @@ object Debug { showTime: Boolean = true, state: Int = 1 ) { - if (AppConfig.checkSourceMessage) { - if (isChecking && sourceUrl != null && (msg ?: "").length < 30) { + if (AppConfig.checkSourceMessage && isChecking) { + if (sourceUrl != null && (msg ?: "").length < 30) { var printMsg = msg ?: "" if (isHtml) { printMsg = HtmlFormatter.format(msg) From cfa613b5db7614cc3471a1b0f0a45139ab2d5601 Mon Sep 17 00:00:00 2001 From: Jason Yao Date: Fri, 20 Aug 2021 21:07:19 -0400 Subject: [PATCH 6/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0timeout?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/source/manage/BookSourceActivity.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt index b16753e0a..4db5082bd 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt @@ -44,6 +44,7 @@ import io.legado.app.utils.viewbindingdelegate.viewBinding import kotlinx.coroutines.* import kotlinx.coroutines.flow.* import java.io.File +import kotlin.math.min class BookSourceActivity : VMBaseActivity(), PopupMenu.OnMenuItemClickListener, @@ -457,16 +458,19 @@ class BookSourceActivity : VMBaseActivity (600 * (lastIndex + 1 - firstIndex) / min(AppConfig.threadCount,8)))) { + Debug.finishChecking() this.cancel() } }