修复登录掉线问题(应该OK了),关于版本显示补丁包版本号

This commit is contained in:
kehaoyuan
2017-10-26 14:51:51 +08:00
parent 9fad040e14
commit fad011e2fc
6 changed files with 24 additions and 22 deletions

View File

@ -37,6 +37,7 @@ public class Config {
public static final String USERSEA_APP_ID = BuildConfig.USERSEA_APP_ID; // 登录验证
public static final String USERSEA_APP_SECRET = BuildConfig.USERSEA_APP_SECRET; // 登录验证
public static final String BUGLY_APPID = BuildConfig.BUGLY_APPID;
public static final String PATCH_VERSION_NAME = BuildConfig.PATCH_VERSION_NAME; // 补丁包版本 对应关于->版本号
// http://www.ghzs666.com/article/${articleId}.html
public static final String URL_ARTICLE = "http://www.ghzs666.com/article/"; // TODO ghzs/ghzs666 统一

View File

@ -207,26 +207,13 @@ public class LoginUtils {
JSONObject content = new JSONObject(string);
int code = content.getInt("code");
if (loginTag == LoginTag.refresh && code == 40802) {
// JSONObject device = content.getJSONObject("device");
// String manufacturer = device.getString("manufacturer");
//
// String model = device.getString("model");
//
// DialogUtils.showAlertDialog(context, "你的账号已在另外一台设备登录"
// , StringUtils.buildString("", manufacturer, "", model, "")
// , "知道了", null, null, null);
//
// LoginUtils.cleanUserData(context);
if (loginTag.equals(LoginTag.phone)) {
outputErrorHint(context, code);
} else {
if (loginTag.equals(LoginTag.phone)) {
outputErrorHint(context, code);
} else {
if (loginTag.equals(LoginTag.qq)) {
GetLoginDataUtils.getInstance(context).QQLogout();
}
Utils.toast(context, context.getString(R.string.login_failure_hint));
if (loginTag.equals(LoginTag.qq)) {
GetLoginDataUtils.getInstance(context).QQLogout();
}
Utils.toast(context, context.getString(R.string.login_failure_hint));
}
} catch (Exception e1) {
e1.printStackTrace();

View File

@ -12,6 +12,7 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
import com.gh.base.BaseActivity;
import com.gh.common.constant.Config;
import com.gh.common.util.StringUtils;
import com.gh.gamecenter.manager.UpdateManager;
@ -51,7 +52,7 @@ public class AboutActivity extends BaseActivity {
initTitle(getString(R.string.title_about));
// ((TextView) findViewById(R.id.about_tv_version)).setText("V" + PackageUtils.getVersionName(this));
((TextView) findViewById(R.id.about_tv_version)).setText("V3.0.0"); // TODO 版本号暂时与gradle versionName不一致
((TextView) findViewById(R.id.about_tv_version)).setText(Config.PATCH_VERSION_NAME); // TODO 版本号暂时与gradle versionName不一致
}
@Override

View File

@ -56,8 +56,8 @@ class OkHttpRetryInterceptor internal constructor(context: Context) : Intercepto
CommonDebug.logMethodWithParams(this, "Retrying ${request.url()} for $tryCount")
}
if (url.contains("user/info") && TextUtils.isEmpty(request.header("Content-Type"))) { // 过滤在当前类请求的 userinfo
tryCount =3
if (url.contains("user/info") && !TextUtils.isEmpty(request.header("Content-Type"))) { // 过滤在当前类请求的 userinfo
tryCount = 3
break
}
@ -92,7 +92,7 @@ class OkHttpRetryInterceptor internal constructor(context: Context) : Intercepto
RetrofitManager.getInstance(mContext)
.getApi()
.getRetryUserInfo()
.subscribe(object : com.gh.gamecenter.retrofit.Response<UserInfoEntity>(){
.subscribe(object : com.gh.gamecenter.retrofit.Response<UserInfoEntity>() {
override fun onResponse(userInfo: UserInfoEntity?) {
super.onResponse(userInfo)
LoginUtils.saveUserInfo(mContext, userInfo)
@ -100,11 +100,13 @@ class OkHttpRetryInterceptor internal constructor(context: Context) : Intercepto
newBuilder.header("TOKEN", loginResponseEntity?.accessToken?.value)
request = newBuilder.build()
response = doRequest(chain, request)
EventBus.getDefault().post(EBReuse(PersonalFragment.LOGIN_TAG))
}
override fun onFailure(e: HttpException?) {
super.onFailure(e)
LoginUtils.cleanUserData(mContext)
EventBus.getDefault().post(EBReuse(PersonalFragment.LOGOUT_TAG))
}
})
}
@ -115,6 +117,13 @@ class OkHttpRetryInterceptor internal constructor(context: Context) : Intercepto
val responseBody = e?.response()?.errorBody()
val string = responseBody?.string()
Utils.log("=======string::" + string)
// 如果当前token 与sp存储的token不一致 证明token已经被刷新过 无需处理当前访问异常
if (!token.equals(LoginUtils.getToken(mContext))){
tryCount = 4
return
}
val content = JSONObject(string)
val code = content.getInt("code")
LoginUtils.cleanUserData(mContext)
@ -133,6 +142,7 @@ class OkHttpRetryInterceptor internal constructor(context: Context) : Intercepto
} else {
// 重新登录
LoginUtils.cleanUserData(mContext)
EventBus.getDefault().post(EBReuse(PersonalFragment.LOGOUT_TAG))
Utils.toast(mContext, "账号过期,请重新登录!")
}
} else { // 网络错误处理