From cd13751df41c6504b3934cd3f1bd441c4ba172ff Mon Sep 17 00:00:00 2001
From: lmw <125975490@qq.com>
Date: 星期五, 19 七月 2024 11:38:27 +0800
Subject: [PATCH] fix bug

---
 app/src/main/java/com/dollearn/student/network/Functions.kt |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/app/src/main/java/com/dollearn/student/network/Functions.kt b/app/src/main/java/com/dollearn/student/network/Functions.kt
index 2b0699c..beb1119 100644
--- a/app/src/main/java/com/dollearn/student/network/Functions.kt
+++ b/app/src/main/java/com/dollearn/student/network/Functions.kt
@@ -6,7 +6,8 @@
 import cn.sinata.xldutils.fragment.BaseFragment
 import cn.sinata.xldutils.rxutils.ResultDataSubscriber
 import cn.sinata.xldutils.utils.SPUtils
-import com.dollearn.student.WeparkApplication
+import cn.sinata.xldutils.utils.myToast
+import com.dollearn.student.DollearnApplication
 import com.dollearn.student.ui.login.LoginActivity
 import com.dollearn.student.utils.Const
 import io.reactivex.Flowable
@@ -26,11 +27,11 @@
         override fun isShowToast() = showToast
 
         override fun onError(code: Int, msg: String) {
-            if (code == 700||code == 600){//token无效
-                error(code,"登录已失效")
+            if (code == 700||code == 600||code == 505||code == 401){//token无效
                 SPUtils.instance().remove(Const.User.TOKEN).remove(Const.User.USER_ID).apply()
-                (activity.application as WeparkApplication).exit()
+                (activity.application as DollearnApplication).exit()
                 activity.startActivity<LoginActivity>()
+                activity.myToast("登录失效,请重新登录")
             }else{
                 super.onError(code, msg)
                 error(code,msg)
@@ -52,10 +53,10 @@
         override fun isShowToast() = showToast
 
         override fun onError(code: Int, msg: String) {
-            if (code == 700||code == 600){//token无效
-                error(code,"登录已失效")
+            if (code == 700||code == 600||code == 505||code == 401){//token无效
+                fragment.myToast("登录失效,请重新登录")
                 SPUtils.instance().remove(Const.User.TOKEN).remove(Const.User.USER_ID).apply()
-                (fragment.activity!!.application as WeparkApplication).exit()
+                (fragment.activity!!.application as DollearnApplication).exit()
                 fragment.startActivity<LoginActivity>()
             }else{
                 super.onError(code, msg)

--
Gitblit v1.7.1