|
|
@ -23,8 +23,7 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) { |
|
|
|
private val startTime: Long = System.currentTimeMillis() |
|
|
|
private val startTime: Long = System.currentTimeMillis() |
|
|
|
|
|
|
|
|
|
|
|
fun printLog(sourceUrl: String?, state: Int, msg: String, print: Boolean = true, isHtml: Boolean = false) { |
|
|
|
fun printLog(sourceUrl: String?, state: Int, msg: String, print: Boolean = true, isHtml: Boolean = false) { |
|
|
|
if (debugSource != sourceUrl) return |
|
|
|
if (debugSource != sourceUrl || callback == null || !print) return |
|
|
|
if (!print) return |
|
|
|
|
|
|
|
var printMsg = msg |
|
|
|
var printMsg = msg |
|
|
|
if (isHtml) { |
|
|
|
if (isHtml) { |
|
|
|
printMsg = printMsg.htmlFormat() |
|
|
|
printMsg = printMsg.htmlFormat() |
|
|
@ -34,22 +33,22 @@ class SourceDebug(private val webBook: WebBook, callback: Callback) { |
|
|
|
callback?.printLog(state, printMsg) |
|
|
|
callback?.printLog(state, printMsg) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun cancelDebug() { |
|
|
|
fun cancelDebug(destroy: Boolean = false) { |
|
|
|
tasks.forEach { |
|
|
|
tasks.forEach { |
|
|
|
if (!it.isCancelled) { |
|
|
|
if (!it.isCancelled) { |
|
|
|
it.cancel() |
|
|
|
it.cancel() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
tasks.clear() |
|
|
|
tasks.clear() |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun stopDebug(){ |
|
|
|
if (destroy) { |
|
|
|
cancelDebug() |
|
|
|
|
|
|
|
debugSource = null |
|
|
|
debugSource = null |
|
|
|
callback = null |
|
|
|
callback = null |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
init { |
|
|
|
init { |
|
|
|
debugSource = webBook.sourceUrl |
|
|
|
debugSource = webBook.sourceUrl |
|
|
|
SourceDebug.callback = callback |
|
|
|
SourceDebug.callback = callback |
|
|
|