Browse Source

删除冗余依赖

drake 3 years ago
parent
commit
27ca3f5ae4

+ 0 - 1
net/build.gradle

@@ -60,7 +60,6 @@ dependencies {
     testImplementation "junit:junit:4.13.2"
     androidTestImplementation "androidx.test:runner:1.3.0"
     androidTestImplementation "androidx.test.espresso:espresso-core:3.3.0"
-    implementation "com.github.liangjingkanji:Tooltip:1.1.2"
 
     compileOnly "com.squareup.okhttp3:okhttp:$okhttp_version"
 

+ 3 - 2
net/src/main/java/com/drake/net/NetConfig.kt

@@ -37,7 +37,7 @@ import com.drake.net.interceptor.RequestInterceptor
 import com.drake.net.interfaces.NetDialogFactory
 import com.drake.net.interfaces.NetErrorHandler
 import com.drake.net.okhttp.toNetOkhttp
-import com.drake.tooltip.toast
+import com.drake.net.utils.TipUtils
 import okhttp3.Call
 import okhttp3.OkHttpClient
 import java.lang.ref.WeakReference
@@ -104,9 +104,10 @@ object NetConfig {
         }
 
         if (logEnabled) printStackTrace()
-        toast(message)
+        TipUtils.toast(message)
     }
 
+
     @Deprecated("使用NetErrorHandler统一处理错误", replaceWith = ReplaceWith("NetConfig.errorHandler"))
     var onStateError: Throwable.(view: View) -> Unit = {
         when (this) {

+ 25 - 0
net/src/main/java/com/drake/net/utils/TipUtils.kt

@@ -0,0 +1,25 @@
+package com.drake.net.utils
+
+import android.annotation.SuppressLint
+import android.widget.Toast
+import com.drake.net.NetConfig
+
+object TipUtils {
+
+    private var toast: Toast? = null
+
+    /**
+     * 重复显示不会覆盖
+     * 可以在子线程显示
+     */
+    @SuppressLint("ShowToast")
+    @JvmStatic
+    fun toast(message: String?) {
+        message ?: return
+        runMain {
+            toast?.cancel()
+            toast = Toast.makeText(NetConfig.app, message, Toast.LENGTH_SHORT)
+            toast?.show()
+        }
+    }
+}