新增主動PK結束通知

This commit is contained in:
zlzw 2023-08-31 15:14:15 +08:00
parent 357ece2ebe
commit 8d984951c3
2 changed files with 112 additions and 37 deletions

View File

@ -352,6 +352,30 @@ public class LiveGiftPopup extends AbsDialogFragment {
fragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment"); 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) { if (IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) {
ImgLoader.display(mContext, R.mipmap.icon_live_gift_gift_itle, giftItle); ImgLoader.display(mContext, R.mipmap.icon_live_gift_gift_itle, giftItle);
} else { } else {
@ -809,6 +833,8 @@ public class LiveGiftPopup extends AbsDialogFragment {
if (!TextUtils.isEmpty(liveGiftModel.getOperateImage())) { if (!TextUtils.isEmpty(liveGiftModel.getOperateImage())) {
operateImage.setVisibility(View.VISIBLE); operateImage.setVisibility(View.VISIBLE);
ImgLoader.display(getContext(), liveGiftModel.getOperateImage(), operateImage); ImgLoader.display(getContext(), liveGiftModel.getOperateImage(), operateImage);
}else {
operateImage.setVisibility(View.GONE);
} }
} }

View File

@ -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_LINK_MIC_PK;
import static com.yunbao.common.Constants.SOCKET_LIVE_DRPK; import static com.yunbao.common.Constants.SOCKET_LIVE_DRPK;
import static com.yunbao.live.activity.LiveActivity.mLiveRyLinkMicPkPresenter; 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.inputStreamList;
import static com.yunbao.live.presenter.LiveRyLinkMicPkPresenter.inputStreamList1; 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 static cn.rongcloud.rtc.base.RCRTCLiveRole.BROADCASTER;
import android.app.Dialog; import android.app.Dialog;
@ -118,6 +121,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
private TextView tv_avatarOther_name; private TextView tv_avatarOther_name;
private ImageView avatarOther; private ImageView avatarOther;
private LinearLayout goto_room_view; private LinearLayout goto_room_view;
private boolean isPk = false;
//修改上面主播的头像 //修改上面主播的头像
@Subscribe(threadMode = ThreadMode.MAIN) @Subscribe(threadMode = ThreadMode.MAIN)
@ -126,6 +130,7 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
if (e != null) { if (e != null) {
if (!e.isClear()) { if (!e.isClear()) {
tv_avatarOther_name.setText(e.getUserNiceName()); tv_avatarOther_name.setText(e.getUserNiceName());
tv_avatarOther_name.setTag(e.getUserNiceName());
ImgLoader.displayAvatar(mContext, e.getAvatar(), avatarOther); ImgLoader.displayAvatar(mContext, e.getAvatar(), avatarOther);
goto_room_view.setVisibility(View.VISIBLE); goto_room_view.setVisibility(View.VISIBLE);
} else { } else {
@ -229,49 +234,49 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
//收到邀请这个时候正在PK或连麦中 自动拒绝对方 //收到邀请这个时候正在PK或连麦中 自动拒绝对方
if (isPking() == true) { 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 @Override
public void onFailed(RTCErrorCode errorCode) { public void onFailed(RTCErrorCode errorCode) {
} }
@Override @Override
public void onSuccess() { public void onSuccess() {
final SocketSendBean msg1 = new SocketSendBean() final SocketSendBean msg1 = new SocketSendBean()
.param("_method_", SOCKET_LINK_MIC_PK) .param("_method_", SOCKET_LINK_MIC_PK)
.param("action", 8); .param("action", 8);
msg1.create(); msg1.create();
String targetId = userBean.getId(); String targetId = userBean.getId();
Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE; Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString()); TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString());
io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(targetId, conversationType, messageContent); io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(targetId, conversationType, messageContent);
RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() { RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() {
@Override @Override
public void onAttached(io.rong.imlib.model.Message message) { 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 @Override
public void onSuccess(io.rong.imlib.model.Message message) { public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) {
Log.e("ry", "发送失敗" + userBean.getId());
}
});
}
});
Log.e("ry", "发送成功"); } else if (extra.equals(SOCKET_LIVE_DRPK)) {
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)) {
//收到多人PK申请 //收到多人PK申请
if (mLiveRyLinkMicPkPresenter != null) { if (mLiveRyLinkMicPkPresenter != null) {
mLiveRyLinkMicPkPresenter.onLinkDRMicPkApply(userBean); mLiveRyLinkMicPkPresenter.onLinkDRMicPkApply(userBean);
@ -431,16 +436,16 @@ public class LivePushRyViewHolder extends AbsRyLivePushViewHolder implements ITX
@Override @Override
public void onFinishOtherRoom(String roomId, String userId) { public void onFinishOtherRoom(String roomId, String userId) {
super.onFinishOtherRoom(roomId, userId); super.onFinishOtherRoom(roomId, userId);
Log.e("ry",roomId+"房间是"+userId); Log.e("ry", roomId + "房间是" + userId);
RCRTCEngine.getInstance().leaveOtherRoom(roomId, true, new IRCRTCResultCallback() { RCRTCEngine.getInstance().leaveOtherRoom(roomId, true, new IRCRTCResultCallback() {
@Override @Override
public void onSuccess() { public void onSuccess() {
Log.e("ry",roomId+"退出啊房间成功"+userId); Log.e("ry", roomId + "退出啊房间成功" + userId);
} }
@Override @Override
public void onFailed(RTCErrorCode errorCode) { 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() { DialogUitl.showSimpleDialog(mContext, "是否要斷開連麥?", new DialogUitl.SimpleCallback() {
@Override @Override
public void onConfirmClick(Dialog dialog, String content) { public void onConfirmClick(Dialog dialog, String content) {
aheadOfScheduleEndPK(mPkUid, CommonAppConfig.getInstance().getUserBean().getUserNiceName(), (String) tv_avatarOther_name.getTag());
//断开连麦 //断开连麦
LiveRyAnchorActivity.isDRPK = 0; LiveRyAnchorActivity.isDRPK = 0;
HttpClient.getInstance().post("livepk.setliveuserout", "livepk.setliveuserout") 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) { private Bitmap decodeResource(Resources resources, int id) {
TypedValue value = new TypedValue(); TypedValue value = new TypedValue();
resources.openRawResource(id, value); 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;
}
}
} }