From afef08855506e5e840a9fec844c9123bb6355731 Mon Sep 17 00:00:00 2001 From: Martin <13046765170@163.com> Date: Mon, 13 May 2024 17:31:55 +0800 Subject: [PATCH] =?UTF-8?q?add[=E5=A3=B0=E6=9C=9B=E5=8D=87=E7=BA=A7-?= =?UTF-8?q?=E8=87=AA=E5=8B=95PK,=E7=9B=B4=E6=8E=A5PK]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yunbao/live/activity/LiveActivity.java | 2 +- .../live/activity/LiveRyAnchorActivity.java | 103 +++++++----------- .../live/adapter/FreePkRecyclerAdapter.java | 3 +- .../presenter/LiveRyLinkMicPkPresenter.java | 16 ++- .../live/socket/SocketLinkMicPkUtil.java | 3 +- .../yunbao/live/socket/SocketRyClient.java | 36 +++++- .../live/views/LivePushRyViewHolder.java | 2 +- .../yunbao/live/views/LiveRoomViewHolder.java | 1 - 8 files changed, 89 insertions(+), 77 deletions(-) diff --git a/live/src/main/java/com/yunbao/live/activity/LiveActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java index 579a75bc6..51dd79c30 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveActivity.java @@ -728,7 +728,7 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL @Override public void onLinkMicPkStart(final String pkUid, final String pkhead, final String pkname, String isLadders) { if (mContext instanceof LiveAudienceActivity) return; - Log.e("ry", "pkUid = " + pkUid + ", pkhead = " + pkhead + ", pkname = " + pkname + ", isLadders = " + isLadders); + L.eSw( "pkUid = " + pkUid + ", pkhead = " + pkhead + ", pkname = " + pkname + ", isLadders = " + isLadders); if (mLiveRyLinkMicPkPresenter != null && mLiveRoomViewHolder != null) { mLiveRyLinkMicPkPresenter.onLinkMicPkStart(pkUid, 1); pr = new pkRunnable(pkUid, pkhead, pkname, isLadders); diff --git a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java index 3a4e4c05a..76c3fb7ba 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveRyAnchorActivity.java @@ -193,7 +193,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl if (RandomPkManager.getInstance().isRankModel()) { msg1.put("is_ladders", "https://downs.yaoulive.com/rank_top_box.png"); } - linkMicAnchorApply(pkUid, pkUid, msg1.toString()); + linkMicAnchorApply(pkUid, pkUid, true); } @Override @@ -1203,7 +1203,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl */ public void linkMicAnchorApply(String pkUid, String stream) { JSONObject msg1 = buildLinkMicJSON(); - linkMicAnchorApply(pkUid, stream, msg1.toString()); + linkMicAnchorApply(pkUid, stream, false); } public JSONObject buildLinkMicJSON() { @@ -1215,7 +1215,7 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl return msg1; } - public void linkMicAnchorApply(final String pkUid, String stream, String extra) { + public void linkMicAnchorApply(final String pkUid, String stream, boolean extra) { LiveHttpUtil.livePkCheckLive(pkUid, stream, mStream, new HttpCallback() { @Override @@ -1224,71 +1224,46 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl JSONObject obj = JSON.parseObject(info[0]); if (obj != null) { if (obj.getString("ispk").equals("0")) { - - // TODO: 2024/4/11 发送IM消息 - final SocketSendBean msg1 = new SocketSendBean() - .param("_method_", SOCKET_LINK_MIC_PK) - .param("action", 1) - .param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()) - .param("pkuid", pkUid) - .param("uid", CommonAppConfig.getInstance().getUid()) - .param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()) - .param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()); - msg1.create(); - - Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM; - TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString()); - io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain("g" + pkUid, conversationType, messageContent); - - RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() { - @Override - public void onAttached(io.rong.imlib.model.Message message) { - - } - - @Override - public void onSuccess(io.rong.imlib.model.Message message) { - Log.e("tx", "发送成功"); - } - - @Override - public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) { - Log.e("tx", "发送失败" + errorCode.getMessage()); - - } - }); - - /*IMRTCManager.getInstance().requestJoinOtherRoom(pkUid, true, extra, new IRCRTCResultCallback() { - @Override - public void onSuccess() { - // ToastUtil.show("邀请 " + pkUid + " 发送成功"); - runOnUiThread(new Runnable() { - @Override - public void run() { - dismiss(); - } - }); - } - - @Override - public void onFailed(RTCErrorCode rtcErrorCode) { - runOnUiThread(new Runnable() { - @Override - public void run() { - dismiss(); - } - }); - //todo 安卓端状态码说明文档:https://docs.rongcloud.cn/v4/views/rtc/call/code/android.html - Log.e("ry", rtcErrorCode + "aaaaaa" + CommonAppConfig.getInstance().getUid() + "VDSSSS" + pkUid); - if (WordUtil.isNewZh()) { - ToastUtil.show("邀请 " + pkUid + " 发送失败 :" + rtcErrorCode); - } else { - ToastUtil.show("invite " + pkUid + " failed:" + rtcErrorCode); + final SocketSendBean msg1 = new SocketSendBean() + .param("_method_", SOCKET_LINK_MIC_PK) + .param("action", 1) + .param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()) + .param("pkuid", pkUid) + .param("uid", CommonAppConfig.getInstance().getUid()) + .param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()) + .param("uhead", CommonAppConfig.getInstance().getUserBean().getAvatar()) + .param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()); + //判断是否是随机PK + if(extra){ + msg1.param("random_pk", "1"); + msg1.param("msgtype","11"); + if (RandomPkManager.getInstance().isRankModel()) { + msg1.param("is_ladders", "https://downs.yaoulive.com/rank_top_box.png"); } } - });*/ + msg1.create(); + Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM; + TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString()); + io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain("g" + pkUid, conversationType, messageContent); + RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() { + @Override + public void onAttached(io.rong.imlib.model.Message message) { + + } + + @Override + public void onSuccess(io.rong.imlib.model.Message message) { + Log.e("tx", "发送成功"); + } + + @Override + public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) { + Log.e("tx", "发送失败" + errorCode.getMessage()); + + } + }); } else { ToastUtil.show("主播正在PK,稍後再試"); if (RandomPkManager.getInstance().isRandomModel()) { diff --git a/live/src/main/java/com/yunbao/live/adapter/FreePkRecyclerAdapter.java b/live/src/main/java/com/yunbao/live/adapter/FreePkRecyclerAdapter.java index 1cf09e983..3f2a0cbf6 100644 --- a/live/src/main/java/com/yunbao/live/adapter/FreePkRecyclerAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/FreePkRecyclerAdapter.java @@ -143,8 +143,7 @@ public class FreePkRecyclerAdapter extends RefreshAdapter { } mOnItemClickListener.onItemClick(bean, -1); ((LiveRyAnchorActivity) mContext).linkMicAnchorApply(bean.getId(), bean.getId(), - ((LiveRyAnchorActivity) mContext).buildLinkMicJSON().toString() - ); + false); return; } if (mDrPkNum <= 0) { diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java index eba1534b6..059a2f2b2 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java @@ -632,8 +632,19 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener { LiveRyAnchorActivity.isDRPK = 1; /*---------------------------------------------------------------- */ - final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LINK_MIC_PK).param("action", 2) //回复PK申请 2 - .param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()).param("pkuid", bean.getId()).param("uid", CommonAppConfig.getInstance().getUid()).param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()).param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()); + final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LINK_MIC_PK) + .param("action", 2) //回复PK申请 2 + .param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()) + .param("pkuid", bean.getId()) + .param("uid", CommonAppConfig.getInstance().getUid()) + .param("uhead", CommonAppConfig.getInstance().getUserBean().getAvatar()) + .param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()) + .param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()); + if (RandomPkManager.getInstance().isRankModel()) { + L.eSw("排位赛"); + msg1.param("is_ladders", "https://downs.yaoulive.com/rank_top_box.png"); + } + msg1.param("is_ladders", "https://downs.yaoulive.com/rank_top_box.png"); msg1.create(); System.out.println("PK回执 = " + msg1.toString()); Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM; @@ -1071,6 +1082,7 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener { .param("pkuid", CommonAppConfig.getInstance().getUid()) .param("msgtype", 2) .param("uid", drPkbeans.get(i).getId()) + .param("uhead", CommonAppConfig.getInstance().getUserBean().getAvatar()) .param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()) .param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()); msg1.create(); diff --git a/live/src/main/java/com/yunbao/live/socket/SocketLinkMicPkUtil.java b/live/src/main/java/com/yunbao/live/socket/SocketLinkMicPkUtil.java index 8ec8ae0ca..867e0c7c1 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketLinkMicPkUtil.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketLinkMicPkUtil.java @@ -66,7 +66,8 @@ public class SocketLinkMicPkUtil { .param("uid", CommonAppConfig.getInstance().getUid()) .param("pkuid", CommonAppConfig.getInstance().getUid()) .param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()) - .param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()); + .param("uhead", CommonAppConfig.getInstance().getUserBean().getAvatar()) + .param("name", CommonAppConfig.getInstance().getUserBean().getUserNiceName()); msg.create(); V2TIMManager.getInstance().sendC2CTextMessage(msg.mResult.toString(), pkUid, new V2TIMSendCallback() { @Override diff --git a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java index 1d92087a8..c5b55e527 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java @@ -2,6 +2,7 @@ package com.yunbao.live.socket; import static com.blankj.utilcode.util.SnackbarUtils.dismiss; import static com.blankj.utilcode.util.ViewUtils.runOnUiThread; +import static com.yunbao.common.Constants.SOCKET_LINK_MIC_PK; import static com.yunbao.common.Constants.SOCKET_LIVE_DRPK; import static com.yunbao.common.Constants.SOCKET_LIVE_MSG_TO_USER; import static com.yunbao.common.Constants.isAnchor; @@ -29,6 +30,7 @@ import com.yunbao.common.bean.AiAutomaticSpeechModel; import com.yunbao.common.bean.FansModel; import com.yunbao.common.bean.GuardMaturityDateRemindModel; import com.yunbao.common.bean.LinkMicUserBean; +import com.yunbao.common.bean.LiveInfoModel; import com.yunbao.common.bean.LiveUserGiftBean; import com.yunbao.common.bean.MsgModel; import com.yunbao.common.bean.PkRankBean; @@ -49,6 +51,7 @@ import com.yunbao.common.event.SendBlindGiftEvent; import com.yunbao.common.event.SendMoneyLongEndEvent; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; +import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.manager.IMRTCManager; import com.yunbao.common.manager.MicUserManager; import com.yunbao.common.manager.MicedUserManager; @@ -1294,13 +1297,13 @@ public class SocketRyClient { case 2://收到对方主播PK回调 L.eSw("收到对方主播PK回调"); RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_START); - mListener.onLinkMicToPk(map.getString("uid"), map.getString("pkhead"), map.getString("pkname")); - mListener.onLinkMicPkStart(map.getString("uid"), map.getString("pkhead"), map.getString("pkname"), map.getString("is_ladders"));// mListener.onLinkMicPkStart(map.getString("uid")); + mListener.onLinkMicToPk(map.getString("uid"), map.getString("uhead"), map.getString("uhead")); + mListener.onLinkMicPkStart(map.getString("uid"), map.getString("uhead"), map.getString("uname"), map.getString("is_ladders"));// mListener.onLinkMicPkStart(map.getString("uid")); if (livePushRyViewHolder != null) { UserBean userBean = new UserBean(); userBean.setId(map.getString("uid")); - userBean.setAvatar(map.getString("pkhead")); - userBean.setUserNiceName(map.getString("pkname")); + userBean.setAvatar(map.getString("uhead")); + userBean.setUserNiceName(map.getString("uname")); livePushRyViewHolder.setAnPkRtc(userBean); } break; @@ -1347,12 +1350,13 @@ public class SocketRyClient { } break; case 10://系统发起PK回调 - final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LIVE_DRPK) + final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LINK_MIC_PK) .param("action", 2) .param("uname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()) .param("pkuid", CommonAppConfig.getInstance().getUid()) .param("msgtype", 2) .param("uid", CommonAppConfig.getInstance().getUid()) + .param("uhead", CommonAppConfig.getInstance().getUserBean().getAvatar()) .param("pkhead", CommonAppConfig.getInstance().getUserBean().getAvatar()) .param("pkname", CommonAppConfig.getInstance().getUserBean().getUserNiceName()); msg1.create(); @@ -1377,6 +1381,28 @@ public class SocketRyClient { } }); + RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_START); + + LiveNetManager.get(mContext).getLiveInfo(map.getString("uid"), new com.yunbao.common.http.base.HttpCallback() { + @Override + public void onSuccess(LiveInfoModel data) { + mListener.onLinkMicToPk(map.getString("uid"), data.getAvatar(), map.getString("uhead")); + mListener.onLinkMicPkStart(map.getString("uid"), data.getAvatar(), map.getString("uname"), map.getString("is_ladders"));// mListener.onLinkMicPkStart(map.getString("uid")); + if (livePushRyViewHolder != null) { + UserBean userBean = new UserBean(); + userBean.setId(map.getString("uid")); + userBean.setAvatar(data.getAvatar()); + userBean.setUserNiceName(map.getString("uname")); + livePushRyViewHolder.setAnPkRtc(userBean); + } + } + + @Override + public void onError(String error) { + + } + } + ); /*JSONObject msg1 = new JSONObject(); msg1.put("type", "autoLivePK"); diff --git a/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java b/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java index 7cc43d910..4a8b5871c 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java @@ -301,7 +301,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX JSONObject map = JSONObject.parseObject(extra); userBean1.setId(map.getString("uid")); userBean1.setUserNiceName(map.getString("pkname")); - userBean1.setAvatar(map.getString("pkhead")); + userBean1.setAvatar(map.getString("uhead")); } else { userBean1.setId(inviterRoomId); userBean1.setUserNiceName("null"); diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java index 7e7039dd7..cbe457cc0 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -2575,7 +2575,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis initPkRankView(bean); if (!StringUtil.isEmpty(bean.getClickUrl())) { - pkRankVf.setOnClickListener(v -> { MobclickAgent.onEvent(mContext, "live_room_sky", "天梯赛按钮"); Bundle bundle = new Bundle();