1. 修复因为特殊处理光遇更新判断而触发的其它下载闪退问题 2. 修复帖子视频详情页点击点赞/关注等按钮触发一键登录时的闪退问题 3. 修复下载完成点击通知栏下载完成通知偶发的闪退问题 4. 修复从首页安利墙发表新安利后点击到达评论可能触发的闪退问题 5. 修复论坛详情在页面被内存回收重建时下拉刷新的闪退问题 6. 修复游戏详情页浏览专区在页面被内存回收重建时点返回按钮偶发的闪退问题 7. 修复开测表列表不存在推荐标签时的闪退问题
80 lines
2.7 KiB
Java
80 lines
2.7 KiB
Java
package com.gh.common.util;
|
|
|
|
import android.app.Activity;
|
|
import android.content.Context;
|
|
import android.os.Bundle;
|
|
import android.text.TextUtils;
|
|
|
|
import com.gh.base.CurrentActivityHolder;
|
|
import com.gh.common.constant.Constants;
|
|
import com.gh.gamecenter.LoginActivity;
|
|
import com.gh.gamecenter.manager.UserManager;
|
|
import com.lightgame.utils.Utils;
|
|
|
|
|
|
/**
|
|
* Created by khy on 28/06/17.
|
|
*/
|
|
|
|
public class CheckLoginUtils {
|
|
|
|
public static void checkLogin(Context context, String entrance, OnLoginListener listener) {
|
|
if (!isLogin()) {
|
|
if (listener != null) Utils.toast(context, "需要登录");
|
|
LogUtils.login("dialog", null, entrance);
|
|
LogUtils.login("activity", null, entrance);
|
|
|
|
if (SPUtils.getBoolean(Constants.SP_HAS_GET_PHONE_INFO) || NetworkUtils.isOpenMobileData(context)) {
|
|
// 需要确保传入的 context 不为 application
|
|
if (!(context instanceof Activity)) {
|
|
context = CurrentActivityHolder.getCurrentActivity();
|
|
}
|
|
|
|
if (context != null) {
|
|
QuickLoginHelper.startLogin(context, entrance);
|
|
}
|
|
} else {
|
|
// 有可能App未启动
|
|
Bundle bundle = new Bundle();
|
|
bundle.putString(EntranceUtils.KEY_ENTRANCE, entrance);
|
|
bundle.putString(EntranceUtils.KEY_TO, LoginActivity.class.getName());
|
|
EntranceUtils.jumpActivity(context, bundle);
|
|
}
|
|
} else {
|
|
if (listener != null) {
|
|
listener.onLogin();
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void checkLogin(final Context context, Bundle nextToBundle, boolean isTriggerNextStep, String entrance, OnLoginListener listener) {
|
|
if (!isLogin()) {
|
|
if (listener != null) Utils.toast(context, "需要登录");
|
|
LogUtils.login("dialog", null, entrance);
|
|
LogUtils.login("activity", null, entrance);
|
|
|
|
// 有可能App未启动
|
|
Bundle bundle = new Bundle();
|
|
bundle.putString(EntranceUtils.KEY_ENTRANCE, entrance);
|
|
bundle.putString(EntranceUtils.KEY_TO, LoginActivity.class.getName());
|
|
EntranceUtils.jumpActivity(context, nextToBundle, bundle, (resultCode, data) -> {
|
|
if (isTriggerNextStep && listener != null && isLogin()) {
|
|
listener.onLogin();
|
|
}
|
|
});
|
|
} else {
|
|
if (listener != null) {
|
|
listener.onLogin();
|
|
}
|
|
}
|
|
}
|
|
|
|
public static boolean isLogin() {
|
|
return !TextUtils.isEmpty(UserManager.getInstance().getToken());
|
|
}
|
|
|
|
public interface OnLoginListener {
|
|
void onLogin();
|
|
}
|
|
}
|