Net Callback
abstract class NetCallback<T>(lifecycle: LifecycleOwner?, lifeEvent: Lifecycle.Event) : Callback
Content copied to clipboard
提供泛型转换特性 相对于OkHttp的Callback新增三个回调函数: onSuccessonComplete 这三个函数都运行在主线程上
Parameters
lifecycle
将Activity/Fragment/LifecycleOwner等作为参数传递会在其生命周期结束时自动取消网络请求. 避免内存泄漏
lifeEvent
指定自动取消的生命周期. 默认为Lifecycle.Event.ON_DESTROY
Constructors
NetCallback
Link copied to clipboard
fun NetCallback(lifecycle: LifecycleOwner? = null, lifeEvent: Lifecycle.Event = Lifecycle.Event.ON_DESTROY)
Content copied to clipboard
将Activity/Fragment/LifecycleOwner等作为参数传递会在其生命周期结束时自动取消网络请求.
Functions
onComplete
Link copied to clipboard
onError
Link copied to clipboard
onFailure
Link copied to clipboard
onResponse
Link copied to clipboard
onStart
Link copied to clipboard
onSuccess
Link copied to clipboard
Properties
Inheritors
DialogCallback
Link copied to clipboard
PageCallback
Link copied to clipboard
StateCallback
Link copied to clipboard