From e3c7e8d0c4bf904c7d990f25745b035d3b1e8369 Mon Sep 17 00:00:00 2001 From: Administrator <1760316362@qq.com> Date: Wed, 31 Jul 2019 11:58:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/base/adapter/ItemViewDelegate.kt | 2 +- .../io/legado/app/model/webbook/SourceDebug.kt | 15 +++++++-------- .../legado/app/ui/sourcedebug/SourceDebugModel.kt | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/io/legado/app/base/adapter/ItemViewDelegate.kt b/app/src/main/java/io/legado/app/base/adapter/ItemViewDelegate.kt index b4cd06a2f..2ac1090f2 100644 --- a/app/src/main/java/io/legado/app/base/adapter/ItemViewDelegate.kt +++ b/app/src/main/java/io/legado/app/base/adapter/ItemViewDelegate.kt @@ -7,7 +7,7 @@ import android.content.Context * * item代理, */ -abstract class ItemViewDelegate(protected val context: Context, val layoutId: Int) { +abstract class ItemViewDelegate(protected val context: Context, val layoutId: Int) { abstract fun convert(holder: ItemViewHolder, item: ITEM, payloads: MutableList) diff --git a/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt b/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt index a4c8ff5a2..03e9d0446 100644 --- a/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt +++ b/app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt @@ -23,8 +23,7 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) { private val startTime: Long = System.currentTimeMillis() fun printLog(sourceUrl: String?, state: Int, msg: String, print: Boolean = true, isHtml: Boolean = false) { - if (debugSource != sourceUrl) return - if (!print) return + if (debugSource != sourceUrl || callback == null || !print) return var printMsg = msg if (isHtml) { printMsg = printMsg.htmlFormat() @@ -34,20 +33,20 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) { callback?.printLog(state, printMsg) } - fun cancelDebug() { + fun cancelDebug(destroy: Boolean = false) { tasks.forEach { if (!it.isCancelled) { it.cancel() } } tasks.clear() - } - fun stopDebug(){ - cancelDebug() - debugSource = null - callback = null + if (destroy) { + debugSource = null + callback = null + } } + } init { diff --git a/app/src/main/java/io/legado/app/ui/sourcedebug/SourceDebugModel.kt b/app/src/main/java/io/legado/app/ui/sourcedebug/SourceDebugModel.kt index 3223e9660..0a9732ad5 100644 --- a/app/src/main/java/io/legado/app/ui/sourcedebug/SourceDebugModel.kt +++ b/app/src/main/java/io/legado/app/ui/sourcedebug/SourceDebugModel.kt @@ -37,6 +37,6 @@ class SourceDebugModel(application: Application) : BaseViewModel(application), S override fun onCleared() { super.onCleared() - SourceDebug.stopDebug() + SourceDebug.cancelDebug(true) } }