diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2428c4a700..5d5c29a75a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -42,7 +42,6 @@ - >(){ @@ -112,7 +112,7 @@ public class GiftUtils { new Thread(new Runnable() { @Override public void run() { - RetrofitManager.getApi().postGiftLing(TokenUtils.getToken(context, isCheck), giftId) + RetrofitManager.getLibao().postLibaoLing(TokenUtils.getToken(context, isCheck), giftId) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new JSONObjectResponse() { @@ -151,7 +151,7 @@ public class GiftUtils { new Thread(new Runnable() { @Override public void run() { - RetrofitManager.getApi().postGiftTao(TokenUtils.getToken(context, isCheck), giftId) + RetrofitManager.getLibao().postLibaoTao(TokenUtils.getToken(context, isCheck), giftId) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new JSONObjectResponse(){ @@ -179,8 +179,7 @@ public class GiftUtils { } public static void getGiftStatus(String ids, final PostGiftListener listener) { - RetrofitManager.getApi() - .getGiftStatus(ids) + RetrofitManager.getLibao().getLibaoStatus(ids) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Response>() { diff --git a/app/src/main/java/com/gh/gamecenter/adapter/GiftDetailAdapter.java b/app/src/main/java/com/gh/gamecenter/adapter/GiftDetailAdapter.java index c41a122f92..17a022e903 100644 --- a/app/src/main/java/com/gh/gamecenter/adapter/GiftDetailAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/adapter/GiftDetailAdapter.java @@ -63,8 +63,7 @@ public class GiftDetailAdapter extends RecyclerView.Adapter() { diff --git a/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailAdapter.java b/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailAdapter.java index f05ad00181..6e0cb4baad 100644 --- a/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/gamedetail/GameDetailAdapter.java @@ -140,8 +140,7 @@ public class GameDetailAdapter extends RecyclerView.Adapter { } public void addGiftList(){ - RetrofitManager.getApi() - .getGiftByGameId(gameEntity.getId(),0 , 128) + RetrofitManager.getLibao().getLibaoByGame(gameEntity.getId(),0 , 128) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Response>(){ diff --git a/app/src/main/java/com/gh/gamecenter/gift/Gift1FragmentAdapter.java b/app/src/main/java/com/gh/gamecenter/gift/Gift1FragmentAdapter.java index 70b4a33c04..c47cfb854b 100644 --- a/app/src/main/java/com/gh/gamecenter/gift/Gift1FragmentAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/gift/Gift1FragmentAdapter.java @@ -85,9 +85,9 @@ public class Gift1FragmentAdapter extends RecyclerView.Adapter> giftApi; if (isSearch) { - giftApi = RetrofitManager.getApi().getSearchGift(mSerchKey, offset); + giftApi = RetrofitManager.getLibao().getLibaoBySearch(mSerchKey, offset); } else { - giftApi = RetrofitManager.getApi().getGift(offset); + giftApi = RetrofitManager.getLibao().getLibao(offset); } giftApi.map(new Func1, List>() { diff --git a/app/src/main/java/com/gh/gamecenter/gift/Gift2FragmentAdapter.java b/app/src/main/java/com/gh/gamecenter/gift/Gift2FragmentAdapter.java index 7f1ca4f9be..efe2debf45 100644 --- a/app/src/main/java/com/gh/gamecenter/gift/Gift2FragmentAdapter.java +++ b/app/src/main/java/com/gh/gamecenter/gift/Gift2FragmentAdapter.java @@ -152,9 +152,7 @@ public class Gift2FragmentAdapter extends RecyclerView.Adapter, List>() { @Override public List call(List list) { @@ -207,8 +205,7 @@ public class Gift2FragmentAdapter extends RecyclerView.Adapter, List>() { @Override public List call(List list) { diff --git a/app/src/main/java/com/gh/gamecenter/retrofit/ApiService.java b/app/src/main/java/com/gh/gamecenter/retrofit/ApiService.java index 2eb79b61a3..a2fa0ba192 100644 --- a/app/src/main/java/com/gh/gamecenter/retrofit/ApiService.java +++ b/app/src/main/java/com/gh/gamecenter/retrofit/ApiService.java @@ -6,9 +6,6 @@ import com.gh.gamecenter.entity.GameDetailEntity; import com.gh.gamecenter.entity.GameDigestEntity; import com.gh.gamecenter.entity.GameEntity; import com.gh.gamecenter.entity.GameUpdateEntity; -import com.gh.gamecenter.entity.GiftDetailEntity; -import com.gh.gamecenter.entity.GiftEntity; -import com.gh.gamecenter.entity.GiftStatusEntity; import com.gh.gamecenter.entity.NewsDetailEntity; import com.gh.gamecenter.entity.NewsEntity; import com.gh.gamecenter.entity.PlatformEntity; @@ -22,7 +19,6 @@ 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.POST; import retrofit2.http.Path; @@ -159,34 +155,6 @@ public interface ApiService { @GET("game/column/{subject_id}/huanyihuan}") Observable> getSubjectGame(@Path("subject_id") String subject_id); //获取专题游戏 用于主页换一批 - @GET("libao?limit=20") - Observable> getGift(@Query("offset") int offset); //获取礼包列表数据 - - @GET("libao?limit=20") - Observable> getSearchGift(@Query("keyword") String searchKey, @Query("offset") int offset); //搜索礼包列表数据 - - @GET("libao/{gift_Id}/detail") - Observable getGiftDetail(@Path("gift_Id") String giftId); //获取礼包详情数据 - - @GET("libao") - Observable> getGiftByGameId(@Query("game_id") String giftId, - @Query("offset") int offset, @Query("limit") int limit); //获取游戏详情礼包数据 - - @GET("libao/status") - Observable> getGiftStatus(@Query("ids") String giftIds); //获取礼包领取按钮状态 - - @GET("libao?limit=20") - Observable> getConcernGift(@Query("key") String searchKey, @Query("offset") int offset); //关注礼包列表数据 - - @GET("libao/cunhaoxiang") - Observable> getCunHaoXiang(@Header("TOKEN") String token); // 获取礼包存号箱数据 - - @POST("libao/{gift_Id}/ling") - Observable postGiftLing(@Header("TOKEN") String token, @Path("gift_Id") String giftId); // 领取礼包 - - @POST("libao/{gift_Id}/tao") - Observable postGiftTao(@Header("TOKEN") String token, @Path("gift_Id") String giftId); // 礼包 淘号 - @Headers({"Content-Type: application/json", "Accept: application/json"}) @POST("support/suggestion") // 上传意见反馈 Observable postSuggestion(@Body RequestBody body); diff --git a/app/src/main/java/com/gh/gamecenter/retrofit/LibaoService.java b/app/src/main/java/com/gh/gamecenter/retrofit/LibaoService.java new file mode 100644 index 0000000000..06a6258d10 --- /dev/null +++ b/app/src/main/java/com/gh/gamecenter/retrofit/LibaoService.java @@ -0,0 +1,50 @@ +package com.gh.gamecenter.retrofit; + +import com.gh.gamecenter.entity.GiftDetailEntity; +import com.gh.gamecenter.entity.GiftEntity; +import com.gh.gamecenter.entity.GiftStatusEntity; + +import java.util.List; + +import okhttp3.ResponseBody; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.POST; +import retrofit2.http.Path; +import retrofit2.http.Query; +import rx.Observable; + +/** + * libao.ghzhushou.com + */ +public interface LibaoService { + + @GET("libao?limit=20") + Observable> getLibao(@Query("offset") int offset); //获取礼包列表数据 + + @GET("libao?limit=20") + Observable> getLibaoBySearch(@Query("keyword") String searchKey, @Query("offset") int offset); //搜索礼包列表数据 + + @GET("libao?limit=20") + Observable> getLibaoByConcern(@Query("key") String key, @Query("offset") int offset); //关注礼包列表数据 + + @GET("libao") + Observable> getLibaoByGame(@Query("game_id") String giftId, + @Query("offset") int offset, @Query("limit") int limit); //获取游戏详情礼包数据 + + @GET("libao/{libao_id}/detail") + Observable getLibaoDetail(@Path("libao_id") String giftId); //获取礼包详情数据 + + @GET("libao/status") + Observable> getLibaoStatus(@Query("ids") String giftIds); //获取礼包领取按钮状态 + + @GET("libao/cunhaoxiang") + Observable> getCunHaoXiang(@Header("TOKEN") String token); // 获取礼包存号箱数据 + + @POST("libao/{libao_id}/ling") + Observable postLibaoLing(@Header("TOKEN") String token, @Path("libao_id") String giftId); // 领取礼包 + + @POST("libao/{libao_id}/tao") + Observable postLibaoTao(@Header("TOKEN") String token, @Path("libao_id") String giftId); // 礼包 淘号 + +} diff --git a/app/src/main/java/com/gh/gamecenter/retrofit/RetrofitManager.java b/app/src/main/java/com/gh/gamecenter/retrofit/RetrofitManager.java index a211c193b5..a1e976143a 100644 --- a/app/src/main/java/com/gh/gamecenter/retrofit/RetrofitManager.java +++ b/app/src/main/java/com/gh/gamecenter/retrofit/RetrofitManager.java @@ -46,10 +46,15 @@ public class RetrofitManager { return getInstance().getUserService(); } + public static LibaoService getLibao() { + return getInstance().getLibaoService(); + } + private ApiService apiService; private DataService dataService; private CommentService commentService; private UserService userService; + private LibaoService libaoService; private RetrofitManager() { Cache cache = new Cache(new File(OkHttpCache.getCachePath()), 10 * 1024 * 1024); // 10Mb @@ -91,6 +96,14 @@ public class RetrofitManager { .baseUrl(Config.USER_HOST) .build() .create(UserService.class); + + libaoService = new Retrofit.Builder() + .client(okHttpClient) + .addConverterFactory(GsonConverterFactory.create()) + .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) + .baseUrl(Config.LIBAO_HOST) + .build() + .create(LibaoService.class); } public ApiService getApiService() { @@ -109,4 +122,8 @@ public class RetrofitManager { return userService; } + public LibaoService getLibaoService() { + return libaoService; + } + }