diff --git a/app/src/main/java/com/gh/common/util/CollectionUtils.kt b/app/src/main/java/com/gh/common/util/CollectionUtils.kt index 7c346e6668..bbc8f0d217 100644 --- a/app/src/main/java/com/gh/common/util/CollectionUtils.kt +++ b/app/src/main/java/com/gh/common/util/CollectionUtils.kt @@ -27,8 +27,8 @@ object CollectionUtils { val body = RequestBody.create(MediaType.parse("application/json"), content) var token = LoginUtils.getToken(context) val postCollection = when (tag) { - CollectionTag.article -> RetrofitManager.getInstance(context).getApi().postCollectionArticle(token, body) - CollectionTag.tools -> RetrofitManager.getInstance(context).getApi().postCollectionTools(token, body) + CollectionTag.article -> RetrofitManager.getInstance(context).getApi().postCollectionArticle(body) + CollectionTag.tools -> RetrofitManager.getInstance(context).getApi().postCollectionTools(body) } postCollection .subscribeOn(Schedulers.io()) @@ -63,8 +63,8 @@ object CollectionUtils { val postCollection: Observable when (tag) { - CollectionTag.article -> postCollection = RetrofitManager.getInstance(context).getApi().deletaCollectionArticle(LoginUtils.getToken(context), id) - CollectionTag.tools -> postCollection = RetrofitManager.getInstance(context).getApi().deleteCollectionTools(LoginUtils.getToken(context), id) + CollectionTag.article -> postCollection = RetrofitManager.getInstance(context).getApi().deletaCollectionArticle(id) + CollectionTag.tools -> postCollection = RetrofitManager.getInstance(context).getApi().deleteCollectionTools(id) } postCollection .subscribeOn(Schedulers.io()) @@ -84,8 +84,8 @@ object CollectionUtils { fun patchCollection(context: Context, id: String, tag: CollectionTag) { val postCollection = when (tag) { - CollectionTag.article -> RetrofitManager.getInstance(context).getApi().patchCollectionArticle(LoginUtils.getToken(context), id) - CollectionTag.tools -> RetrofitManager.getInstance(context).getApi().patchCollectionTools(LoginUtils.getToken(context), id) + CollectionTag.article -> RetrofitManager.getInstance(context).getApi().patchCollectionArticle(id) + CollectionTag.tools -> RetrofitManager.getInstance(context).getApi().patchCollectionTools(id) } postCollection .subscribeOn(Schedulers.io()) diff --git a/app/src/main/java/com/gh/common/util/ConcernUtils.kt b/app/src/main/java/com/gh/common/util/ConcernUtils.kt index bf6f7e3fff..ddcaeefcf7 100644 --- a/app/src/main/java/com/gh/common/util/ConcernUtils.kt +++ b/app/src/main/java/com/gh/common/util/ConcernUtils.kt @@ -30,7 +30,7 @@ object ConcernUtils { params.put(gameId) val body = RequestBody.create(MediaType.parse("application/json"), params.toString()) RetrofitManager.getInstance(context).getApi() - .postConcern(LoginUtils.getToken(context), body) + .postConcern(body) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(object : Response(){ @@ -48,7 +48,7 @@ object ConcernUtils { fun deleteConcernData(context: Context, gameId: String, listener: onConcernListener) { RetrofitManager.getInstance(context).getApi() - .deleteConcern(LoginUtils.getToken(context), gameId) + .deleteConcern(gameId) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(object : Response(){ @@ -68,7 +68,7 @@ object ConcernUtils { val body = RequestBody.create(MediaType.parse("application/json"), data.toString()) RetrofitManager.getInstance(context).getApi() - .putConcern(LoginUtils.getToken(context), body) + .putConcern(body) .subscribeOn(Schedulers.io()) .observeOn(Schedulers.io()) .subscribe(object : Response() { @@ -99,7 +99,7 @@ object ConcernUtils { val body = RequestBody.create(MediaType.parse("application/json"), JSONArray(response).toString()) RetrofitManager.getInstance(context).getApi() - .putConcern(LoginUtils.getToken(context), body) + .putConcern(body) .subscribeOn(Schedulers.io()) .observeOn(Schedulers.io()) .subscribe(Response()) @@ -110,7 +110,7 @@ object ConcernUtils { }) } else { RetrofitManager.getInstance(context).getApi() - .getConcern(LoginUtils.getToken(context)) + .getConcern() .subscribeOn(Schedulers.io()) .observeOn(Schedulers.io()) .subscribe(object : Response>() { diff --git a/app/src/main/java/com/gh/common/util/LibaoUtils.java b/app/src/main/java/com/gh/common/util/LibaoUtils.java index 7ac82a3adc..2b9d6794d0 100644 --- a/app/src/main/java/com/gh/common/util/LibaoUtils.java +++ b/app/src/main/java/com/gh/common/util/LibaoUtils.java @@ -73,7 +73,7 @@ public class LibaoUtils { //初始化存号箱 获取存号箱所有礼包 public static void getCunHaoXiang(final Context context) { RetrofitManager.getInstance(context).getApi() - .getCunHaoXiang(LoginUtils.getToken(context)) + .getCunHaoXiang() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Response>() { @@ -109,7 +109,7 @@ public class LibaoUtils { Observable observable; if (!TextUtils.isEmpty(captchaCode)) { - observable = RetrofitManager.getInstance(context).getApi().postLibaoLing(LoginUtils.getToken(context), captchaCode, libaoId); + observable = RetrofitManager.getInstance(context).getApi().postLibaoLing(captchaCode, libaoId); } else { observable = RetrofitManager.getInstance(context).getApi().postLibaoLing(LoginUtils.getToken(context), libaoId); } @@ -133,7 +133,7 @@ public class LibaoUtils { private static void postLibaoTao(final Context context, final String libaoId, final boolean isCheck, final PostLibaoListener listener) { - RetrofitManager.getInstance(context).getApi().postLibaoTao(LoginUtils.getToken(context), libaoId) + RetrofitManager.getInstance(context).getApi().postLibaoTao(libaoId) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new JSONObjectResponse() { @@ -151,7 +151,7 @@ public class LibaoUtils { public static void deleteLibaoCode(final Context context, final String code, final boolean isCheck, final PostLibaoListener listener) { - RetrofitManager.getInstance(context).getApi().deleteLibaoCode(LoginUtils.getToken(context), code) + RetrofitManager.getInstance(context).getApi().deleteLibaoCode(code) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Response() { 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 5a98350036..9912166f8f 100644 --- a/app/src/main/java/com/gh/common/util/LoginUtils.java +++ b/app/src/main/java/com/gh/common/util/LoginUtils.java @@ -241,7 +241,7 @@ public class LoginUtils { HashMap map = new HashMap<>(); map.put("device_id", syncDeviceID); RequestBody body = RequestBody.create(MediaType.parse("application/json"), new JSONObject(map).toString()); - RetrofitManager.getInstance(context).getApi().syncUserData(token, body) + RetrofitManager.getInstance(context).getApi().syncUserData(body) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Response() { @@ -274,12 +274,10 @@ public class LoginUtils { // 注销登录 public static void logout(final Context context) { - LoginResponseEntity loginToken = getLoginToken(context); - if (loginToken == null || loginToken.getAccessToken() == null) return; RetrofitManager.getInstance(context) .getUsersea() - .logout(loginToken.getAccessToken().getValue()) + .logout() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Response() { @@ -344,7 +342,7 @@ public class LoginUtils { public static void getUserData(final Context context, String token, final onLoginCallBackListener listener, final LoginTag loginTag) { RetrofitManager.getInstance(context) .getApi() - .getUserInfo(token) + .getUserInfo() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Response() { @@ -466,14 +464,11 @@ public class LoginUtils { final Dialog loadingDialog = DialogUtils.showWaitDialog(context, "正在修改信息..."); - LoginResponseEntity loginToken = getLoginToken(context); - if (loginToken == null || loginToken.getAccessToken() == null) return; - RequestBody body = RequestBody.create(MediaType.parse("application/json"), new JSONObject(map).toString()); RetrofitManager.getInstance(context) .getUsersea() - .changeUserInfo(loginToken.getAccessToken().getValue(), body) + .changeUserInfo(body) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Response() { diff --git a/app/src/main/java/com/gh/common/util/PostCommentUtils.java b/app/src/main/java/com/gh/common/util/PostCommentUtils.java index d88ba1e094..84700a557d 100644 --- a/app/src/main/java/com/gh/common/util/PostCommentUtils.java +++ b/app/src/main/java/com/gh/common/util/PostCommentUtils.java @@ -29,9 +29,9 @@ public class PostCommentUtils { RequestBody body = RequestBody.create(MediaType.parse("application/json"), content); Observable observable; if (commentEntity != null) { - observable = RetrofitManager.getInstance(context).getApi().postReplyComment(LoginUtils.getToken(context), commentEntity.getId(), body); + observable = RetrofitManager.getInstance(context).getApi().postReplyComment(commentEntity.getId(), body); } else { - observable = RetrofitManager.getInstance(context).getApi().postNewsComment(LoginUtils.getToken(context), newsId, body); + observable = RetrofitManager.getInstance(context).getApi().postNewsComment(newsId, body); } observable.subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) @@ -59,7 +59,7 @@ public class PostCommentUtils { public static void addCommentVoto(final Context context, final String commentId, final PostCommentListener listener) { RetrofitManager.getInstance(context).getApi() - .postCommentVote(LoginUtils.getToken(context), commentId) + .postCommentVote(commentId) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Response() { @@ -83,7 +83,7 @@ public class PostCommentUtils { final PostCommentListener listener) { RequestBody body = RequestBody.create(MediaType.parse("application/json"), reportData); RetrofitManager.getInstance(context).getApi() - .postReportData(body, LoginUtils.getToken(context)) + .postReportData(body) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Response() { diff --git a/app/src/main/java/com/gh/common/util/TokenUtils.java b/app/src/main/java/com/gh/common/util/TokenUtils.java index fc03121acf..c8b13fac85 100644 --- a/app/src/main/java/com/gh/common/util/TokenUtils.java +++ b/app/src/main/java/com/gh/common/util/TokenUtils.java @@ -3,92 +3,74 @@ package com.gh.common.util; import android.content.Context; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; -import android.net.wifi.WifiManager; -import android.os.Build; import android.os.Environment; import android.preference.PreferenceManager; -import android.provider.Settings; -import android.text.TextUtils; import com.gh.gamecenter.BuildConfig; -import com.gh.gamecenter.retrofit.JSONObjectResponse; -import com.gh.gamecenter.retrofit.Response; import com.gh.gamecenter.retrofit.RetrofitManager; import com.gh.gamecenter.retrofit.StringResponse; -import com.lightgame.utils.Util_System_Phone_State; import com.lightgame.utils.Utils; -import com.tencent.stat.StatConfig; - -import org.json.JSONException; -import org.json.JSONObject; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import okhttp3.MediaType; -import okhttp3.RequestBody; -import okhttp3.ResponseBody; -import rx.Observable; import rx.android.schedulers.AndroidSchedulers; -import rx.functions.Func1; import rx.schedulers.Schedulers; public class TokenUtils { // 注册设备 - public static synchronized void register(final Context context) { - Map params = new HashMap<>(); - params.put("MANUFACTURER", Build.MANUFACTURER); - params.put("MODEL", Build.MODEL); - params.put("ANDROID_SDK", String.valueOf(Build.VERSION.SDK_INT)); - params.put("ANDROID_VERSION", Build.VERSION.RELEASE); - String android_id = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); - if (!TextUtils.isEmpty(android_id)) { - params.put("ANDROID_ID", android_id); - } - String imei = Util_System_Phone_State.getDeviceId(context); - if (!TextUtils.isEmpty(imei)) { - params.put("IMEI", imei); - } - WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); - String mac = wm.getConnectionInfo().getMacAddress(); - if (!TextUtils.isEmpty(mac) || !":::::".equals(mac)) { - params.put("MAC", mac); - } else { - SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); - sp.edit().putBoolean("isUploadMac", false).apply(); - } - String mid = StatConfig.getMid(context); - if (!TextUtils.isEmpty(mid) || !"0".equals(mid)) { - params.put("MTA_ID", mid); - } else { - SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); - sp.edit().putBoolean("isUploadMid", false).apply(); - } - RequestBody body = RequestBody.create(MediaType.parse("application/json"), new JSONObject(params).toString()); - RetrofitManager.getInstance(context).getApi().postRegister(body) - .subscribeOn(Schedulers.io()) - .observeOn(Schedulers.io()) - .subscribe(new JSONObjectResponse() { - @Override - public void onResponse(JSONObject response) { - if (response.length() != 0) { - try { - // 保存device_id - saveDeviceId(context, response.getString("device_id")); - Utils.log("device_id = " + response.getString("device_id")); - } catch (JSONException e) { - e.printStackTrace(); - } - } - } - }); - } +// public static synchronized void register(final Context context) { +// Map params = new HashMap<>(); +// params.put("MANUFACTURER", Build.MANUFACTURER); +// params.put("MODEL", Build.MODEL); +// params.put("ANDROID_SDK", String.valueOf(Build.VERSION.SDK_INT)); +// params.put("ANDROID_VERSION", Build.VERSION.RELEASE); +// String android_id = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID); +// if (!TextUtils.isEmpty(android_id)) { +// params.put("ANDROID_ID", android_id); +// } +// String imei = Util_System_Phone_State.getDeviceId(context); +// if (!TextUtils.isEmpty(imei)) { +// params.put("IMEI", imei); +// } +// WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); +// String mac = wm.getConnectionInfo().getMacAddress(); +// if (!TextUtils.isEmpty(mac) || !":::::".equals(mac)) { +// params.put("MAC", mac); +// } else { +// SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); +// sp.edit().putBoolean("isUploadMac", false).apply(); +// } +// String mid = StatConfig.getMid(context); +// if (!TextUtils.isEmpty(mid) || !"0".equals(mid)) { +// params.put("MTA_ID", mid); +// } else { +// SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); +// sp.edit().putBoolean("isUploadMid", false).apply(); +// } +// RequestBody body = RequestBody.create(MediaType.parse("application/json"), new JSONObject(params).toString()); +// RetrofitManager.getInstance(context).getApi().postRegister(body) +// .subscribeOn(Schedulers.io()) +// .observeOn(Schedulers.io()) +// .subscribe(new JSONObjectResponse() { +// @Override +// public void onResponse(JSONObject response) { +// if (response.length() != 0) { +// try { +// // 保存device_id +// saveDeviceId(context, response.getString("device_id")); +// Utils.log("device_id = " + response.getString("device_id")); +// } catch (JSONException e) { +// e.printStackTrace(); +// } +// } +// } +// }); +// } public static synchronized void saveDeviceId(Context context, String device_id) { saveSharedPreferences(context, device_id); @@ -152,63 +134,63 @@ public class TokenUtils { } - // 获取用户token - public static synchronized Observable getToken(final Context context, boolean isCheck) { - - if (true) { // TODO TEST - return Observable.just(LoginUtils.getToken(context)); - } - - String token = null; - if (isCheck) { - SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); - token = sp.getString("token", null); - if (token != null) { - long expire = sp.getLong("token_expire", 0) * 1000 - 10 * 1000; - long time = Utils.getTime(context); - // 判断token是否过期 - if (time >= expire) { - // token已过期 - token = null; - } - } - } - if (token == null) { - Map params = new HashMap<>(); - params.put("device_id", getDeviceId(context)); - return RetrofitManager.getInstance(context).getApi() - .postLogin(RequestBody.create(MediaType.parse("application/json"), new JSONObject(params).toString())) - .flatMap(new Func1>() { - @Override - public Observable call(ResponseBody responseBody) { - String value = null; - try { - SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); - Editor editor = sp.edit(); - JSONObject response = new JSONObject(responseBody.string()); - editor.putString("user_name", response.getString("name")); - editor.putString("user_icon", response.getString("icon")); - response = response.getJSONObject("token"); - editor.putString("token", response.getString("value")); - editor.putLong("token_expire", response.getLong("expire")); - editor.apply(); - // 服务器返回的token和本地已存的token相同,更新本地时间 - getTime(context); - value = response.getString("value"); - } catch (IOException | JSONException e) { - e.printStackTrace(); - } - return Observable.just(value); - } - }).onErrorResumeNext(new Func1>() { - @Override - public Observable call(Throwable throwable) { - return Observable.error(throwable); - } - }); - } - return Observable.just(token); - } +// // 获取用户token +// public static synchronized Observable getToken(final Context context, boolean isCheck) { +// +// if (true) { // TODO TEST +// return Observable.just(LoginUtils.getToken(context)); +// } +// +// String token = null; +// if (isCheck) { +// SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); +// token = sp.getString("token", null); +// if (token != null) { +// long expire = sp.getLong("token_expire", 0) * 1000 - 10 * 1000; +// long time = Utils.getTime(context); +// // 判断token是否过期 +// if (time >= expire) { +// // token已过期 +// token = null; +// } +// } +// } +// if (token == null) { +// Map params = new HashMap<>(); +// params.put("device_id", getDeviceId(context)); +// return RetrofitManager.getInstance(context).getApi() +// .postLogin(RequestBody.create(MediaType.parse("application/json"), new JSONObject(params).toString())) +// .flatMap(new Func1>() { +// @Override +// public Observable call(ResponseBody responseBody) { +// String value = null; +// try { +// SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); +// Editor editor = sp.edit(); +// JSONObject response = new JSONObject(responseBody.string()); +// editor.putString("user_name", response.getString("name")); +// editor.putString("user_icon", response.getString("icon")); +// response = response.getJSONObject("token"); +// editor.putString("token", response.getString("value")); +// editor.putLong("token_expire", response.getLong("expire")); +// editor.apply(); +// // 服务器返回的token和本地已存的token相同,更新本地时间 +// getTime(context); +// value = response.getString("value"); +// } catch (IOException | JSONException e) { +// e.printStackTrace(); +// } +// return Observable.just(value); +// } +// }).onErrorResumeNext(new Func1>() { +// @Override +// public Observable call(Throwable throwable) { +// return Observable.error(throwable); +// } +// }); +// } +// return Observable.just(token); +// } public static synchronized String getDeviceId(Context context) { return loadSharedPreferences(context, false); @@ -309,46 +291,46 @@ public class TokenUtils { return null; } - // 检查设备信息是否已经上传完整 - public static synchronized void checkDeviceInfo(Context context, String token) { - final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); - final HashMap params = new HashMap<>(); - if (!sp.getBoolean("isUploadExtra", false)) { - params.put("MANUFACTURER", Build.MANUFACTURER); - params.put("MODEL", Build.MODEL); - params.put("ANDROID_SDK", String.valueOf(Build.VERSION.SDK_INT)); - params.put("ANDROID_VERSION", Build.VERSION.RELEASE); - } - if (!sp.getBoolean("isUploadMac", true)) { - WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); - String mac = wm.getConnectionInfo().getMacAddress(); - if (!TextUtils.isEmpty(mac) || !":::::".equals(mac)) { - params.put("MAC", mac); - } - } - if (!sp.getBoolean("isUploadMid", true)) { - String mid = StatConfig.getMid(context); - if (!TextUtils.isEmpty(mid) || !"0".equals(mid)) { - params.put("MTA_ID", mid); - } - } - if (params.size() != 0) { - RequestBody body = RequestBody.create(MediaType.parse("application/json"), - new JSONObject(params).toString()); - RetrofitManager.getInstance(context).getApi().postDevice(token, body, TokenUtils.getDeviceId(context)) - .subscribeOn(Schedulers.io()) - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(new Response() { - @Override - public void onResponse(ResponseBody response) { - SharedPreferences.Editor editor = sp.edit(); - editor.putBoolean("isUploadExtra", true); - editor.putBoolean("isUploadMac", true); - editor.putBoolean("isUploadMid", true); - editor.apply(); - } - }); - } - } +// // 检查设备信息是否已经上传完整 +// public static synchronized void checkDeviceInfo(Context context, String token) { +// final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); +// final HashMap params = new HashMap<>(); +// if (!sp.getBoolean("isUploadExtra", false)) { +// params.put("MANUFACTURER", Build.MANUFACTURER); +// params.put("MODEL", Build.MODEL); +// params.put("ANDROID_SDK", String.valueOf(Build.VERSION.SDK_INT)); +// params.put("ANDROID_VERSION", Build.VERSION.RELEASE); +// } +// if (!sp.getBoolean("isUploadMac", true)) { +// WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); +// String mac = wm.getConnectionInfo().getMacAddress(); +// if (!TextUtils.isEmpty(mac) || !":::::".equals(mac)) { +// params.put("MAC", mac); +// } +// } +// if (!sp.getBoolean("isUploadMid", true)) { +// String mid = StatConfig.getMid(context); +// if (!TextUtils.isEmpty(mid) || !"0".equals(mid)) { +// params.put("MTA_ID", mid); +// } +// } +// if (params.size() != 0) { +// RequestBody body = RequestBody.create(MediaType.parse("application/json"), +// new JSONObject(params).toString()); +// RetrofitManager.getInstance(context).getApi().postDevice(token, body, TokenUtils.getDeviceId(context)) +// .subscribeOn(Schedulers.io()) +// .observeOn(AndroidSchedulers.mainThread()) +// .subscribe(new Response() { +// @Override +// public void onResponse(ResponseBody response) { +// SharedPreferences.Editor editor = sp.edit(); +// editor.putBoolean("isUploadExtra", true); +// editor.putBoolean("isUploadMac", true); +// editor.putBoolean("isUploadMid", true); +// editor.apply(); +// } +// }); +// } +// } } diff --git a/app/src/main/java/com/gh/gamecenter/MainActivity.java b/app/src/main/java/com/gh/gamecenter/MainActivity.java index d58452329b..dbfc2d5054 100644 --- a/app/src/main/java/com/gh/gamecenter/MainActivity.java +++ b/app/src/main/java/com/gh/gamecenter/MainActivity.java @@ -519,7 +519,7 @@ public class MainActivity extends BaseActivity { // 更新用户已安装游戏 RequestBody body = RequestBody.create(MediaType.parse("application/json"), new JSONArray(installed).toString()); - RetrofitManager.getInstance(mContext).getApi().putPackage(LoginUtils.getToken(MainActivity.this), body) + RetrofitManager.getInstance(mContext).getApi().putPackage(body) .subscribeOn(Schedulers.io()) .observeOn(Schedulers.io()) .subscribe(new Response()); @@ -965,7 +965,7 @@ public class MainActivity extends BaseActivity { RequestBody body = RequestBody.create( MediaType.parse("application/json"), params.toString()); RetrofitManager.getInstance(mContext).getApi() - .postPackage(LoginUtils.getToken(MainActivity.this), body) + .postPackage(body) .subscribeOn(Schedulers.io()) .observeOn(Schedulers.io()) .subscribe(new Response()); @@ -976,7 +976,7 @@ public class MainActivity extends BaseActivity { if ("卸载".equals(busFour.getType())) { // 更新已安装游戏 RetrofitManager.getInstance(mContext).getApi() - .deletePackage(LoginUtils.getToken(this), packageName) + .deletePackage(packageName) .subscribeOn(Schedulers.io()) .observeOn(Schedulers.io()) .subscribe(new Response()); diff --git a/app/src/main/java/com/gh/gamecenter/SuggestionActivity.java b/app/src/main/java/com/gh/gamecenter/SuggestionActivity.java index b8e3dc3900..6baa9e47b5 100644 --- a/app/src/main/java/com/gh/gamecenter/SuggestionActivity.java +++ b/app/src/main/java/com/gh/gamecenter/SuggestionActivity.java @@ -532,7 +532,7 @@ public class SuggestionActivity extends BaseActivity implements SuggestTypeAdapt private void sendSuggestion(final RequestBody body) { - RetrofitManager.getInstance(this).getApi().postSuggestion(body, LoginUtils.getToken(this)) + RetrofitManager.getInstance(this).getApi().postSuggestion(body) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new JSONObjectResponse() { diff --git a/app/src/main/java/com/gh/gamecenter/VoteActivity.java b/app/src/main/java/com/gh/gamecenter/VoteActivity.java index 0ad01605d2..3fe9e981dc 100644 --- a/app/src/main/java/com/gh/gamecenter/VoteActivity.java +++ b/app/src/main/java/com/gh/gamecenter/VoteActivity.java @@ -25,7 +25,6 @@ import com.gh.base.BaseActivity; import com.gh.base.OnRequestCallBackListener; import com.gh.common.util.CheckLoginUtils; import com.gh.common.util.DialogUtils; -import com.gh.common.util.LoginUtils; import com.gh.gamecenter.adapter.VoteAdapter; import com.gh.gamecenter.db.VersionVoteDao; import com.gh.gamecenter.db.info.VersionVoteInfo; @@ -258,7 +257,7 @@ public class VoteActivity extends BaseActivity implements SwipeRefreshLayout.OnR final RequestBody body = RequestBody.create(MediaType.parse("application/json"), object.toString()); RetrofitManager.getInstance(this).getApi() - .postVersionVote(LoginUtils.getToken(this), body, mGameId) + .postVersionVote(body, mGameId) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Response() { diff --git a/app/src/main/java/com/gh/gamecenter/collection/ArticleAdapter.java b/app/src/main/java/com/gh/gamecenter/collection/ArticleAdapter.java index c662e92ef6..b683ffc333 100644 --- a/app/src/main/java/com/gh/gamecenter/collection/ArticleAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/collection/ArticleAdapter.java @@ -15,7 +15,6 @@ import com.gh.common.util.DataCollectionUtils; import com.gh.common.util.DataUtils; import com.gh.common.util.DisplayUtils; import com.gh.common.util.ImageUtils; -import com.gh.common.util.LoginUtils; import com.gh.common.util.NewsUtils; import com.gh.gamecenter.NewsDetailActivity; import com.gh.gamecenter.R; @@ -78,7 +77,7 @@ public class ArticleAdapter extends BaseRecyclerAdapter { isLoading = true; RetrofitManager.getInstance(mContext) .getApi() - .getCollectionArticle(LoginUtils.getToken(mContext), offset) + .getCollectionArticle(offset) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Response>(){ diff --git a/app/src/main/java/com/gh/gamecenter/collection/ToolsAdapter.java b/app/src/main/java/com/gh/gamecenter/collection/ToolsAdapter.java index d2c77dddaf..ff123ad266 100644 --- a/app/src/main/java/com/gh/gamecenter/collection/ToolsAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/collection/ToolsAdapter.java @@ -11,7 +11,6 @@ import android.widget.Toast; import com.gh.base.OnRequestCallBackListener; import com.gh.common.util.EntranceUtils; import com.gh.common.util.ImageUtils; -import com.gh.common.util.LoginUtils; import com.gh.gamecenter.NewsDetailActivity; import com.gh.gamecenter.R; import com.gh.gamecenter.WebActivity; @@ -56,7 +55,7 @@ public class ToolsAdapter extends BaseRecyclerAdapter { isLoading = true; RetrofitManager.getInstance(mContext) .getApi() - .getCollectionTools(LoginUtils.getToken(mContext), offset) + .getCollectionTools(offset) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Response>() { diff --git a/app/src/main/java/com/gh/gamecenter/entity/CommentEntity.kt b/app/src/main/java/com/gh/gamecenter/entity/CommentEntity.kt index 372a348664..9991eef235 100644 --- a/app/src/main/java/com/gh/gamecenter/entity/CommentEntity.kt +++ b/app/src/main/java/com/gh/gamecenter/entity/CommentEntity.kt @@ -20,6 +20,8 @@ class CommentEntity { var time: Long = 0 + var userData: UserDataEntity? = null + inner class ParentEntity { var user: UserEntity? = null } diff --git a/app/src/main/java/com/gh/gamecenter/entity/GameDetailEntity.kt b/app/src/main/java/com/gh/gamecenter/entity/GameDetailEntity.kt index d5e25c79c8..d098df3e17 100644 --- a/app/src/main/java/com/gh/gamecenter/entity/GameDetailEntity.kt +++ b/app/src/main/java/com/gh/gamecenter/entity/GameDetailEntity.kt @@ -49,6 +49,8 @@ class GameDetailEntity : Parcelable { var fulishuoming: String? = null + var userData: UserDataEntity? = null + override fun describeContents(): Int { return 0 } @@ -71,6 +73,7 @@ class GameDetailEntity : Parcelable { dest.writeParcelable(this.serverEntity, flags) dest.writeTypedList(this.relatedGames) dest.writeString(this.fulishuoming) + dest.writeParcelable(this.userData, flags) } constructor() {} @@ -93,6 +96,7 @@ class GameDetailEntity : Parcelable { this.serverEntity = `in`.readParcelable(GameDetailServer::class.java.classLoader) this.relatedGames = `in`.createTypedArrayList(GameDetailRelatedGame.CREATOR) this.fulishuoming = `in`.readString() + this.userData = `in`.readParcelable(UserDataEntity::class.java.classLoader) } companion object { diff --git a/app/src/main/java/com/gh/gamecenter/entity/LibaoEntity.kt b/app/src/main/java/com/gh/gamecenter/entity/LibaoEntity.kt index 158d7a4be8..7ca66cc7da 100644 --- a/app/src/main/java/com/gh/gamecenter/entity/LibaoEntity.kt +++ b/app/src/main/java/com/gh/gamecenter/entity/LibaoEntity.kt @@ -47,6 +47,8 @@ class LibaoEntity : Parcelable { var repeat: Int = 0 // 剩余可领取数量 + var userData: UserDataEntity? = null + constructor() override fun describeContents(): Int { @@ -70,6 +72,7 @@ class LibaoEntity : Parcelable { dest.writeByte(if (this.isActive) 1.toByte() else 0.toByte()) dest.writeLong(this.time) dest.writeInt(this.repeat) + dest.writeParcelable(this.userData, flags) } protected constructor(`in`: Parcel) { @@ -89,6 +92,7 @@ class LibaoEntity : Parcelable { this.isActive = `in`.readByte().toInt() != 0 this.time = `in`.readLong() this.repeat = `in`.readInt() + this.userData = `in`.readParcelable(UserDataEntity::class.java.classLoader) } companion object { diff --git a/app/src/main/java/com/gh/gamecenter/entity/NewsDetailEntity.kt b/app/src/main/java/com/gh/gamecenter/entity/NewsDetailEntity.kt index 4599a2e53d..6c8f4348b4 100644 --- a/app/src/main/java/com/gh/gamecenter/entity/NewsDetailEntity.kt +++ b/app/src/main/java/com/gh/gamecenter/entity/NewsDetailEntity.kt @@ -23,4 +23,6 @@ class NewsDetailEntity { //相关推荐 var more: List? = null + var userData: UserDataEntity? = null + } diff --git a/app/src/main/java/com/gh/gamecenter/entity/ToolBoxEntity.kt b/app/src/main/java/com/gh/gamecenter/entity/ToolBoxEntity.kt index dac3124137..9691512b07 100644 --- a/app/src/main/java/com/gh/gamecenter/entity/ToolBoxEntity.kt +++ b/app/src/main/java/com/gh/gamecenter/entity/ToolBoxEntity.kt @@ -23,6 +23,9 @@ class ToolBoxEntity : Parcelable { var time: Long = 0 + var userData: UserDataEntity? = null + + override fun describeContents(): Int { return 0 } @@ -34,6 +37,7 @@ class ToolBoxEntity : Parcelable { dest.writeString(this.des) dest.writeString(this.url) dest.writeLong(this.time) + dest.writeParcelable(this.userData, flags) } constructor() @@ -45,6 +49,7 @@ class ToolBoxEntity : Parcelable { this.des = `in`.readString() this.url = `in`.readString() this.time = `in`.readLong() + this.userData = `in`.readParcelable(UserDataEntity::class.java.classLoader) } companion object { diff --git a/app/src/main/java/com/gh/gamecenter/entity/UserDataEntity.kt b/app/src/main/java/com/gh/gamecenter/entity/UserDataEntity.kt new file mode 100644 index 0000000000..aab9093288 --- /dev/null +++ b/app/src/main/java/com/gh/gamecenter/entity/UserDataEntity.kt @@ -0,0 +1,60 @@ +package com.gh.gamecenter.entity + +import android.os.Parcel +import android.os.Parcelable + +/** + * Created by khy on 14/09/17. + */ + +class UserDataEntity : Parcelable { + + var isGameConcerned: Boolean = false + + var isArticleFavorite: Boolean = false + + var isToolkitFavorite: Boolean = false + + var isCommentOwn: Boolean = false + + var isCommentVoted: Boolean = false + + var userDataLibaoList: List? = null + + override fun describeContents(): Int { + return 0 + } + + override fun writeToParcel(dest: Parcel, flags: Int) { + dest.writeByte(if (this.isGameConcerned) 1.toByte() else 0.toByte()) + dest.writeByte(if (this.isArticleFavorite) 1.toByte() else 0.toByte()) + dest.writeByte(if (this.isToolkitFavorite) 1.toByte() else 0.toByte()) + dest.writeByte(if (this.isCommentOwn) 1.toByte() else 0.toByte()) + dest.writeByte(if (this.isCommentVoted) 1.toByte() else 0.toByte()) + dest.writeTypedList(this.userDataLibaoList) + } + + constructor() {} + + protected constructor(`in`: Parcel) { + this.isGameConcerned = `in`.readByte().toInt() != 0 + this.isArticleFavorite = `in`.readByte().toInt() != 0 + this.isToolkitFavorite = `in`.readByte().toInt() != 0 + this.isCommentOwn = `in`.readByte().toInt() != 0 + this.isCommentVoted = `in`.readByte().toInt() != 0 + this.userDataLibaoList = `in`.createTypedArrayList(UserDataLibaoEntity.CREATOR) + } + + companion object { + + @JvmField val CREATOR: Parcelable.Creator = object : Parcelable.Creator { + override fun createFromParcel(source: Parcel): UserDataEntity { + return UserDataEntity(source) + } + + override fun newArray(size: Int): Array { + return arrayOfNulls(size) + } + } + } +} diff --git a/app/src/main/java/com/gh/gamecenter/entity/UserDataLibaoEntity.kt b/app/src/main/java/com/gh/gamecenter/entity/UserDataLibaoEntity.kt new file mode 100644 index 0000000000..260664ae07 --- /dev/null +++ b/app/src/main/java/com/gh/gamecenter/entity/UserDataLibaoEntity.kt @@ -0,0 +1,48 @@ +package com.gh.gamecenter.entity + +import android.os.Parcel +import android.os.Parcelable + +/** + * Created by khy on 14/09/17. + */ + +class UserDataLibaoEntity : Parcelable { + + var code: String? = null + + var type: String? = null + + var time: Long = 0 + + override fun describeContents(): Int { + return 0 + } + + override fun writeToParcel(dest: Parcel, flags: Int) { + dest.writeString(this.code) + dest.writeString(this.type) + dest.writeLong(this.time) + } + + constructor() {} + + protected constructor(`in`: Parcel) { + this.code = `in`.readString() + this.type = `in`.readString() + this.time = `in`.readLong() + } + + companion object { + + @JvmField val CREATOR: Parcelable.Creator = object : Parcelable.Creator { + override fun createFromParcel(source: Parcel): UserDataLibaoEntity { + return UserDataLibaoEntity(source) + } + + override fun newArray(size: Int): Array { + return arrayOfNulls(size) + } + } + } +} diff --git a/app/src/main/java/com/gh/gamecenter/fragment/MainFragment.java b/app/src/main/java/com/gh/gamecenter/fragment/MainFragment.java index 7bc58807da..c6cf6bd1a1 100644 --- a/app/src/main/java/com/gh/gamecenter/fragment/MainFragment.java +++ b/app/src/main/java/com/gh/gamecenter/fragment/MainFragment.java @@ -7,12 +7,9 @@ import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.View; -import android.view.ViewGroup; -import android.widget.Button; import com.gh.base.SearchBarHint; import com.gh.base.fragment.BaseFragment_ViewPager_Checkable; -import com.gh.common.util.LoginUtils; import com.gh.gamecenter.MainActivity; import com.gh.gamecenter.R; import com.gh.gamecenter.db.MessageMarkReadDao; @@ -196,9 +193,9 @@ public class MainFragment extends BaseFragment_ViewPager_Checkable { final MessageMarkReadDao readDao) { Observable observable; if ("kefu".equals(type)) { - observable = RetrofitManager.getInstance(context).getApi().postMarkKeFuRead(body, LoginUtils.getToken(context)); + observable = RetrofitManager.getInstance(context).getApi().postMarkKeFuRead(body); } else { - observable = RetrofitManager.getInstance(context).getApi().postMarkNoticeRead(body, LoginUtils.getToken(context)); + observable = RetrofitManager.getInstance(context).getApi().postMarkNoticeRead(body); } observable.subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) diff --git a/app/src/main/java/com/gh/gamecenter/geetest/GeetestUtils.java b/app/src/main/java/com/gh/gamecenter/geetest/GeetestUtils.java index 37cf659a8d..3d2a859c6d 100644 --- a/app/src/main/java/com/gh/gamecenter/geetest/GeetestUtils.java +++ b/app/src/main/java/com/gh/gamecenter/geetest/GeetestUtils.java @@ -5,7 +5,6 @@ import android.content.Context; import android.content.DialogInterface; import com.gh.common.util.AppDebugConfig; -import com.gh.common.util.LoginUtils; import com.gh.gamecenter.retrofit.JSONObjectResponse; import com.gh.gamecenter.retrofit.RetrofitManager; import com.lightgame.utils.RuntimeUtils; @@ -68,7 +67,7 @@ public class GeetestUtils { isOperating = true; RetrofitManager.getInstance(context).getApi() - .getCaptchaData(LoginUtils.getToken(context)) + .getCaptchaData() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new JSONObjectResponse() { diff --git a/app/src/main/java/com/gh/gamecenter/message/CommentFragmentAdapter.java b/app/src/main/java/com/gh/gamecenter/message/CommentFragmentAdapter.java index 2ebe9f333e..c065333b26 100644 --- a/app/src/main/java/com/gh/gamecenter/message/CommentFragmentAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/message/CommentFragmentAdapter.java @@ -9,7 +9,6 @@ import android.view.ViewGroup; import com.gh.base.OnRequestCallBackListener; import com.gh.common.util.CommentUtils; import com.gh.common.util.ImageUtils; -import com.gh.common.util.LoginUtils; import com.gh.gamecenter.CommentDetailActivity; import com.gh.gamecenter.MessageDetailActivity; import com.gh.gamecenter.R; @@ -61,7 +60,7 @@ public class CommentFragmentAdapter extends BaseRecyclerAdapter { public void loadData(final int offset) { isLoaded = false; RetrofitManager.getInstance(mContext).getApi() - .getMessageCommentData(LoginUtils.getToken(mContext), offset, 20) + .getMessageCommentData(offset, 20) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Response>() { diff --git a/app/src/main/java/com/gh/gamecenter/message/KeFuFragmentAdapter.java b/app/src/main/java/com/gh/gamecenter/message/KeFuFragmentAdapter.java index fb29d8f56d..cdade55d2a 100644 --- a/app/src/main/java/com/gh/gamecenter/message/KeFuFragmentAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/message/KeFuFragmentAdapter.java @@ -11,7 +11,6 @@ import android.view.ViewGroup; import com.gh.base.OnRequestCallBackListener; import com.gh.common.util.CommentUtils; import com.gh.common.util.EntranceUtils; -import com.gh.common.util.LoginUtils; import com.gh.common.util.QQUtils; import com.gh.gamecenter.GameDetailActivity; import com.gh.gamecenter.NewsDetailActivity; @@ -84,7 +83,7 @@ public class KeFuFragmentAdapter extends BaseRecyclerAdapter { public void loadData(final int offset) { isLoaded = false; RetrofitManager.getInstance(mContext).getApi() - .getMessageKeFuData(LoginUtils.getToken(mContext), offset, 20) + .getMessageKeFuData(offset, 20) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Response>() { @@ -150,7 +149,7 @@ public class KeFuFragmentAdapter extends BaseRecyclerAdapter { final RequestBody body = RequestBody.create(MediaType.parse("application/json"), ids); RetrofitManager.getInstance(mContext).getApi() - .postKeFuDataReceive(body, LoginUtils.getToken(mContext)) + .postKeFuDataReceive(body) .subscribeOn(Schedulers.io()) .observeOn(Schedulers.io()) .subscribe(new Response() { diff --git a/app/src/main/java/com/gh/gamecenter/message/MessageFragment.java b/app/src/main/java/com/gh/gamecenter/message/MessageFragment.java index b02e00af3a..e92460f14f 100644 --- a/app/src/main/java/com/gh/gamecenter/message/MessageFragment.java +++ b/app/src/main/java/com/gh/gamecenter/message/MessageFragment.java @@ -12,7 +12,6 @@ import android.widget.TextView; import com.gh.base.fragment.BaseFragment_ViewPager_Checkable; import com.gh.common.util.DisplayUtils; -import com.gh.common.util.LoginUtils; import com.gh.gamecenter.R; import com.gh.gamecenter.db.KeFuMarkReadDao; import com.gh.gamecenter.entity.MessageUnreadEntity; @@ -123,7 +122,7 @@ public class MessageFragment extends BaseFragment_ViewPager_Checkable { private void initMessageUnread(final Context context) { RetrofitManager.getInstance(context).getApi() - .getMessageUnread(LoginUtils.getToken(context)) + .getMessageUnread() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Response() { @@ -176,7 +175,7 @@ public class MessageFragment extends BaseFragment_ViewPager_Checkable { private void postMarkCommentRead(final Context context) { RetrofitManager.getInstance(context).getApi() - .postMarkCommentRead(LoginUtils.getToken(context)) + .postMarkCommentRead() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Response() { diff --git a/app/src/main/java/com/gh/gamecenter/message/NoticeFragmentAdapter.java b/app/src/main/java/com/gh/gamecenter/message/NoticeFragmentAdapter.java index 10caf3ca4a..e2fa05c0b6 100644 --- a/app/src/main/java/com/gh/gamecenter/message/NoticeFragmentAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/message/NoticeFragmentAdapter.java @@ -11,7 +11,6 @@ import android.view.ViewGroup; import com.gh.base.OnRequestCallBackListener; import com.gh.common.util.CommentUtils; import com.gh.common.util.EntranceUtils; -import com.gh.common.util.LoginUtils; import com.gh.common.util.QQUtils; import com.gh.gamecenter.GameDetailActivity; import com.gh.gamecenter.NewsDetailActivity; @@ -82,7 +81,7 @@ public class NoticeFragmentAdapter extends BaseRecyclerAdapter { public void loadData(final int offset) { isLoaded = false; RetrofitManager.getInstance(mContext).getApi() - .getMessageNoticeData(LoginUtils.getToken(mContext), offset, 20) + .getMessageNoticeData(offset, 20) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Response>() { @@ -157,7 +156,7 @@ public class NoticeFragmentAdapter extends BaseRecyclerAdapter { final RequestBody body = RequestBody.create(MediaType.parse("application/json"), ids); RetrofitManager.getInstance(mContext).getApi() - .postNoticeDataReceive(body, LoginUtils.getToken(mContext)) + .postNoticeDataReceive(body) .subscribeOn(Schedulers.io()) .observeOn(Schedulers.io()) .subscribe(new Response() { diff --git a/app/src/main/java/com/gh/gamecenter/personal/PersonalFragment.java b/app/src/main/java/com/gh/gamecenter/personal/PersonalFragment.java index ea6c12e316..eda9a52507 100644 --- a/app/src/main/java/com/gh/gamecenter/personal/PersonalFragment.java +++ b/app/src/main/java/com/gh/gamecenter/personal/PersonalFragment.java @@ -253,7 +253,7 @@ public class PersonalFragment extends BaseFragment implements GetLoginDataUtils. if (context == null) return; RetrofitManager.getInstance(context).getApi() - .getMessageUnread(LoginUtils.getToken(context)) + .getMessageUnread() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Response() { diff --git a/app/src/main/java/com/gh/gamecenter/retrofit/OkHttpCacheInterceptor.java b/app/src/main/java/com/gh/gamecenter/retrofit/OkHttpCacheInterceptor.java index ecd1fcfe64..4609905ea4 100644 --- a/app/src/main/java/com/gh/gamecenter/retrofit/OkHttpCacheInterceptor.java +++ b/app/src/main/java/com/gh/gamecenter/retrofit/OkHttpCacheInterceptor.java @@ -1,10 +1,12 @@ package com.gh.gamecenter.retrofit; import android.content.Context; +import android.text.TextUtils; import com.gh.common.constant.Config; import com.gh.common.util.GzipUtils; import com.gh.common.util.HMACUtils; +import com.gh.common.util.LoginUtils; import com.gh.common.util.NetworkUtils; import com.gh.common.util.StringUtils; import com.gh.common.util.TimestampUtils; @@ -59,6 +61,13 @@ class OkHttpCacheInterceptor implements Interceptor { .build(); } + String token = LoginUtils.getToken(mContext); + if (!TextUtils.isEmpty(token)) { // 数据接口全局添加token + request = request.newBuilder() + .addHeader("TOKEN", token) + .build(); + } + // log 打印 // Utils.log(String.format("Interceptor Sending request %s on %s%n%s", // request.url(), chain.connection(), request.headers())); 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 39cfb21781..2740c9b00d 100644 --- a/app/src/main/java/com/gh/gamecenter/retrofit/OkHttpRetryInterceptor.kt +++ b/app/src/main/java/com/gh/gamecenter/retrofit/OkHttpRetryInterceptor.kt @@ -78,12 +78,10 @@ class OkHttpRetryInterceptor internal constructor(context: Context) : Intercepto .subscribe(object : com.gh.gamecenter.retrofit.Response() { override fun onResponse(loginResponseEntity: LoginResponseEntity?) { LoginUtils.saveLoginToken(mContext, loginResponseEntity) - val accessToken = loginResponseEntity?.accessToken?.value -// Utils.log("=======accessToken::" + accessToken) RetrofitManager.getInstance(mContext) .getApi() - .getUserInfo(accessToken) + .getUserInfo() .subscribe(object : com.gh.gamecenter.retrofit.Response(){ override fun onResponse(userInfo: UserInfoEntity?) { super.onResponse(userInfo) diff --git a/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java b/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java index 4bde01d93e..f18ca32055 100644 --- a/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java +++ b/app/src/main/java/com/gh/gamecenter/retrofit/service/ApiService.java @@ -51,405 +51,657 @@ import rx.Observable; */ public interface ApiService { + /** + * 获取资讯-关注 根据key + */ @GET("zixun/guanzhu?limit=20") - Observable> getGuanZhuByKey(@Query("key") String key, @Query("offset") int offset); // 获取资讯-关注 根据key + Observable> getGuanZhuByKey(@Query("key") String key, @Query("offset") int offset); + /** + * 获取资讯-关注 根据id + */ @GET("zixun/guanzhu?limit=20") - Observable> getGuanZhuById(@Query("game_id") String game_id, @Query("offset") int offset); // 获取资讯-关注 根据id + Observable> getGuanZhuById(@Query("game_id") String game_id, @Query("offset") int offset); + /** + * 获取资讯-资讯 + */ @GET("zixun/zixun?limit=20") - Observable> getZiXun(@Query("offset") int offset); // 获取资讯-资讯 + Observable> getZiXun(@Query("offset") int offset); + /** + * 获取资讯-原创 + */ @GET("zixun/yuanchuang?limit=20") - Observable> getYuanChuang(@Query("offset") int offset); // 获取资讯-原创 + Observable> getYuanChuang(@Query("offset") int offset); + /** + * 获取资讯-攻略 + */ @GET("article") Observable> getNews(@Query("type_group") String type_group, - @Query("limit") int limit, @Query("offset") int offset); // 获取资讯-原创 + @Query("limit") int limit, @Query("offset") int offset); + /** + * 获取游戏摘要 + */ @GET("game/{game_id}/digest") - Observable getGameDigest(@Path("game_id") String game_id); // 获取游戏摘要 + Observable getGameDigest(@Path("game_id") String game_id); + /** + * 获取游戏新闻摘要 + */ @GET("game/{game_id}/article_digest") - Observable getGameNewsDigest(@Path("game_id") String game_id); // 获取游戏新闻摘要 + Observable getGameNewsDigest(@Path("game_id") String game_id); + /** + * 获取游戏详情 + */ @GET("game/{game_id}/detail") - Observable getGameDetail(@Path("game_id") String game_id); // 获取游戏详情 + Observable getGameDetail(@Path("game_id") String game_id); + /** + * 获取热门卡牌 + */ @GET("game/remenkapai") - Observable> getRemenkapai(); // 获取热门卡牌 + Observable> getRemenkapai(); + /** + * 获取服务器时间 + */ @GET("support/time/current") - Observable getTime();// 获取服务器时间 + Observable getTime(); + /** + * 统计下载量 + */ @Headers({"Content-Type: application/json", "Accept: application/json"}) @POST("stat/download") - Observable postDownload(@Body RequestBody body); // 统计下载量 + Observable postDownload(@Body RequestBody body); + /** + * 根据包名获取游戏摘要 + */ @GET("support/package/{package_name}/game/digest") - Observable> getGameDigestByPackageName(@Path("package_name") String package_name); // 根据包名获取游戏摘要 + Observable> getGameDigestByPackageName(@Path("package_name") String package_name); + /** + * 获取游戏更新 + */ @GET("update/package/{package_name}") - Observable getGameUpdate(@Path("package_name") String package_name);// 获取游戏更新 + Observable getGameUpdate(@Path("package_name") String package_name); + /** + * 获取游戏更新 + */ @GET("update/game/{gh_id}/package/{package_name}") Observable getGameUpdate(@Path("gh_id") String gh_id, - @Path("package_name") String package_name);// 获取游戏更新 + @Path("package_name") String package_name); + /** + * 获取搜索关键字 + */ @GET("search/game/default") - Observable> getSearchHints(); // 获取搜索关键字 + Observable> getSearchHints(); + /** + * 获取助手更新 + */ @GET("support/upgrade") - Observable getUpdate(@Query("version") String version, @Query("channel") String channel); // 获取助手更新 + Observable getUpdate(@Query("version") String version, @Query("channel") String channel); + /** + * 获取新闻详情 + */ @GET("article/{news_id}/detail") - Observable getNewsDetail(@Path("news_id") String news_id); // 获取新闻详情 + Observable getNewsDetail(@Path("news_id") String news_id); + /** + * 获取新闻摘要 + */ @GET("article/{news_id}/digest") Observable getNewsDigest(@Path("news_id") String news_id); // 获取新闻摘要 + /** + * 获取新闻相关推荐 + */ @GET("article/{news_id}/suggestion") - Observable> getNewsSuggestion(@Path("news_id") String news_id); // 获取新闻相关推荐 - - @GET("skin/gameInfo/{game_id}") - Observable getGameSkin(@Path("game_id") String game_id); // 获取游戏皮肤信息 + Observable> getNewsSuggestion(@Path("news_id") String news_id); + /** + * 获取游戏新闻 + */ @GET("game/{game_id}/article") Observable> getGameNews(@Path("game_id") String game_id, @Query("limit") int limit, - @Query("offset") int offset, @Query("type") String type); // 获取游戏新闻 + @Query("offset") int offset, @Query("type") String type); + /** + * 获取游戏攻略 + */ @GET("game/{game_id}/article") Observable> getGameNews(@Path("game_id") String game_id, @Query("limit") int limit, - @Query("type_group") String type, @Query("offset") int offset); // 获取游戏攻略 + @Query("type_group") String type, @Query("offset") int offset); + /** + * 获取游戏新闻 + */ @GET("game/{game_id}/article") Observable> getGameNews(@Path("game_id") String game_id, @Query("limit") int limit, - @Query("offset") int offset); // 获取游戏新闻 + @Query("offset") int offset); + /** + * 获取游戏新闻 + */ @GET("game/{game_id}/article") - Observable> getGameNews(@Path("game_id") String game_id, @Query("limit") int limit); // 获取游戏新闻 + Observable> getGameNews(@Path("game_id") String game_id, @Query("limit") int limit); + /** + * 获取游戏开服信息 + */ @GET("game/{game_id}/serverInfo") - Observable getGameServer(@Path("game_id") String game_id); // 获取游戏开服信息 + Observable getGameServer(@Path("game_id") String game_id); + /** + * 获取游戏平台信息 + */ @GET("support/setting/platform") - Observable> getGamePlatform(); // 获取游戏平台信息 + Observable> getGamePlatform(); + /** + * 获取新闻rich摘要 + */ @GET("article/{news_id}/rich-digest") - Observable getNewsRichDigest(@Path("news_id") String news_id); // 获取新闻rich摘要 + Observable getNewsRichDigest(@Path("news_id") String news_id); + /** + * 搜索新闻 + */ @GET("search/article") Observable> getSearchNews(@Query("game_id") String game_id, @Query("keyword") String keyword, - @Query("page") int page, @Query("limit") int limit); // 搜索新闻 + @Query("page") int page, @Query("limit") int limit); + /** + * 搜索游戏 + */ @GET("search/game") - Observable> getSearchGame(@Query("keyword") String keyword); // 搜索游戏 + Observable> getSearchGame(@Query("keyword") String keyword); + /** + * 获取首页滚动图 + */ @GET("index/slides") - Observable> getSlide(); // 获取首页滚动图 + Observable> getSlide(); + /** + * 获取游戏插件专题数据 + */ @GET("index/column") - Observable> getColumn(); // 获取游戏插件专题数据 + Observable> getColumn(); + /** + * 获取专题数据 + */ @GET("column/{column_id}/content") Observable> getColumn(@Path("column_id") String column_id, @Query("order") String order, - @Query("page") int page, @Query("type") String type); // 获取专题数据 + @Query("page") int page, @Query("type") String type); + /** + * 获取专题数据标题 + */ @GET("column/{column_id}/settings") - Observable getColumnSettings(@Path("column_id") String column_id); // 获取专题数据标题 + Observable getColumnSettings(@Path("column_id") String column_id); + /** + * 获取界面设置参数 + */ @GET("support/setting/ui") - Observable getUISetting(); // 获取界面设置参数 + Observable getUISetting(); + /** + * 获取下载按钮显示状态 + */ @GET("support/download_status") - Observable getDownloadStatus(@Query("version") String version, @Query("channel") String channel); // 获取界面设置参数 + Observable getDownloadStatus(@Query("version") String version, @Query("channel") String channel); + /** + * 获取主页专题入口数据 + */ @GET("index/recommend") - Observable> getSubjectDigest(); //获取主页专题入口数据 + Observable> getSubjectDigest(); + /** + * 获取专题游戏 用于主页换一批 + */ @GET("column/{subject_id}/huanyihuan") - Observable> getSubjectGame(@Path("subject_id") String subject_id); //获取专题游戏 用于主页换一批 + Observable> getSubjectGame(@Path("subject_id") String subject_id); + /** + * 上传意见反馈 + */ @Headers({"Content-Type: application/json", "Accept: application/json"}) @POST("support/user/suggestion") - Observable postSuggestion(@Body RequestBody body, @Header("TOKEN") String token); // 上传意见反馈 + Observable postSuggestion(@Body RequestBody body); + /** + * 获取有用包名 + */ @GET("support/package/in-use") - Observable> getPackageUsed(@Query("since") long since, @Query("skip") long skip); // 获取有用包名 + Observable> getPackageUsed(@Query("since") long since, @Query("skip") long skip); + /** + * 获取设备关注数据 针对助手2.3版本关注数据的迁移 + */ @GET("device/{device_id}/concern") - Observable> getConcernData(@Path("device_id") String device_id); // 获取设备关注数据 针对助手2.3版本关注数据的迁移 + Observable> getConcernData(@Path("device_id") String device_id); + /** + * 根据专题ID获取专题名称 + */ @GET("column/{column_id}/name") - Observable getSubjectName(@Path("column_id") String column_id); //根据专题ID获取专题名称 + Observable getSubjectName(@Path("column_id") String column_id); + /** + * 获取游戏的所有标签 + */ @GET("game/digest/tags") - Observable> getTags(); //获取游戏的所有标签 + Observable> getTags(); + /** + * 获取热门搜索 + */ @GET("search/game/remen") - Observable getHotSearch(); // 获取热门搜索 - - @GET("game/server/offset") - Observable getKaiFuOffset(@Query("type") String type); // 获取开服表偏移量 + Observable getHotSearch(); + /** + * 获取开服表数据 + */ @GET("game/server") - Observable> getKaiFuData(@Query("type") String type, @Query("day") String day, @Query("offset") int offset, @Query("limit") int limit); // 获取开服表数据 + Observable> getKaiFuData(@Query("type") String type, @Query("day") String day, + @Query("offset") int offset, @Query("limit") int limit); + /** + * 获取游戏新闻类型 + */ @GET("game/{game_id}/article_type") - Observable> getGameArticleType(@Path("game_id") String gameId); // 获取游戏新闻类型 + Observable> getGameArticleType(@Path("game_id") String gameId); + /** + * 获取意见反馈的问题选项 + */ @GET("support/setting/suggestion") - Observable getSuggestionType(); // 获取意见反馈的问题选项 + Observable getSuggestionType(); + /** + * 获取投票 游戏求版本列表 + */ @GET("game/{game_id}/version/request") - Observable> getVersionVote(@Path("game_id") String gameId, @Query("offset") int offset, @Query("limit") int limit); //获取投票 游戏求版本列表 + Observable> getVersionVote(@Path("game_id") String gameId, @Query("offset") int offset, + @Query("limit") int limit); + /** + * 提交投票 + */ @Headers({"Content-Type: application/json", "Accept: application/json"}) @POST("game/{game_id}/version/request/vote") - Observable postVersionVote(@Header("TOKEN") String token, @Body RequestBody body, @Path("game_id") String gameId);//提交投票 + Observable postVersionVote(@Body RequestBody body, @Path("game_id") String gameId); + /** + * 根据game_id获取工具箱数据 + */ @GET("game/{game_id}/toolkit") Observable> getGameToolBoxData(@Path("game_id") String gameId, @Query("offset") int offset); + /** + * 根据关键字获取工具箱信息(搜索) + */ @GET("toolkit") Observable> getToolBoxData(@Query("offset") int offset, @Query("keyword") String keyword); + /** + * 排除已关注的工具箱数据 + */ @GET("toolkit") Observable> getToolBoxDataExclude(@Query("offset") int offset, @Query("key_exclude") String excludeKey, @Query("keyword") String keyword); + /** + * 获取已关注的工具箱数据 + */ @GET("toolkit") Observable> getToolBoxData(@Query("offset") int offset, @Query("key") String key, @Query("keyword") String keyword); + /** + * 根据工具箱id获取工具箱详情数据 + */ @GET("toolkit") Observable> getToolBoxById(@Query("id") String toolsId); + /** + * 增加收藏的工具 + */ @POST("favorite/toolkit") - Observable postCollectionTools(@Header("TOKEN") String token, @Body RequestBody body); // 增加收藏的工具 + Observable postCollectionTools(@Body RequestBody body); + /** + * 增加收藏的文章 + */ @POST("favorite/article") - Observable postCollectionArticle(@Header("TOKEN") String token, @Body RequestBody body); // 增加收藏的文章 + Observable postCollectionArticle(@Body RequestBody body); + /** + * 获取收藏的工具 + */ @GET("favorite/toolkit") - Observable> getCollectionTools(@Header("TOKEN") String token, @Query("offset") int offset); // 获取收藏的工具 + Observable> getCollectionTools(@Query("offset") int offset); + /** + * 获取收藏的文章 + */ @GET("favorite/article") - Observable> getCollectionArticle(@Header("TOKEN") String token, @Query("offset") int offset); // 获取收藏的文章 + Observable> getCollectionArticle(@Query("offset") int offset); + /** + * 删除收藏的文章 + */ @DELETE("favorite/toolkit/{toolsid}") - Observable deleteCollectionTools(@Header("TOKEN") String token, @Path("toolsid") String toolsId); // 删除收藏的文章 + Observable deleteCollectionTools(@Path("toolsid") String toolsId); + /** + * 删除收藏的工具 + */ @DELETE("favorite/article/{articleid}") - Observable deletaCollectionArticle(@Header("TOKEN") String token, @Path("articleid") String articleId); // 删除收藏的工具 + Observable deletaCollectionArticle(@Path("articleid") String articleId); + /** + * 修改收藏的文章 + */ @PATCH("favorite/toolkit/{toolsid}") - Observable patchCollectionTools(@Header("TOKEN") String token, @Path("toolsid") String toolsId); // 修改收藏的文章 + Observable patchCollectionTools(@Path("toolsid") String toolsId); + /** + * 修改收藏的工具 + */ @PATCH("favorite/article/{articleid}") - Observable patchCollectionArticle(@Header("TOKEN") String token, @Path("articleid") String articleId); // 修改收藏的工具 + Observable patchCollectionArticle(@Path("articleid") String articleId); + /** + * 根据设备信息判断用户是否是新用户 + */ @Headers({"Content-Type: application/json", "Accept: application/json"}) @POST("user/device") - Observable checkDevice(@Body RequestBody body); // 根据设备信息判断用户是否是新用户 + Observable checkDevice(@Body RequestBody body); + /** + * 将老用户的数据同步到 3.0 版本的数据中 + */ @Headers({"Content-Type: application/json", "Accept: application/json"}) @POST("user/sync") - Observable syncUserData(@Header("TOKEN") String token, @Body RequestBody body); // 将老用户的数据同步到 3.0 版本的数据中 + Observable syncUserData(@Body RequestBody body); - // 获取用户信息(头像/用户名) + /** + * 获取用户信息(头像/用户名) + */ @GET("user/info") - Observable getUserInfo(@Header("TOKEN") String token); + Observable getUserInfo(); + /** + * 检查手机号码是否可用 + */ @GET("user/mobile/{phoneNum}") Observable checkPhoneNum(@Path("phoneNum") String phoneNum); + /** + * 添加关注 + */ @Headers({"Content-Type: application/json", "Accept: application/json"}) @POST("concern/game") - // 添加关注 - Observable postConcern(@Header("TOKEN") String token, @Body RequestBody body); + Observable postConcern(@Body RequestBody body); + /** + * 删除关注 + */ @DELETE("concern/game/{game_id}") - // 删除关注 - Observable deleteConcern(@Header("TOKEN") String token, @Path("game_id") String game_id); + Observable deleteConcern(@Path("game_id") String game_id); + /** + * 整体更新设备关注 + */ @Headers({"Content-Type: application/json", "Accept: application/json"}) @PUT("concern/game") - // 整体更新设备关注 - Observable putConcern(@Header("TOKEN") String token, @Body RequestBody body); + Observable putConcern(@Body RequestBody body); + /** + * 获取设备关注数据 + */ @GET("concern/game") - // 获取设备关注数据 - Observable> getConcern(@Header("TOKEN") String token); + Observable> getConcern(); + /** + * 添加已安装游戏 + */ @Headers({"Content-Type: application/json", "Accept: application/json"}) @POST("package") - // 添加已安装游戏 - Observable postPackage(@Header("TOKEN") String token, @Body RequestBody body); + Observable postPackage(@Body RequestBody body); + /** + * 删除已安装游戏 + */ @DELETE("package/{package_name}") - // 删除已安装游戏 - Observable deletePackage(@Header("TOKEN") String token, @Path("package_name") String package_name); + Observable deletePackage(@Path("package_name") String package_name); + /** + * 整体更新设备已安装游戏 + */ @Headers({"Content-Type: application/json", "Accept: application/json"}) @PUT("package") - // 整体更新设备已安装游戏 - Observable putPackage(@Header("TOKEN") String token, @Body RequestBody body); - -// @Headers({"Content-Type: application/json", "Accept: application/json"}) -// @POST("ghzs") -// // 上传用户所使用的助手信息 -// Observable postGhzs(@Header("TOKEN") String token, @Body RequestBody body); + Observable putPackage(@Body RequestBody body); /*********** CommentService ************/ + /** + * 获取新闻评论数 + */ @GET("article/{ids}/comment/num") - // 获取新闻评论数 Observable> getNewsCommentnum(@Path("ids") String ids); + /** + * 提交举报信息 + */ @POST("report") - //提交举报信息 - Observable postReportData(@Body RequestBody reportData, @Header("TOKEN") String token); + Observable postReportData(@Body RequestBody reportData); + /** + * 发布评论 + */ @Headers({"Content-Type: application/json", "Accept: application/json"}) @POST("article/{news_id}/comment") - // 发布评论 - Observable postNewsComment(@Header("TOKEN") String token, @Path("news_id") String news_id, + Observable postNewsComment(@Path("news_id") String news_id, @Body RequestBody body); + /** + * 评论点赞 + */ @POST("comment/{comment_id}/vote") - // 评论点赞 - Observable postCommentVote(@Header("TOKEN") String token, @Path("comment_id") String comment_id); + Observable postCommentVote(@Path("comment_id") String comment_id); + /** + * 获取新闻评论 + */ @GET("article/{news_id}/comment?order=hot") - // 获取新闻评论 Observable> getHotComment(@Path("news_id") String news_id, @Query("limit") int limit, @Query("offset") int offset); + /** + * 获取新闻评论 + */ @GET("article/{news_id}/comment") - // 获取新闻评论 Observable> getComment(@Path("news_id") String news_id, @Query("limit") int limit, @Query("offset") int offset); + /** + * 发布评论 + */ @Headers({"Content-Type: application/json", "Accept: application/json"}) @POST("article/comment/{comment_id}/reply") - // 发布评论 - Observable postReplyComment(@Header("TOKEN") String token, @Path("comment_id") String comment_id, + Observable postReplyComment(@Path("comment_id") String comment_id, @Body RequestBody body); + /** + * 获取评论对话 + */ @GET("article/comment/{comment_id}/trace") - // 获取评论对话 Observable> getCommentTrace(@Path("comment_id") String news_id, @Query("limit") int limit, @Query("offset") int offset); /********* LibaoService ********/ + /** + * 获取礼包列表数据 + */ @GET("libao?limit=20") - Observable> getLibao(@Query("offset") int offset); //获取礼包列表数据 + Observable> getLibao(@Query("offset") int offset); + /** + * 搜索礼包列表数据 + */ @GET("libao?limit=20") - Observable> getLibaoBySearch(@Query("keyword") String searchKey, @Query("offset") int offset); //搜索礼包列表数据 + Observable> getLibaoBySearch(@Query("keyword") String searchKey, @Query("offset") int offset); + /** + * 关注礼包列表数据 + */ @GET("libao?limit=20") - Observable> getLibaoByConcern(@Query("key") String key, @Query("offset") int offset); //关注礼包列表数据 + Observable> getLibaoByConcern(@Query("key") String key, @Query("offset") int offset); + /** + * 获取游戏详情礼包数据 + */ @GET("libao") Observable> getLibaoByGame(@Query("game_id") String libaoId, - @Query("offset") int offset, @Query("limit") int limit); //获取游戏详情礼包数据 + @Query("offset") int offset, @Query("limit") int limit); + /** + * 获取礼包详情数据 + */ @GET("libao/{libao_id}/detail") - Observable getLibaoDetail(@Path("libao_id") String libaoId); //获取礼包详情数据 + Observable getLibaoDetail(@Path("libao_id") String libaoId); + /** + * 获取礼包摘要数据 + */ @GET("libao/{libao_id}/digest") - Observable getLibaoDigest(@Path("libao_id") String libaoId); //获取礼包摘要数据 + Observable getLibaoDigest(@Path("libao_id") String libaoId); + /** + * 获取礼包领取按钮状态 + */ @GET("libao/status") - Observable> getLibaoStatus(@Query("ids") String libaoIds); //获取礼包领取按钮状态 + Observable> getLibaoStatus(@Query("ids") String libaoIds); + /** + * 获取礼包存号箱数据 + */ @GET("libao/cunhaoxiang") - Observable> getCunHaoXiang(@Header("TOKEN") String token); // 获取礼包存号箱数据 + Observable> getCunHaoXiang(); + /** + * 领取礼包 + */ @POST("libao/{libao_id}/ling") - Observable postLibaoLing(@Header("TOKEN") String token, @Path("libao_id") String libaoId); // 领取礼包 + Observable postLibaoLing(@Path("libao_id") String libaoId); + /** + * 领取礼包 带验证数据 + */ @POST("libao/{libao_id}/ling") - Observable postLibaoLing(@Header("TOKEN") String token, @Header("CODE") String captchaCode, - @Path("libao_id") String libaoId); // 领取礼包 带验证数据 + Observable postLibaoLing(@Header("CODE") String captchaCode, + @Path("libao_id") String libaoId); + /** + * 礼包 淘号 + */ @POST("libao/{libao_id}/tao") - Observable postLibaoTao(@Header("TOKEN") String token, @Path("libao_id") String libaoId); // 礼包 淘号 + Observable postLibaoTao(@Path("libao_id") String libaoId); + /** + * 删除存号箱的礼包 + */ @DELETE("libao/code/{code}") - Observable deleteLibaoCode(@Header("TOKEN") String token, @Path("code") String code); //删除存号箱的礼包 + Observable deleteLibaoCode(@Path("code") String code); + /** + * 获取验证码数据 + */ @POST("libao/captcha") - Observable getCaptchaData(@Header("TOKEN") String token); //获取验证码数据 + Observable getCaptchaData(); + /** + * 获取历史礼包数据 + */ @GET("libao") - Observable> getHistoryLibao(@Query("history") String history, @Query("offset") int offset); //获取历史礼包数据 + Observable> getHistoryLibao(@Query("history") String history, @Query("offset") int offset); /***************8 MessageService *******/ + /** + * 获取消息-客服数据 + */ @GET("message/private") - Observable> getMessageKeFuData(@Header("TOKEN") String token, - @Query("offset") int offset, @Query("limit") int limit); // 获取消息-客服数据 + Observable> getMessageKeFuData(@Query("offset") int offset, @Query("limit") int limit); + /** + * 获取消息未读数据 + */ @GET("message/sync") - Observable getMessageUnread(@Header("TOKEN") String token); // 获取消息未读数据 + Observable getMessageUnread(); + /** + * 确认接收客服消息 + */ @Headers({"Content-Type: application/json", "Accept: application/json"}) @POST("message/private/confirm/receive") - Observable postKeFuDataReceive(@Body RequestBody body, @Header("TOKEN") String token); //确认接收客服消息 + Observable postKeFuDataReceive(@Body RequestBody body); + /** + * 提交已读客服消息 + */ @Headers({"Content-Type: application/json", "Accept: application/json"}) @POST("message/private/confirm/read") - Observable postMarkKeFuRead(@Body RequestBody body, @Header("TOKEN") String token); //提交已读客服消息 + Observable postMarkKeFuRead(@Body RequestBody body); + /** + * 获取消息-客服数据 + */ @GET("message/user/announcement") - Observable> getMessageNoticeData(@Header("TOKEN") String token, - @Query("offset") int offset, @Query("limit") int limit); // 获取消息-客服数据 + Observable> getMessageNoticeData(@Query("offset") int offset, @Query("limit") int limit); + /** + * 提交已读公告消息 + */ @Headers({"Content-Type: application/json", "Accept: application/json"}) @POST("message/user/announcement/confirm/read") - Observable postMarkNoticeRead(@Body RequestBody body, @Header("TOKEN") String token); //提交已读公告消息 + Observable postMarkNoticeRead(@Body RequestBody body); + /** + * 提交已读客服消息 + */ @Headers({"Content-Type: application/json", "Accept: application/json"}) @POST("message/user/announcement/confirm/receive") - Observable postNoticeDataReceive(@Body RequestBody body, @Header("TOKEN") String token); //提交已读客服消息 + Observable postNoticeDataReceive(@Body RequestBody body); + /** + * 获取消息-评论数据 + */ @GET("message/user/comment") - Observable> getMessageCommentData(@Header("TOKEN") String token, - @Query("offset") int offset, @Query("limit") int limit); // 获取消息-评论数据 + Observable> getMessageCommentData(@Query("offset") int offset, @Query("limit") int limit); + /** + * 提交已读评论消息 + */ @Headers({"Content-Type: application/json", "Accept: application/json"}) @POST("message/user/comment/confirm/read") - Observable postMarkCommentRead(@Header("TOKEN") String token); //提交已读评论消息 - - - /********* UserService ***********/ - @Headers({"Content-Type: application/json", "Accept: application/json"}) - @POST("name") - Observable postName(@Header("TOKEN") String token, @Body RequestBody body); // 修改昵称 - - @Headers({"Content-Type: application/json", "Accept: application/json"}) - @POST("device/{device_id}") - Observable postDevice(@Header("TOKEN") String token, @Body RequestBody body, - @Path("device_id") String device_id); // 修改设备信息 - - - @Headers({"Content-Type: application/json", "Accept: application/json"}) - @POST("device/register") - Observable postRegister(@Body RequestBody body); // 注册设备 - - @Headers({"Content-Type: application/json", "Accept: application/json"}) - @POST("login") - Observable postLogin(@Body RequestBody body); // 用户登录 - - @Headers({"Content-Type: application/json", "Accept: application/json"}) - @POST("icon-default") - // 上传用户所使用的助手信息 - Observable postDefaultIcon(@Header("TOKEN") String token, @Body RequestBody body); - + Observable postMarkCommentRead(); } \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/retrofit/service/DataService.java b/app/src/main/java/com/gh/gamecenter/retrofit/service/DataService.java index f565f34e07..0a0f1ac628 100644 --- a/app/src/main/java/com/gh/gamecenter/retrofit/service/DataService.java +++ b/app/src/main/java/com/gh/gamecenter/retrofit/service/DataService.java @@ -20,27 +20,37 @@ import rx.Observable; */ public interface DataService { + /** + * 获取新闻阅读量 + */ @GET("v1d46/news/{ids}/visit") - // 获取新闻阅读量 Observable> getNewsViews(@Path("ids") String ids); + /** + * 统计新闻阅读量 + */ @POST("news/stat") - // 统计新闻阅读量 Observable postNewsViews(@Query("news_id") String news_id); + /** + * 上传log + */ @Headers({"Content-Type: application/json", "Accept: application/json"}) @POST("api/v1d0/log") - // 上传log Observable postLog(@Body RequestBody body); + /** + * 上传实时数据 + */ @Headers({"Content-Type: application/json", "Accept: application/json"}) @POST("collection/upload2") - // 上传实时数据 Observable postRealData(@Body RequestBody body); + /** + * 上传数据 + */ @Headers({"Content-Type: application/json", "Accept: application/json"}) @POST("collection/upload") - // 上传数据 Observable postData(@Body RequestBody body); } diff --git a/app/src/main/java/com/gh/gamecenter/retrofit/service/UserseaService.java b/app/src/main/java/com/gh/gamecenter/retrofit/service/UserseaService.java index 6cb832130c..c0eb7b68fc 100644 --- a/app/src/main/java/com/gh/gamecenter/retrofit/service/UserseaService.java +++ b/app/src/main/java/com/gh/gamecenter/retrofit/service/UserseaService.java @@ -1,13 +1,10 @@ package com.gh.gamecenter.retrofit.service; import com.gh.gamecenter.entity.LoginResponseEntity; -import com.gh.gamecenter.entity.UserInfoEntity; import okhttp3.RequestBody; import okhttp3.ResponseBody; import retrofit2.http.Body; -import retrofit2.http.GET; -import retrofit2.http.Header; import retrofit2.http.Headers; import retrofit2.http.PATCH; import retrofit2.http.POST; @@ -19,47 +16,59 @@ import rx.Observable; public interface UserseaService { - // 手机登录获取验证码 + /** + * 手机登录获取验证码 + */ @Headers({"Content-Type: application/json", "Accept: application/json"}) @POST("login/mobile?step=1") Observable loginByCaptcha(@Body RequestBody body); - // 手机登录 + /** + * 手机登录 + */ @Headers({"Content-Type: application/json", "Accept: application/json"}) @POST("login/mobile?step=2") Observable loginByMobile(@Body RequestBody body); - // QQ登录 + /** + * QQ登录 + */ @Headers({"Content-Type: application/json", "Accept: application/json"}) @POST("login/qq") Observable loginByQQ(@Body RequestBody body); - // 微博登录 + /** + * 微博登录 + */ @Headers({"Content-Type: application/json", "Accept: application/json"}) @POST("login/weibo") Observable loginByWeibo(@Body RequestBody body); - // 微信登录 + /** + * 微信登录 + */ @Headers({"Content-Type: application/json", "Accept: application/json"}) @POST("login/wechat") Observable loginByWechat(@Body RequestBody body); - // 获取用户信息(头像/用户名) - @GET("profile") - Observable getUserInfo(@Header("TOKEN") String token); - - // 刷新accessToken + /** + * 刷新accessToken + */ @Headers({"Content-Type: application/json", "Accept: application/json"}) @POST("refresh") Observable refreshToken(@Body RequestBody body); - // 修改用户信息 + /** + * 修改用户信息 + */ @Headers({"Content-Type: application/json", "Accept: application/json"}) @PATCH("meta") - Observable changeUserInfo(@Header("TOKEN") String token, @Body RequestBody body); + Observable changeUserInfo(@Body RequestBody body); - // 注销登录 + /** + * 注销登录 + */ @Headers({"Content-Type: application/json", "Accept: application/json"}) @POST("logout") - Observable logout(@Header("TOKEN") String token); + Observable logout(); }