pull/32/head
Administrator 5 years ago
parent 846c01a416
commit e3c7e8d0c4
  1. 2
      app/src/main/java/io/legado/app/base/adapter/ItemViewDelegate.kt
  2. 15
      app/src/main/java/io/legado/app/model/webbook/SourceDebug.kt
  3. 2
      app/src/main/java/io/legado/app/ui/sourcedebug/SourceDebugModel.kt

@ -7,7 +7,7 @@ import android.content.Context
*
* item代理
*/
abstract class ItemViewDelegate<in ITEM>(protected val context: Context, val layoutId: Int) {
abstract class ItemViewDelegate<ITEM>(protected val context: Context, val layoutId: Int) {
abstract fun convert(holder: ItemViewHolder, item: ITEM, payloads: MutableList<Any>)

@ -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 {

@ -37,6 +37,6 @@ class SourceDebugModel(application: Application) : BaseViewModel(application), S
override fun onCleared() {
super.onCleared()
SourceDebug.stopDebug()
SourceDebug.cancelDebug(true)
}
}

Loading…
Cancel
Save