From 8d984951c34558453e294371829648c7ba9086fd Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Thu, 31 Aug 2023 15:14:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=B8=BB=E5=8B=95PK=E7=B5=90?= =?UTF-8?q?=E6=9D=9F=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yunbao/live/dialog/LiveGiftPopup.java | 26 ++++ .../live/views/LivePushRyViewHolder.java | 123 ++++++++++++------ 2 files changed, 112 insertions(+), 37 deletions(-) diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveGiftPopup.java b/live/src/main/java/com/yunbao/live/dialog/LiveGiftPopup.java index a7258c47d..3076a1fba 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveGiftPopup.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveGiftPopup.java @@ -352,6 +352,30 @@ public class LiveGiftPopup extends AbsDialogFragment { fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment"); } }); + /** + * 礼物图片运营位跳转 + */ + ViewClicksAntiShake.clicksAntiShake(operateImage, new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo(); + StringBuffer htmlUrl = new StringBuffer(); + htmlUrl.append(CommonAppConfig.HOST) + .append(liveGiftModel.getOperateUrl()) + .append("?uid=") + .append(userInfo.getId()) + .append("&token=") + .append(userInfo.getToken()) + .append("&for"); + Bundle bundle = new Bundle(); + bundle.putString("url", htmlUrl.toString()); + bundle.putInt("height", DeviceUtils.getScreenHeight(getActivity()) / 5 * 3); + LiveHDDialogFragment fragment = new LiveHDDialogFragment(); + fragment.setArguments(bundle); + fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment"); + } + }); + if (IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) { ImgLoader.display(mContext, R.mipmap.icon_live_gift_gift_itle, giftItle); } else { @@ -809,6 +833,8 @@ public class LiveGiftPopup extends AbsDialogFragment { if (!TextUtils.isEmpty(liveGiftModel.getOperateImage())) { operateImage.setVisibility(View.VISIBLE); ImgLoader.display(getContext(), liveGiftModel.getOperateImage(), operateImage); + }else { + operateImage.setVisibility(View.GONE); } } 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 8cc9d560f..f35464cf0 100644 --- a/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LivePushRyViewHolder.java @@ -4,8 +4,11 @@ import static com.lzy.okgo.utils.HttpUtils.runOnUiThread; import static com.yunbao.common.Constants.SOCKET_LINK_MIC_PK; import static com.yunbao.common.Constants.SOCKET_LIVE_DRPK; import static com.yunbao.live.activity.LiveActivity.mLiveRyLinkMicPkPresenter; +import static com.yunbao.live.event.LiveAudienceEvent.LiveAudienceType.LIVE_PK_END; +import static com.yunbao.live.event.LiveAudienceEvent.LiveAudienceType.LIVE_PK_ING; import static com.yunbao.live.presenter.LiveRyLinkMicPkPresenter.inputStreamList; import static com.yunbao.live.presenter.LiveRyLinkMicPkPresenter.inputStreamList1; +import static com.yunbao.live.presenter.LiveRyLinkMicPkPresenter.mPkUid; import static cn.rongcloud.rtc.base.RCRTCLiveRole.BROADCASTER; import android.app.Dialog; @@ -118,6 +121,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX private TextView tv_avatarOther_name; private ImageView avatarOther; private LinearLayout goto_room_view; + private boolean isPk = false; //修改上面主播的头像 @Subscribe(threadMode = ThreadMode.MAIN) @@ -126,6 +130,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX if (e != null) { if (!e.isClear()) { tv_avatarOther_name.setText(e.getUserNiceName()); + tv_avatarOther_name.setTag(e.getUserNiceName()); ImgLoader.displayAvatar(mContext, e.getAvatar(), avatarOther); goto_room_view.setVisibility(View.VISIBLE); } else { @@ -229,49 +234,49 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX //收到邀请这个时候正在PK或连麦中 自动拒绝对方 if (isPking() == true) { - rtcRoom.getLocalUser().responseJoinOtherRoom(userBean.getId(), userBean.getId(), false, false, "extra", new IRCRTCResultCallback() { + rtcRoom.getLocalUser().responseJoinOtherRoom(userBean.getId(), userBean.getId(), false, false, "extra", new IRCRTCResultCallback() { - @Override - public void onFailed(RTCErrorCode errorCode) { + @Override + public void onFailed(RTCErrorCode errorCode) { - } + } - @Override - public void onSuccess() { - final SocketSendBean msg1 = new SocketSendBean() - .param("_method_", SOCKET_LINK_MIC_PK) - .param("action", 8); - msg1.create(); + @Override + public void onSuccess() { + final SocketSendBean msg1 = new SocketSendBean() + .param("_method_", SOCKET_LINK_MIC_PK) + .param("action", 8); + msg1.create(); - String targetId = userBean.getId(); - Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE; - TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString()); - io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(targetId, conversationType, messageContent); + String targetId = userBean.getId(); + Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE; + TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString()); + io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(targetId, conversationType, messageContent); - RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() { - @Override - public void onAttached(io.rong.imlib.model.Message message) { + 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("ry", "发送成功"); + if (SocketRyClient.mSocketHandler != null) { + SocketRyClient.mSocketHandler.processBroadcast(msg1.mResult.toString() + ""); } + } - @Override - public void onSuccess(io.rong.imlib.model.Message message) { + @Override + public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) { + Log.e("ry", "发送失敗" + userBean.getId()); + } + }); + } + }); - Log.e("ry", "发送成功"); - if (SocketRyClient.mSocketHandler != null) { - SocketRyClient.mSocketHandler.processBroadcast(msg1.mResult.toString() + ""); - } - } - - @Override - public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) { - Log.e("ry", "发送失敗" + userBean.getId()); - } - }); - } - }); - - }else if (extra.equals(SOCKET_LIVE_DRPK)) { + } else if (extra.equals(SOCKET_LIVE_DRPK)) { //收到多人PK申请 if (mLiveRyLinkMicPkPresenter != null) { mLiveRyLinkMicPkPresenter.onLinkDRMicPkApply(userBean); @@ -431,16 +436,16 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX @Override public void onFinishOtherRoom(String roomId, String userId) { super.onFinishOtherRoom(roomId, userId); - Log.e("ry",roomId+"房间是"+userId); + Log.e("ry", roomId + "房间是" + userId); RCRTCEngine.getInstance().leaveOtherRoom(roomId, true, new IRCRTCResultCallback() { @Override public void onSuccess() { - Log.e("ry",roomId+"退出啊房间成功"+userId); + Log.e("ry", roomId + "退出啊房间成功" + userId); } @Override public void onFailed(RTCErrorCode errorCode) { - Log.e("ry",roomId+"退出啊房间失败"+userId); + Log.e("ry", roomId + "退出啊房间失败" + userId); } }); @@ -491,6 +496,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX DialogUitl.showSimpleDialog(mContext, "是否要斷開連麥?", new DialogUitl.SimpleCallback() { @Override public void onConfirmClick(Dialog dialog, String content) { + aheadOfScheduleEndPK(mPkUid, CommonAppConfig.getInstance().getUserBean().getUserNiceName(), (String) tv_avatarOther_name.getTag()); //断开连麦 LiveRyAnchorActivity.isDRPK = 0; HttpClient.getInstance().post("livepk.setliveuserout", "livepk.setliveuserout") @@ -597,6 +603,8 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX } }); + + } }); } @@ -975,6 +983,38 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX } + private void aheadOfScheduleEndPK(String pkUid, String uname, String pkname) { + if (!isPk) { + return; + } + String ct = "由於" + uname + "退出比賽," + pkname + "獲得勝利"; + + SocketSendBean seed_msg = new SocketSendBean() + .param("_method_", Constants.SOCKET_SYSTEM) + .param("action", 1) + .param("ct", ct); + seed_msg.create(); + + + HttpClient.getInstance().get("Tx.sendmsgzs2", "Tx.sendmsgzs2") + .params("GroupId", "g" + pkUid) + .params("jsonstr", seed_msg.mResult.toString()) + .execute(new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + HttpClient.getInstance().post("Tx.sendmsgzs2", "Tx.sendmsgzs2") + .params("GroupId", "g" + CommonAppConfig.getInstance().getUid()) + .params("jsonstr", seed_msg.mResult.toString()) + .execute(new HttpCallback() { + @Override + public void onSuccess(int code, String msg, String[] info) { + + } + }); + } + }); + } + private Bitmap decodeResource(Resources resources, int id) { TypedValue value = new TypedValue(); resources.openRawResource(id, value); @@ -1006,4 +1046,13 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX } }); } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void updateSub(LiveAudienceEvent event) { + if (event.getType() == LIVE_PK_END) { + isPk = false; + } else if (event.getType() == LIVE_PK_ING) { + isPk = true; + } + } }