ソースを参照

| 缺省页预读缓存错误

drake 5 年 前
コミット
0efaedfcc0

+ 1 - 1
README.md

@@ -83,7 +83,7 @@ implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0'
 // 支持自动下拉刷新和缺省页的, 可选, 刷新头和上拉加载参考SmartRefreshLayout
 implementation 'com.github.liangjingkanji:BRV:1.2.1'
 
-implementation 'com.github.liangjingkanji:Net:2.1.3'
+implementation 'com.github.liangjingkanji:Net:2.1.4'
 ```
 
 

+ 4 - 4
net/src/main/java/com/drake/net/scope/NetCoroutineScope.kt

@@ -27,11 +27,11 @@ open class NetCoroutineScope() : AndroidScope() {
     protected var isReadCache = true
     protected var onCache: (suspend CoroutineScope.() -> Unit)? = null
 
-    protected var readCacheSucceed = false
+    protected var isCacheSucceed = false
         get() = if (onCache != null) field else false
 
     protected var error = true
-        get() = if (readCacheSucceed) field else true
+        get() = if (isCacheSucceed) field else true
 
     var animate: Boolean = false
 
@@ -55,13 +55,13 @@ open class NetCoroutineScope() : AndroidScope() {
             start()
             if (onCache != null && isReadCache) {
                 supervisorScope {
-                    readCacheSucceed = try {
+                    isCacheSucceed = try {
                         onCache?.invoke(this)
                         true
                     } catch (e: Exception) {
                         false
                     }
-                    readCache(readCacheSucceed)
+                    readCache(isCacheSucceed)
                 }
             }
             block()

+ 1 - 1
net/src/main/java/com/drake/net/scope/StateCoroutineScope.kt

@@ -42,7 +42,7 @@ class StateCoroutineScope(val state: StateLayout) : NetCoroutineScope() {
 
     override fun catch(e: Throwable) {
         super.catch(e)
-        state.showError(e)
+        if (!isCacheSucceed) state.showError(e)
     }
 
     override fun handleError(e: Throwable) {

+ 1 - 1
sample/src/main/java/com/drake/net/sample/App.kt

@@ -21,7 +21,7 @@ class App : Application() {
         }
 
         initNet("") {
-            converter(JsonConvert())
+            //            converter(JsonConvert())
             cacheEnabled()
         }