瀏覽代碼

| 取消请求参数为空的问题

drake 4 年之前
父節點
當前提交
f9e3d5dc0b

+ 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.3.3'
 
-implementation 'com.github.liangjingkanji:Net:2.2.0'
+implementation 'com.github.liangjingkanji:Net:2.2.1'
 ```
 
 

+ 3 - 1
kalle/src/main/java/com/yanzhenjie/kalle/Canceler.kt

@@ -26,7 +26,8 @@ object Canceler {
      * @param uid   target request.
      * @param canceller canceller.
      */
-    fun addCancel(uid: Any, canceller: Canceller) {
+    fun addCancel(uid: Any?, canceller: Canceller) {
+        uid ?: return
         map[uid] = canceller
     }
 
@@ -45,6 +46,7 @@ object Canceler {
      *
      */
     fun cancel(uid: Any?) {
+        uid ?: return
         val iterator = map.iterator()
         while (iterator.hasNext()) {
             val next = iterator.next()

+ 1 - 6
sample/src/main/java/com/drake/net/sample/ui/fragment/StateLayoutFragment.kt

@@ -16,7 +16,6 @@ import com.drake.net.Get
 import com.drake.net.sample.R
 import com.drake.net.utils.scope
 import kotlinx.android.synthetic.main.fragment_state_layout.*
-import kotlinx.coroutines.delay
 
 
 class StateLayoutFragment : Fragment() {
@@ -34,11 +33,7 @@ class StateLayoutFragment : Fragment() {
 
         state.onRefresh {
             scope {
-                delay(1000)
-
-                tv_fragment.text = Get<String>("method") {
-                    param("userId", "drake")
-                }.await()
+                tv_fragment.text = Get<String>("api").await()
             }
         }.showLoading()
     }