|
@@ -33,6 +33,7 @@ open class NetCoroutineScope() : AndroidScope() {
|
|
protected var error = true
|
|
protected var error = true
|
|
get() = if (cacheSucceed) field else true
|
|
get() = if (cacheSucceed) field else true
|
|
|
|
|
|
|
|
+ var animate: Boolean = false
|
|
|
|
|
|
constructor(
|
|
constructor(
|
|
lifecycleOwner: LifecycleOwner,
|
|
lifecycleOwner: LifecycleOwner,
|
|
@@ -90,12 +91,17 @@ open class NetCoroutineScope() : AndroidScope() {
|
|
* 只在第一次启动作用域时回调
|
|
* 只在第一次启动作用域时回调
|
|
* 该函数在作用域[launch]之前执行
|
|
* 该函数在作用域[launch]之前执行
|
|
* 函数内部所有的异常都不会被抛出, 也不会终止作用域执行
|
|
* 函数内部所有的异常都不会被抛出, 也不会终止作用域执行
|
|
|
|
+ *
|
|
|
|
+ * @param error 是否在缓存读取成功但网络请求错误时吐司错误信息
|
|
|
|
+ * @param animate 是否在缓存成功后依然显示加载动画
|
|
|
|
+ * @param onCache 该作用域内的所有异常都算缓存读取失败, 不会吐司和打印任何错误
|
|
*/
|
|
*/
|
|
fun cache(
|
|
fun cache(
|
|
error: Boolean = false,
|
|
error: Boolean = false,
|
|
- animate: Boolean = true,
|
|
|
|
|
|
+ animate: Boolean = false,
|
|
onCache: suspend CoroutineScope.() -> Unit
|
|
onCache: suspend CoroutineScope.() -> Unit
|
|
): AndroidScope {
|
|
): AndroidScope {
|
|
|
|
+ this.animate = animate
|
|
this.error = error
|
|
this.error = error
|
|
this.onCache = onCache
|
|
this.onCache = onCache
|
|
return this
|
|
return this
|