解决重复登录 出现多个弹窗问题

This commit is contained in:
kehaoyuan
2018-01-18 15:35:42 +08:00
parent c6f1a7d212
commit 370b2122aa
4 changed files with 25 additions and 26 deletions

View File

@ -38,7 +38,9 @@ import static com.gh.common.util.EntranceUtils.KEY_ENTRANCE;
public abstract class BaseActivity extends BaseToolBarActivity implements EasyPermissions.PermissionCallbacks {
protected String mEntrance;
private boolean mIsPause;
private boolean mIsExistLogoutDialog;
protected final Handler mBaseHandler = new BaseHandler(this);
@ -117,7 +119,6 @@ public abstract class BaseActivity extends BaseToolBarActivity implements EasyPe
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(final EBShowDialog showDialog) {
//TODO 改为缓存到UI可见时才调用参考beier-assist Lifecycle组件
if (!mIsPause && this.getClass().getName().equals(RunningUtils.getTopActivity(this))) {
if ("hijack".equals(showDialog.getType())) {
DialogUtils.showQqSessionDialog(this, "2586716223");// 建议用户联系客服
@ -133,6 +134,8 @@ public abstract class BaseActivity extends BaseToolBarActivity implements EasyPe
}
});
} else if ("loginException".equals(showDialog.getType())) {
if (mIsExistLogoutDialog) return;
mIsExistLogoutDialog = true;
try {
JSONObject object = new JSONObject(showDialog.getPath());
JSONObject device = object.getJSONObject("device");
@ -141,12 +144,10 @@ public abstract class BaseActivity extends BaseToolBarActivity implements EasyPe
DialogUtils.showAlertDialog(this, "你的账号已在另外一台设备登录"
, StringUtils.buildString("", manufacturer, " - ", model, "")
, "知道了", "重新登录"
, null, new DialogUtils.CancelListener() {
@Override
public void onCancel() {
startActivity(LoginActivity.getIntent(BaseActivity.this));
}
});
, null
, () -> startActivity(LoginActivity.getIntent(BaseActivity.this))
);
mBaseHandler.postDelayed(() -> mIsExistLogoutDialog = false, 5000);
} catch (JSONException e) {
e.printStackTrace();
}