diff --git a/live/src/main/java/com/yunbao/live/bean/PunishBean.java b/common/src/main/java/com/yunbao/common/bean/PunishBean.java similarity index 77% rename from live/src/main/java/com/yunbao/live/bean/PunishBean.java rename to common/src/main/java/com/yunbao/common/bean/PunishBean.java index 1a3e24371..3276d4434 100644 --- a/live/src/main/java/com/yunbao/live/bean/PunishBean.java +++ b/common/src/main/java/com/yunbao/common/bean/PunishBean.java @@ -1,4 +1,4 @@ -package com.yunbao.live.bean; +package com.yunbao.common.bean; //处罚消息的对象 public class PunishBean { diff --git a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java index b85878b8f..e58cfcd64 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -1344,4 +1344,9 @@ public interface PDLiveApi { @Query("gift_id")String giftId, @Query("live_uid")String liveUid ); + + //处罚通知红点 + @GET("/api/public/?service=Message.penalizeStatus") + Observable getPenalizeStatus(); + } diff --git a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java index 5e5e61785..e102bb23e 100644 --- a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java +++ b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java @@ -91,6 +91,8 @@ import com.yunbao.common.http.base.CheckLiveCallBack; import com.yunbao.common.http.base.HttpCallback; import com.yunbao.common.utils.WordUtil; +import org.json.JSONObject; + import java.io.File; import java.util.ArrayList; import java.util.HashMap; @@ -2301,20 +2303,21 @@ public class LiveNetManager { /** * 获取房间金豆门槛和赢家获得的金豆 + * * @param roomId * @param callback */ - public void getScore(String roomId,HttpCallback callback){ + public void getScore(String roomId, HttpCallback callback) { API.get().pdLiveApi(mContext) .getScore(roomId) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(sudGameScoreBeanResponseModel -> { - if (callback != null){ + if (callback != null) { callback.onSuccess(sudGameScoreBeanResponseModel.getData().getInfo()); } }, throwable -> { - if (callback != null){ + if (callback != null) { callback.onError(mContext.getString(R.string.net_error)); } }).isDisposed(); @@ -2322,20 +2325,21 @@ public class LiveNetManager { /** * 获取游戏中所有玩家的信息 + * * @param roomId * @param callback */ - public void getSudGameInfo(String roomId,HttpCallback> callback){ + public void getSudGameInfo(String roomId, HttpCallback> callback) { API.get().pdLiveApi(mContext) .getSudGameInfo(roomId) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) - .subscribe(infoModel->{ - if (callback != null){ + .subscribe(infoModel -> { + if (callback != null) { callback.onSuccess(infoModel.getData().getInfo()); } - },throwable -> { - if (callback != null){ + }, throwable -> { + if (callback != null) { callback.onError(mContext.getString(R.string.net_error)); } }).isDisposed(); @@ -3061,9 +3065,9 @@ public class LiveNetManager { } - public void openGuard(String liveUid, String guardType, String priceKey, String stream,String coupon_type,String couponId, HttpCallback callback) { + public void openGuard(String liveUid, String guardType, String priceKey, String stream, String coupon_type, String couponId, HttpCallback callback) { API.get().pdLiveApi(mContext) - .openGuard(liveUid, guardType, priceKey, stream,coupon_type,couponId) + .openGuard(liveUid, guardType, priceKey, stream, coupon_type, couponId) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Consumer>() { @@ -3572,9 +3576,9 @@ public class LiveNetManager { }).isDisposed(); } - public void userUseDress( String usersDressId, HttpCallback callback) { + public void userUseDress(String usersDressId, HttpCallback callback) { API.get().pdLiveApi(mContext) - .userUseDress(usersDressId,3) + .userUseDress(usersDressId, 3) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Consumer>>() { @@ -3602,6 +3606,42 @@ public class LiveNetManager { return MultipartBody.Part.createFormData("file", file.getName(), requestBody); } + public void getPenalizeStatus(HttpCallback callback) { + API.get().pdLiveApi(mContext) + .getPenalizeStatus() + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer() { + @Override + public void accept(ResponseModel responseModel) throws Exception { + if (callback != null) { + if (responseModel.getData().getCode() == 0) { + String s = responseModel.getData().getInfo().toString(); + try { + JSONObject ob = new JSONObject(s); + if (ob.getInt("unread_num") > 0) { + callback.onSuccess(responseModel); + } else { + callback.onError(""); + } + } catch (Exception e) { + callback.onError(""); + } + } else { + callback.onError(""); + } + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } + /** * 直播间取消网络请求 */ diff --git a/common/src/main/java/com/yunbao/common/utils/RouteUtil.java b/common/src/main/java/com/yunbao/common/utils/RouteUtil.java index 5fef0e982..3900488c5 100644 --- a/common/src/main/java/com/yunbao/common/utils/RouteUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/RouteUtil.java @@ -1,6 +1,5 @@ package com.yunbao.common.utils; -import android.app.Activity; import android.content.Context; import android.content.Intent; @@ -56,6 +55,7 @@ public class RouteUtil { public static final String PATH_FEEDBACK_SUCCESS_ACTIVITY = "/main/FeedbackSuccessActivity"; public static final String PATH_FEEDBACK_ACTIVITY = "/main/FeedbackActivity"; public static final String PATH_FEEDBACK_EDIT_ACTIVITY = "/main/FeedbackEditActivity"; + public static final String PATH_LIVE_PUNISHACTIVITY = "/live/PunishActivity"; public static void forwardCommunityActivity() { @@ -379,4 +379,11 @@ public class RouteUtil { ARouter.getInstance().build(path) .navigation(); } + /** + * 处罚通知界面 + */ + public static void forwardPunishActivity() { + ARouter.getInstance().build(PATH_LIVE_PUNISHACTIVITY) + .navigation(); + } } diff --git a/live/src/main/java/com/yunbao/live/activity/PunishActivity.java b/live/src/main/java/com/yunbao/live/activity/PunishActivity.java index b750b9c11..84a016aba 100644 --- a/live/src/main/java/com/yunbao/live/activity/PunishActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/PunishActivity.java @@ -2,14 +2,16 @@ package com.yunbao.live.activity; import androidx.recyclerview.widget.LinearLayoutManager; +import com.alibaba.android.arouter.facade.annotation.Route; import com.alibaba.fastjson.JSON; import com.yunbao.common.activity.AbsActivity; import com.yunbao.common.adapter.RefreshAdapter; import com.yunbao.common.custom.CommonRefreshView; import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.utils.RouteUtil; import com.yunbao.live.R; import com.yunbao.live.adapter.PunishAdapter; -import com.yunbao.live.bean.PunishBean; +import com.yunbao.common.bean.PunishBean; import com.yunbao.live.http.ImHttpUtil; import java.util.ArrayList; @@ -17,6 +19,7 @@ import java.util.Arrays; import java.util.List; //处罚通知单 +@Route(path = RouteUtil.PATH_LIVE_PUNISHACTIVITY) public class PunishActivity extends AbsActivity { private CommonRefreshView mRefreshView; diff --git a/live/src/main/java/com/yunbao/live/activity/SystemMessageActivity.java b/live/src/main/java/com/yunbao/live/activity/SystemMessageActivity.java index ffed237b0..03d9d07f3 100644 --- a/live/src/main/java/com/yunbao/live/activity/SystemMessageActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/SystemMessageActivity.java @@ -11,13 +11,12 @@ import com.yunbao.common.Constants; import com.yunbao.common.activity.AbsActivity; import com.yunbao.common.activity.SelectImageActivity; import com.yunbao.common.bean.ImageEntity; -import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.http.ResponseModel; +import com.yunbao.common.http.live.LiveNetManager; +import com.yunbao.common.utils.RouteUtil; import com.yunbao.live.R; -import com.yunbao.live.http.ImHttpUtil; import com.yunbao.live.views.SystemMessageViewHolder; -import org.json.JSONObject; - import java.util.ArrayList; import java.util.Date; @@ -76,8 +75,7 @@ public class SystemMessageActivity extends AbsActivity { punish.setVisibility(View.VISIBLE); punishNotice = findViewById(R.id.tv_sys_msg_punish_notice); punish.setOnClickListener(v -> { - Intent intent = new Intent(getApplicationContext(), PunishActivity.class); - startActivity(intent); + RouteUtil.forwardPunishActivity(); punishNotice.setVisibility(View.GONE); }); @@ -87,23 +85,15 @@ public class SystemMessageActivity extends AbsActivity { finish(); } }); - ImHttpUtil.getPenalizeStatus(new HttpCallback() { + LiveNetManager.get(mContext).getPenalizeStatus(new com.yunbao.common.http.base.HttpCallback() { @Override - public void onSuccess(int code, String msg, String[] info) { - if (code == 0 && info != null && info.length > 0) { - try { - JSONObject ob = new JSONObject(info[0]); - if (ob.getInt("unread_num") > 0) { - punishNotice.setVisibility(View.VISIBLE); - } else { - punishNotice.setVisibility(View.GONE); - } - } catch (Exception e) { - punishNotice.setVisibility(View.GONE); - } - } else { - punishNotice.setVisibility(View.GONE); - } + public void onSuccess(ResponseModel responseModel) { + punishNotice.setVisibility(View.VISIBLE); + } + + @Override + public void onError(String error) { + punishNotice.setVisibility(View.GONE); } }); } diff --git a/live/src/main/java/com/yunbao/live/adapter/PunishAdapter.java b/live/src/main/java/com/yunbao/live/adapter/PunishAdapter.java index 0762d4ac0..c929100c9 100644 --- a/live/src/main/java/com/yunbao/live/adapter/PunishAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/PunishAdapter.java @@ -11,7 +11,7 @@ import androidx.recyclerview.widget.RecyclerView; import com.yunbao.common.adapter.RefreshAdapter; import com.yunbao.live.R; -import com.yunbao.live.bean.PunishBean; +import com.yunbao.common.bean.PunishBean; import java.util.List;