Commit 036e248b by 王文龙

[update]优化账号被踢弹窗逻辑

parent 565646d3
...@@ -94,7 +94,7 @@ dependencies { ...@@ -94,7 +94,7 @@ dependencies {
implementation 'com.android.support:multidex:1.0.3' implementation 'com.android.support:multidex:1.0.3'
implementation("com.offcn.live:titleview:1.1.0-s1") implementation("com.offcn.live:titleview:1.1.0-s1")
implementation("com.offcn.live:imsdk-kit:1.0.0.13") implementation("com.offcn.live:imsdk-kit:1.0.0.14")
// DB // DB
implementation 'org.greenrobot:greendao:3.2.2' implementation 'org.greenrobot:greendao:3.2.2'
......
...@@ -2,6 +2,7 @@ package com.offcn.imclient.ui; ...@@ -2,6 +2,7 @@ package com.offcn.imclient.ui;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.animation.ValueAnimator; import android.animation.ValueAnimator;
import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
...@@ -14,6 +15,7 @@ import android.widget.TextView; ...@@ -14,6 +15,7 @@ import android.widget.TextView;
import com.google.android.material.tabs.TabLayout; import com.google.android.material.tabs.TabLayout;
import com.jyall.base.adapter.BaseVPAdapter; import com.jyall.base.adapter.BaseVPAdapter;
import com.jyall.base.base.BaseActivity; import com.jyall.base.base.BaseActivity;
import com.jyall.base.util.AppManager;
import com.jyall.base.util.CommonUtils; import com.jyall.base.util.CommonUtils;
import com.offcn.imclient.R; import com.offcn.imclient.R;
import com.offcn.imclient.bean.UserBean; import com.offcn.imclient.bean.UserBean;
...@@ -74,7 +76,7 @@ public class MainActivity extends BaseActivity { ...@@ -74,7 +76,7 @@ public class MainActivity extends BaseActivity {
@Override @Override
public void onStateDisconnected(int code, String error) { public void onStateDisconnected(int code, String error) {
ZGLLogUtils.e(TAG, "IM连接失败 " + code + " " + error); ZGLLogUtils.e(TAG, "IM连接失败 " + code + " " + error);
ZGLCommonUtils.showToast(MainActivity.this, "IM连接失败 " + code + " " + error); // ZGLCommonUtils.showToast(MainActivity.this, "IM连接失败 " + code + " " + error);
// 连接失败超时,和部分情况作特殊处理如退出页面:token失效、被踢 // 连接失败超时,和部分情况作特殊处理如退出页面:token失效、被踢
if (code == OIMCode.Code_IM_Connect_Fail if (code == OIMCode.Code_IM_Connect_Fail
|| code == OIMCode.Code_IM_Connect_Timeout || code == OIMCode.Code_IM_Connect_Timeout
...@@ -88,14 +90,22 @@ public class MainActivity extends BaseActivity { ...@@ -88,14 +90,22 @@ public class MainActivity extends BaseActivity {
LoginManager.logout(MainActivity.this); LoginManager.logout(MainActivity.this);
UserBeanDaoManager.getInstance().deleteAll(); UserBeanDaoManager.getInstance().deleteAll();
AlertDialog dialog = new AlertDialog.Builder(MainActivity.this) Activity curActivity = AppManager.getAppManager().getCurrentActivity();
if (curActivity != null) {
AlertDialog dialog = new AlertDialog.Builder(curActivity)
.setTitle("IM连接失败") .setTitle("IM连接失败")
.setMessage(code + "," + error) .setMessage(code + "," + error)
.setPositiveButton("退出", new DialogInterface.OnClickListener() { .setPositiveButton("重新登录", new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
startActivity(new Intent(MainActivity.this, LoginActivity.class)); startActivity(new Intent(curActivity, LoginActivity.class));
finish(); AppManager.getAppManager().finishAllActivity();
}
})
.setNegativeButton("我知道了", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
AppManager.getAppManager().AppExit(curActivity);
} }
}) })
.setCancelable(false) .setCancelable(false)
...@@ -104,6 +114,7 @@ public class MainActivity extends BaseActivity { ...@@ -104,6 +114,7 @@ public class MainActivity extends BaseActivity {
dialog.show(); dialog.show();
} }
} }
}
@Override @Override
public void onStateReconnecting() { public void onStateReconnecting() {
...@@ -134,7 +145,7 @@ public class MainActivity extends BaseActivity { ...@@ -134,7 +145,7 @@ public class MainActivity extends BaseActivity {
@Override @Override
public void onTabSelected(TabLayout.Tab tab) { public void onTabSelected(TabLayout.Tab tab) {
mViewPager.setCurrentItem(tab.getPosition()); mViewPager.setCurrentItem(tab.getPosition(), false);
changeTabSelect(tab); //Tab获取焦点 changeTabSelect(tab); //Tab获取焦点
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment