diff --git a/app/src/main/java/com/gh/common/util/GsonUtils.kt b/app/src/main/java/com/gh/common/util/GsonUtils.kt new file mode 100644 index 0000000000..e771821478 --- /dev/null +++ b/app/src/main/java/com/gh/common/util/GsonUtils.kt @@ -0,0 +1,35 @@ +package com.gh.common.util + +import com.google.gson.Gson +import com.google.gson.reflect.TypeToken + + +/** + * Created by khy on 11/10/17. + */ +class GsonUtils private constructor() { + val mGson: Gson = Gson() + + companion object { + fun getInstance(): GsonUtils { + return Inner.anotherSingle + } + + private object Inner { + val anotherSingle = GsonUtils() + } + } + + fun fromJsonBean(json: String, t: Class): T { + return mGson.fromJson(json, t) + } + + fun fromJsonList(json: String, t: Class): T { + val type = object : TypeToken>() {}.type + return mGson.fromJson(json, type) + } + + fun toJson(any: Any): String { + return mGson.toJson(any) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/gh/common/util/LoginUtils.java b/app/src/main/java/com/gh/common/util/LoginUtils.java index c56ae828d2..1938890232 100644 --- a/app/src/main/java/com/gh/common/util/LoginUtils.java +++ b/app/src/main/java/com/gh/common/util/LoginUtils.java @@ -369,6 +369,7 @@ public class LoginUtils { if (loginTag != null && loginTag.equals(LoginTag.qq)) { GetLoginDataUtils.getInstance(context).QQLogout(); } + cleanUserData(context); } }); } diff --git a/app/src/main/java/com/gh/gamecenter/AboutActivity.java b/app/src/main/java/com/gh/gamecenter/AboutActivity.java index 2dd67958b0..f479137afb 100644 --- a/app/src/main/java/com/gh/gamecenter/AboutActivity.java +++ b/app/src/main/java/com/gh/gamecenter/AboutActivity.java @@ -12,7 +12,6 @@ import android.widget.RelativeLayout; import android.widget.TextView; import com.gh.base.BaseActivity; -import com.gh.common.util.PackageUtils; import com.gh.common.util.StringUtils; import com.gh.gamecenter.manager.UpdateManager; @@ -51,7 +50,8 @@ public class AboutActivity extends BaseActivity { super.onCreate(savedInstanceState); 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("V" + PackageUtils.getVersionName(this)); + ((TextView) findViewById(R.id.about_tv_version)).setText("V3.0.0"); // TODO 版本号暂时与gradle versionName不一致 } @Override diff --git a/app/src/main/java/com/gh/gamecenter/retrofit/OkHttpRetryInterceptor.kt b/app/src/main/java/com/gh/gamecenter/retrofit/OkHttpRetryInterceptor.kt index 538d7dc6f6..63b8e800fc 100644 --- a/app/src/main/java/com/gh/gamecenter/retrofit/OkHttpRetryInterceptor.kt +++ b/app/src/main/java/com/gh/gamecenter/retrofit/OkHttpRetryInterceptor.kt @@ -101,6 +101,11 @@ class OkHttpRetryInterceptor internal constructor(context: Context) : Intercepto request = newBuilder.build() response = doRequest(chain, request) } + + override fun onFailure(e: HttpException?) { + super.onFailure(e) + LoginUtils.cleanUserData(mContext) + } }) }