add[声望升级-自動PK,直接PK]

This commit is contained in:
Martin 2024-05-13 17:31:55 +08:00
parent 73414f3349
commit afef088555
8 changed files with 89 additions and 77 deletions

View File

@ -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);

View File

@ -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,8 +1224,6 @@ 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)
@ -1233,7 +1231,16 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
.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;
@ -1257,38 +1264,6 @@ public class LiveRyAnchorActivity extends LiveActivity implements LiveFunctionCl
}
});
/*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);
}
}
});*/
} else {
ToastUtil.show("主播正在PK稍後再試");
if (RandomPkManager.getInstance().isRandomModel()) {

View File

@ -143,8 +143,7 @@ public class FreePkRecyclerAdapter extends RefreshAdapter<RandomPkUserBean> {
}
mOnItemClickListener.onItemClick(bean, -1);
((LiveRyAnchorActivity) mContext).linkMicAnchorApply(bean.getId(), bean.getId(),
((LiveRyAnchorActivity) mContext).buildLinkMicJSON().toString()
);
false);
return;
}
if (mDrPkNum <= 0) {

View File

@ -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();

View File

@ -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<V2TIMMessage>() {
@Override

View File

@ -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<LiveInfoModel>() {
@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");

View File

@ -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");

View File

@ -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();