From d2686778150e295050e298665bf62a942a734672 Mon Sep 17 00:00:00 2001 From: dingliufan <358892638@qq.com> Date: Thu, 23 Apr 2020 12:15:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A8=E6=80=81=E7=8E=AF=E5=A2=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/mebooth/text/Application.java | 1 + .../mylibrary/main/AppApplication.java | 35 ++++++-- .../mylibrary/main/utils/YService.java | 82 +++++++++---------- 3 files changed, 71 insertions(+), 47 deletions(-) diff --git a/app/src/main/java/com/mebooth/text/Application.java b/app/src/main/java/com/mebooth/text/Application.java index 44309c6..25f3f12 100644 --- a/app/src/main/java/com/mebooth/text/Application.java +++ b/app/src/main/java/com/mebooth/text/Application.java @@ -25,6 +25,7 @@ public class Application extends AppApplication { @Override public void onCreate() { super.onCreate(); + this.setDebug(true); //传递用户信息 UserTokenJson userTokenJson = new UserTokenJson(); //冬shan diff --git a/mylibrary/src/main/java/com/mebooth/mylibrary/main/AppApplication.java b/mylibrary/src/main/java/com/mebooth/mylibrary/main/AppApplication.java index 299dede..633a0b5 100644 --- a/mylibrary/src/main/java/com/mebooth/mylibrary/main/AppApplication.java +++ b/mylibrary/src/main/java/com/mebooth/mylibrary/main/AppApplication.java @@ -64,6 +64,7 @@ public UserTokenJson getUserTokenJson() { private boolean isShowBack; private TextMessage rongMsg; + public boolean isShowBack() { return isShowBack; } @@ -86,11 +87,11 @@ public void setUserTokenJson(UserTokenJson userTokenJson) { intent.putExtra("index", "refreshList"); sendBroadcast(intent); - try{ - if(RongIM.getInstance().getRongIMClient().getCurrentConnectionStatus() == RongIMClient.ConnectionStatusListener.ConnectionStatus.KICKED_OFFLINE_BY_OTHER_CLIENT){ + try { + if (RongIM.getInstance().getRongIMClient().getCurrentConnectionStatus() == RongIMClient.ConnectionStatusListener.ConnectionStatus.KICKED_OFFLINE_BY_OTHER_CLIENT) { RongIM.getInstance().logout(); } - }catch (Exception e){ + } catch (Exception e) { } @@ -164,16 +165,38 @@ public void setLogOut(boolean isLogOut) { sendBroadcast(intent); SharedPreferencesUtils.writeString("token", ""); - try{ - if(RongIM.getInstance().getRongIMClient().getCurrentConnectionStatus() != RongIMClient.ConnectionStatusListener.ConnectionStatus.DISCONNECTED){ + try { + if (RongIM.getInstance().getRongIMClient().getCurrentConnectionStatus() != RongIMClient.ConnectionStatusListener.ConnectionStatus.DISCONNECTED) { RongIM.getInstance().logout(); } - }catch (Exception e){ + } catch (Exception e) { } } } + + public boolean isDebug; + + public boolean isDebug() { + return isDebug; + } + + public void setDebug(boolean debug) { + isDebug = debug; + } + + public static String baseUrl() { + + if (AppApplication.getInstance().isDebug()) { + + return "http://test-tataclub.baojiawangluo.com/"; + + } + return "http://tataclub.baojiawangluo.com/"; + + } + @Override public void onCreate() { super.onCreate(); diff --git a/mylibrary/src/main/java/com/mebooth/mylibrary/main/utils/YService.java b/mylibrary/src/main/java/com/mebooth/mylibrary/main/utils/YService.java index c293dd2..bfab850 100644 --- a/mylibrary/src/main/java/com/mebooth/mylibrary/main/utils/YService.java +++ b/mylibrary/src/main/java/com/mebooth/mylibrary/main/utils/YService.java @@ -39,8 +39,8 @@ public interface YService { //测试 - String BASE_URL = "http://test-tataclub.baojiawangluo.com/"; -// public static String BASE_URL = ""; +// String BASE_URL = "http://test-tataclub.baojiawangluo.com/"; + public static String BASE_URL = AppApplication.baseUrl(); //外网s // String BASE_URL = "http://test.tatabike.com/"; // String BASE_URL = "http://tataclub.baojiawangluo.com/"; @@ -50,200 +50,200 @@ public interface YService { //推荐列表 @FormUrlEncoded - @POST(BASE_URL + "topic/getFeeds") + @POST("topic/getFeeds") Observable getRecommend(@Field("name") String name, @Field("offset") String offset, @Field("num") int num); // Observable getRecommend(@Field("name") String name); //此刻列表 @FormUrlEncoded - @POST(BASE_URL + "topic/getLatest") + @POST("topic/getLatest") Observable getNow(@Field("platform") String platform, @Field("offset") String offset, @Field("num") int num); // Observable getNow(); //此刻列表详情 @FormUrlEncoded - @POST(BASE_URL + "topic/getTopicInfo") + @POST("topic/getTopicInfo") Observable getNow(@Field("tid") int tid); //发布帖子 @FormUrlEncoded - @POST(BASE_URL + "topic/add") + @POST("topic/add") Observable getAddTopic(@Field("content") String content, @Field("location") String location, @Field("images") String images); //新闻详情 @FormUrlEncoded - @POST(BASE_URL + "topic/getNewsInfo") + @POST("topic/getNewsInfo") Observable getNewInfo(@Field("newsid") int newsid); //是否关注 @FormUrlEncoded - @POST(BASE_URL + "follow/isFollowed") + @POST("follow/isFollowed") Observable getIsFollow(@Field("fids") int fids); //是否收藏 @FormUrlEncoded - @POST(BASE_URL + "praise/isPraised") + @POST("praise/isPraised") Observable getIsCollect(@Field("tid") int tid); //评论列表 @FormUrlEncoded - @POST(BASE_URL + "reply/getReplies") + @POST("reply/getReplies") Observable getCommentInfo(@Field("tid") int tid, @Field("type") int type, @Field("direct") int direct); //回复评论 @FormUrlEncoded - @POST(BASE_URL + "reply/add") + @POST("reply/add") // Observable updateRepairFile(@PartMap Map params); Observable requestComment(@Field("tid") int tid, @Field("pid") int pid, @Field("content") String content, @Field("type") int type); //上传图片 @Multipart - @POST(BASE_URL + "image/upload") + @POST("image/upload") // Observable updateRepairFile(@PartMap Map params); Observable updateRepairFile(@Part MultipartBody.Part file); //发布帖子 @FormUrlEncoded - @POST(BASE_URL + "topic/add") + @POST("topic/add") // Observable updateRepairFile(@PartMap Map params); Observable publishTopic(@Field("content") String content, @Field("location") String location, @Field("images") String images, @Field("platform") String platform); //发布新闻 @FormUrlEncoded - @POST(BASE_URL + "news/add") + @POST("news/add") // Observable updateRepairFile(@PartMap Map params); Observable publishNews(@Field("title") String title, @Field("cover") String cover, @Field("content") String content, @Field("location") String location); //关注 @FormUrlEncoded - @POST(BASE_URL + "follow/add") + @POST("follow/add") // Observable updateRepairFile(@PartMap Map params); Observable addFollow(@Field("uid") int uid); //取消关注 @FormUrlEncoded - @POST(BASE_URL + "follow/cancel") + @POST("follow/cancel") // Observable updateRepairFile(@PartMap Map params); Observable cancelFollow(@Field("uid") int uid); //点赞 @FormUrlEncoded - @POST(BASE_URL + "praise/add") + @POST("praise/add") // Observable updateRepairFile(@PartMap Map params); Observable addPraises(@Field("tid") int tid, @Field("type") int type); //取消点赞 @FormUrlEncoded - @POST(BASE_URL + "praise/cancel") + @POST("praise/cancel") // Observable updateRepairFile(@PartMap Map params); Observable cancelPraises(@Field("tid") int tid, @Field("type") int type); //收藏 @FormUrlEncoded - @POST(BASE_URL + "favorite/add") + @POST("favorite/add") // Observable updateRepairFile(@PartMap Map params); Observable addFavorite(@Field("relateid") int newsid); //取消收藏 @FormUrlEncoded - @POST(BASE_URL + "favorite/cancel") + @POST("favorite/cancel") // Observable updateRepairFile(@PartMap Map params); Observable cancelFavorite(@Field("relateid") int newsid); //获取用户个人信息 // @FormUrlEncoded - @POST(BASE_URL + "user/getMyUserInfo") + @POST("user/getMyUserInfo") // Observable updateRepairFile(@PartMap Map params); Observable userInfo(); //修改头像 @FormUrlEncoded - @POST(BASE_URL + "user/setAvatar") + @POST("user/setAvatar") // Observable updateRepairFile(@PartMap Map params); Observable udateHeaderIcon(@Field("avatar") String avatar); //修改昵称 @FormUrlEncoded - @POST(BASE_URL + "user/setNickname") + @POST("user/setNickname") // Observable updateRepairFile(@PartMap Map params); Observable udateNickName(@Field("nickname") String nickname); //我发布的帖子 @FormUrlEncoded - @POST(BASE_URL + "topic/getUserTopicList") + @POST("topic/getUserTopicList") // Observable updateRepairFile(@PartMap Map params); Observable userPublishList(@Field("uid") int uid, @Field("offset") String offset, @Field("num") int num); //我收藏的帖子 @FormUrlEncoded - @POST(BASE_URL + "favorite/getFavoriteList") + @POST("favorite/getFavoriteList") // Observable updateRepairFile(@PartMap Map params); Observable userPraiseList(@Field("offset") String offset, @Field("num") int num); //删除我发布的帖子 @FormUrlEncoded - @POST(BASE_URL + "topic/delete") + @POST("topic/delete") // Observable updateRepairFile(@PartMap Map params); Observable deleteTopic(@Field("tid") int tid); //我关注的人 @FormUrlEncoded - @POST(BASE_URL + "follow/getFollowings") + @POST("follow/getFollowings") // Observable updateRepairFile(@PartMap Map params); Observable getCareList(@Field("offset") String offset, @Field("num") int num); //我的粉丝 @FormUrlEncoded - @POST(BASE_URL + "follow/getFollowers") + @POST("follow/getFollowers") // Observable updateRepairFile(@PartMap Map params); Observable getFansList(@Field("offset") String offset, @Field("num") int num); //用户关注的人 @FormUrlEncoded - @POST(BASE_URL + "follow/getUserFollowings") + @POST("follow/getUserFollowings") // Observable updateRepairFile(@PartMap Map params); Observable getUserCareList(@Field("uid") int uid); //获取融云token - @POST(BASE_URL + "message/getToken") + @POST("message/getToken") Observable getRongTokenInfo(); //获取分享信息 @FormUrlEncoded - @POST(BASE_URL + "share/getShareInfo") + @POST("share/getShareInfo") Observable getShareInfo(@Field("scene") String scene, @Field("relateid") int relateid, @Field("type") String type); //获取我的界面数量信息 @FormUrlEncoded - @POST(BASE_URL + "user/getUserInfo") + @POST("user/getUserInfo") Observable getMineCountInfo(@Field("uid") int uid); //获取我的界面数量信息 @FormUrlEncoded - @POST(BASE_URL + "user/getUserInfos") + @POST("user/getUserInfos") Observable getIMUserInfo(@Field("uids") String uids); //获取banner页面 @FormUrlEncoded - @POST(BASE_URL + "config/getConfig") + @POST("config/getConfig") // Observable updateRepairFile(@PartMap Map params); Observable bannerList(@Field("name") String name); //获取专题页面 @FormUrlEncoded - @POST(BASE_URL + "config/getConfig") + @POST("config/getConfig") // Observable updateRepairFile(@PartMap Map params); Observable entranceList(@Field("name") String name); //获取我发布的新闻列表 @FormUrlEncoded - @POST(BASE_URL + "news/getUserNewsList") + @POST("news/getUserNewsList") // Observable updateRepairFile(@PartMap Map params); Observable userNewsList(@Field("uid") int uid, @Field("offset") String offset, @Field("num") int num); //删除我发布的单个新闻 @FormUrlEncoded - @POST(BASE_URL + "news/delete") + @POST("news/delete") // Observable updateRepairFile(@PartMap Map params); Observable deleteNews(@Field("newsid") int newsid); @@ -255,25 +255,25 @@ public interface YService { //获取附近地点 @FormUrlEncoded - @POST(BASE_URL + "config/getPlaces") + @POST("config/getPlaces") // Observable updateRepairFile(@PartMap Map params); Observable placesInfo(@Field("lng") String lng, @Field("lat") String lat); //获取省份 // @FormUrlEncoded - @POST(BASE_URL + "config/getProvinces") + @POST("config/getProvinces") // Observable updateRepairFile(@PartMap Map params); Observable ProvincesListInfo(); //获取省份所管辖的市 @FormUrlEncoded - @POST(BASE_URL + "config/getCitys") + @POST("config/getCitys") // Observable updateRepairFile(@PartMap Map params); Observable CityListInfo(@Field("province") String province); //保存个人信息 @FormUrlEncoded - @POST(BASE_URL + "user/setUserInfo") + @POST("user/setUserInfo") // Observable updateRepairFile(@PartMap Map params); Observable setUserInfo(@Field("avatar") String avatar,@Field("nickname") String nickname,@Field("gender") String gender,@Field("city") String city,@Field("signature") String signature); }