Package com. drake. net. utils
Types
Functions
debounce
Link copied to clipboard
为EditText的输入框文本变化启用节流阀, 即超过指定时间后(默认800毫秒)的输入框文本变化事件TextWatcher.onTextChanged会被下游收集到
fastest
Link copied to clipboard
isNetworking
Link copied to clipboard
launchIn
Link copied to clipboard
inline fun <T> Flow<T>.launchIn(owner: LifecycleOwner? = null, event: Lifecycle.Event = Lifecycle.Event.ON_DESTROY, dispatcher: CoroutineDispatcher = Dispatchers.Main, crossinline action: suspend CoroutineScope.(T) -> Unit): AndroidScope
Content copied to clipboard
scope
Link copied to clipboard
fun scope(dispatcher: CoroutineDispatcher = Dispatchers.Main, block: suspend CoroutineScope.() -> Unit): AndroidScope
Content copied to clipboard
fun PageRefreshLayout.scope(dispatcher: CoroutineDispatcher = Dispatchers.Main, block: suspend CoroutineScope.() -> Unit): PageCoroutineScope
Content copied to clipboard
fun StateLayout.scope(dispatcher: CoroutineDispatcher = Dispatchers.Main, block: suspend CoroutineScope.() -> Unit): NetCoroutineScope
Content copied to clipboard
自动处理缺省页的异步作用域 作用域开始执行时显示加载中缺省页 作用域正常结束时显示成功缺省页 作用域抛出异常时显示错误缺省页 并且自动吐司错误信息, 可配置 com.drake.net.interfaces.NetErrorHandler.onStateError 自动打印异常日志 布局被销毁或者界面关闭作用域被取消
scopeDialog
Link copied to clipboard
fun Fragment.scopeDialog(dialog: Dialog? = null, cancelable: Boolean = true, dispatcher: CoroutineDispatcher = Dispatchers.Main, block: suspend CoroutineScope.() -> Unit): NetCoroutineScope
Content copied to clipboard
作用域开始时自动显示加载对话框, 结束时自动关闭加载对话框 可以设置全局对话框 com.drake.net.NetConfig.dialogFactory 对话框被取消或者界面关闭作用域被取消
fun FragmentActivity.scopeDialog(dialog: Dialog? = null, cancelable: Boolean = true, dispatcher: CoroutineDispatcher = Dispatchers.Main, block: suspend CoroutineScope.() -> Unit): NetCoroutineScope
Content copied to clipboard
作用域开始时自动显示加载对话框, 结束时自动关闭加载对话框 可以设置全局对话框 com.drake.net.NetConfig.dialogFactory 对话框被取消或者界面关闭作用域被取消
scopeLife
Link copied to clipboard
fun Fragment.scopeLife(lifeEvent: Lifecycle.Event = Lifecycle.Event.ON_DESTROY, dispatcher: CoroutineDispatcher = Dispatchers.Main, block: suspend CoroutineScope.() -> Unit): AndroidScope
Content copied to clipboard
异步作用域该作用域生命周期跟随Fragment
fun LifecycleOwner.scopeLife(lifeEvent: Lifecycle.Event = Lifecycle.Event.ON_DESTROY, dispatcher: CoroutineDispatcher = Dispatchers.Main, block: suspend CoroutineScope.() -> Unit): AndroidScope
Content copied to clipboard
异步作用域该作用域生命周期跟随LifecycleOwner
scopeNet
Link copied to clipboard
fun scopeNet(dispatcher: CoroutineDispatcher = Dispatchers.Main, block: suspend CoroutineScope.() -> Unit): NetCoroutineScope
Content copied to clipboard
该函数比scope多了以下功能
在作用域内抛出异常时会被回调的com.drake.net.interfaces.NetErrorHandler.onError函数中
自动显示错误信息吐司, 可以通过指定com.drake.net.interfaces.NetErrorHandler.onError来取消或者增加自己的处理
scopeNetLife
Link copied to clipboard
fun View.scopeNetLife(dispatcher: CoroutineDispatcher = Dispatchers.Main, block: suspend CoroutineScope.() -> Unit): ViewCoroutineScope
Content copied to clipboard
fun Fragment.scopeNetLife(lifeEvent: Lifecycle.Event = Lifecycle.Event.ON_DESTROY, dispatcher: CoroutineDispatcher = Dispatchers.Main, block: suspend CoroutineScope.() -> Unit): NetCoroutineScope
Content copied to clipboard
和scopeNetLife功能相同, 只是接受者为Fragment
fun LifecycleOwner.scopeNetLife(lifeEvent: Lifecycle.Event = Lifecycle.Event.ON_DESTROY, dispatcher: CoroutineDispatcher = Dispatchers.Main, block: suspend CoroutineScope.() -> Unit): NetCoroutineScope
Content copied to clipboard
toRequestBody
Link copied to clipboard
withDefault
Link copied to clipboard
suspend fun <T> withDefault(block: suspend CoroutineScope.() -> T): <ERROR CLASS>
Content copied to clipboard
withUnconfined
Link copied to clipboard
suspend fun <T> withUnconfined(block: suspend CoroutineScope.() -> T): <ERROR CLASS>
Content copied to clipboard