|
|
@ -13,6 +13,8 @@ class SourceDebugModel(application: Application) : BaseViewModel(application), S |
|
|
|
|
|
|
|
|
|
|
|
private var webBook: WebBook? = null |
|
|
|
private var webBook: WebBook? = null |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private var callback: ((Int, String)-> Unit)? = null |
|
|
|
|
|
|
|
|
|
|
|
fun init(sourceUrl: String?) { |
|
|
|
fun init(sourceUrl: String?) { |
|
|
|
sourceUrl?.let { |
|
|
|
sourceUrl?.let { |
|
|
|
//优先使用这个,不会抛出异常 |
|
|
|
//优先使用这个,不会抛出异常 |
|
|
@ -23,6 +25,10 @@ class SourceDebugModel(application: Application) : BaseViewModel(application), S |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun observe(callback: (Int, String)-> Unit){ |
|
|
|
|
|
|
|
this.callback = callback |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun startDebug(key: String, start: (() -> Unit)? = null, error: (() -> Unit)? = null) { |
|
|
|
fun startDebug(key: String, start: (() -> Unit)? = null, error: (() -> Unit)? = null) { |
|
|
|
webBook?.let { |
|
|
|
webBook?.let { |
|
|
|
start?.invoke() |
|
|
|
start?.invoke() |
|
|
@ -31,7 +37,7 @@ class SourceDebugModel(application: Application) : BaseViewModel(application), S |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun printLog(state: Int, msg: String) { |
|
|
|
override fun printLog(state: Int, msg: String) { |
|
|
|
postEvent(Bus.SOURCE_DEBUG_LOG, EventMessage.obtain(state, msg)) |
|
|
|
callback?.invoke(state, msg) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun onCleared() { |
|
|
|
override fun onCleared() { |
|
|
|