Просмотр исходного кода

修复登录失效无法跳转登录界面的bug;

zengjiebin лет назад: 7
Родитель
Сommit
068c811e8d

+ 12 - 10
app/src/main/java/com/sheep/gamegroup/util/Jump2View.java

@@ -303,15 +303,19 @@ public class Jump2View {
      * 跳到登录页面
      *
      * @param context
-     * @param o
+     * @param from
      */
-    public synchronized void goLoginView(Context context, String o) {
+    public synchronized void goLoginView(Context context, String from) {
         Intent intent = new Intent(context, LoginAct.class);
-        intent.putExtra("where_from", o);
+        intent.putExtra("where_from", from);
         if (!(context instanceof Activity)) {
             intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        } else if (!TextUtils.isEmpty(o)) {
-            ((Activity) context).finish();
+        } else if (!TextUtils.isEmpty(from)) {
+            try {
+                ((Activity) context).finish();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
         }
         context.startActivity(intent);
     }
@@ -1502,17 +1506,15 @@ public class Jump2View {
         gotoLoginAgain("");
     }
 
-    public void gotoLoginAgain(String o) {
+    public void gotoLoginAgain(String msg) {
         String token = SpUtils.getToken(SheepApp.getInstance());
         if (TextUtils.isEmpty(token)) {
             return;
         }
         SpUtils.saveToken(SheepApp.getInstance(), "");
         DataUtil.getInstance().clearData();
-        G.showToast(TextUtils.isEmpty(o) ? "登录信息已过期,请重新登录" : o);
-        Intent intent = new Intent(SheepApp.getInstance(), ActMain.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-        intent.putExtra("INTENT_ACTION", "LOGOUT");
-        SheepApp.getInstance().startActivity(intent);
+        G.showToast(TextUtils.isEmpty(msg) ? "登录信息已过期,请重新登录" : msg);
+        goLoginView(SheepApp.getInstance().getCurrentActivity(), "other");
     }
 
     public void gotoGuide(final Activity activity) {

+ 1 - 2
app/src/main/java/com/sheep/gamegroup/view/activity/ActMain.java

@@ -88,8 +88,7 @@ public class ActMain extends BaseActYmPermissionCheck {
     public void onNewIntent(Intent intent) {
         super.onNewIntent(intent);
         if ("LOGOUT".equals(intent.getStringExtra("INTENT_ACTION"))) {
-            Jump2View.getInstance().goLoginView(this, "");
-            finish();
+            Jump2View.getInstance().goLoginView(this, "home");
         } else if (intent.hasExtra("SWITCH_TAB")) {
             switchFragment(intent.getIntExtra("SWITCH_TAB", 0));
         }