From e89e82483b4dac2f637e937dc9be92e615b0413b Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Mon, 4 Sep 2023 16:25:06 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=B8=AD=E8=8B=B1=E6=96=87?= =?UTF-8?q?=20=E8=B0=83=E6=95=B4=E5=BC=80=E6=92=AD=E9=A2=91=E9=81=93?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/yunbao/common/Constants.java | 1 + .../yunbao/live/adapter/LiveChatAdapter.java | 13 +++++-- .../com/yunbao/live/bean/LiveChatBean.java | 1 + .../yunbao/live/socket/SocketRyClient.java | 36 +++++++++++++------ 4 files changed, 38 insertions(+), 13 deletions(-) diff --git a/common/src/main/java/com/yunbao/common/Constants.java b/common/src/main/java/com/yunbao/common/Constants.java index 95dccdaf3..6f9ed2090 100644 --- a/common/src/main/java/com/yunbao/common/Constants.java +++ b/common/src/main/java/com/yunbao/common/Constants.java @@ -185,6 +185,7 @@ public class Constants { public static final String LIVE_PK_END = "endPK";//结束PK,以这个PK获取到的参数为准 public static final String RED_PACKET = "RedPacket";//红包通知 public static final String RED_PACKET_SUPER_JACKPOT = "RedPacketSuperJackpot";//超级红包通知 + public static final String SOCKET_LIVE_MSG_TO_USER = "SendMsgToUser";//七日用户主播提示语 //游戏socket public static final String SOCKET_GAME_ZJH = "startGame";//炸金花 diff --git a/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java index 98a0245a9..80af285d3 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java @@ -6,6 +6,7 @@ import static com.yunbao.live.bean.LiveChatBean.LUCKY_ANGEL; import static com.yunbao.live.bean.LiveChatBean.RECOMMEND_CARD_NOTIFY; import static com.yunbao.live.bean.LiveChatBean.STAR_CHALLENGE_UPGRADE_NOTIFY; import static com.yunbao.live.bean.LiveChatBean.SYSTEM3_COLOR; +import static com.yunbao.live.bean.LiveChatBean.TYPE_TO_USER_MSG; import static com.yunbao.live.bean.LiveChatBean.WISH_LIST_PROGRESS; import static com.yunbao.live.bean.LiveChatBean.XYD_COMPLETE; @@ -242,7 +243,7 @@ public class LiveChatAdapter extends RecyclerView.Adapter { itemView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { - if (!TextUtils.isEmpty(bean.getId())&&!TextUtils.isEmpty(bean.getUserNiceName())){ + if (!TextUtils.isEmpty(bean.getId()) && !TextUtils.isEmpty(bean.getUserNiceName())) { Bus.get().post(new LiveAudienceEvent() .setType(LiveAudienceEvent.LiveAudienceType.INPUT_DIALOG) .setOlineUserlistModel(new OlineUserlistModel().setId(bean.getId()).setUserNicename(bean.getUserNiceName()))); @@ -391,7 +392,7 @@ public class LiveChatAdapter extends RecyclerView.Adapter { new LoadDian9TuUtil().loadDian9TuAssets(mContext, mBg, 1); mTextView.setText(bean.getContent()); } - } else if (bean.getType() == LiveChatBean.SYSTEM2) { + } else if (bean.getType() == LiveChatBean.SYSTEM2 || bean.getType()==TYPE_TO_USER_MSG) { mTextView.setTextColor(Color.parseColor("#ffffff")); new LoadDian9TuUtil().loadDian9TuAssets(mContext, mBg, 1); mTextView.setText(bean.getContent()); @@ -530,6 +531,10 @@ public class LiveChatAdapter extends RecyclerView.Adapter { if (bean == null) { return; } + if(bean.getType()==LiveChatBean.TYPE_TO_USER_MSG + &&!CommonAppConfig.getInstance().getUid().equals(bean.getAtUserID())){ + return; + } // Log.i(TAG, "insertItem: " + bean.getContent()+" size = "+(mList.size()+1)); int size = mList.size(); //设置最大展示99条消息 @@ -551,7 +556,9 @@ public class LiveChatAdapter extends RecyclerView.Adapter { Bus.get().post(new LiveAudienceEvent() .setType(LiveAudienceEvent.LiveAudienceType.NEW_MESSAGE_REMINDER)); - if (bean.getAtUserID() != null && bean.getAtUserID().contains(String.valueOf(model.getId()))) { + if (bean.getType() != LiveChatBean.TYPE_TO_USER_MSG && + bean.getAtUserID() != null + && bean.getAtUserID().contains(String.valueOf(model.getId()))) { Bus.get().post(new LiveAudienceEvent() .setType(LiveAudienceEvent.LiveAudienceType.AT_MESSAGE)); mPosition = size; diff --git a/live/src/main/java/com/yunbao/live/bean/LiveChatBean.java b/live/src/main/java/com/yunbao/live/bean/LiveChatBean.java index 12e035400..229054e9b 100644 --- a/live/src/main/java/com/yunbao/live/bean/LiveChatBean.java +++ b/live/src/main/java/com/yunbao/live/bean/LiveChatBean.java @@ -27,6 +27,7 @@ public class LiveChatBean { public static final int XYD_COMPLETE = 207;//心愿单完成通知 public static final int WISH_LIST_PROGRESS = 307;//心愿单进度通知 public static final int BLIND_BOX = 409;//盲盒礼物消息 + public static final int TYPE_TO_USER_MSG=500;//指定信息 private String id; 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 f3968ff14..922d1f686 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_LIVE_MSG_TO_USER; import static com.yunbao.live.activity.LiveRyAnchorActivity.isDRPK; import static com.yunbao.live.views.LiveRoomViewHolder.getIsHot; @@ -101,9 +102,9 @@ public class SocketRyClient { @Override public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) { Log.i("tx", "加入" + "失败" + coreErrorCode); - if(WordUtil.isNewZh()) { + if (WordUtil.isNewZh()) { ToastUtil.show("網絡不佳無法連接,請重新進入"); - }else{ + } else { ToastUtil.show("The network is not connected, please re-enter"); } } @@ -199,9 +200,9 @@ public class SocketRyClient { .setObject(JSONArray.parseArray(mic_data.getJSONArray("userlist").toString(), LinkMicUserBean.class)) ); } else if (actions == 6) { - if(WordUtil.isNewZh()) { + if (WordUtil.isNewZh()) { ToastUtil.show("主播已關閉當前語音連麥功能"); - }else{ + } else { ToastUtil.show("The host has disabled the voice connection function"); } EventBus.getDefault().post("endMic"); @@ -209,9 +210,9 @@ public class SocketRyClient { .setType(LiveAudienceEvent.LiveAudienceType.LINK_MIC_CLOSE) .setObject(map.toJavaObject(LinkMicUserBean.class))); } else if (actions == 8) { - if(WordUtil.isNewZh()) { + if (WordUtil.isNewZh()) { ToastUtil.show("您已被移出多人語音連麥"); - }else { + } else { ToastUtil.show("You have been removed from Multi-Voice Connection"); } EventBus.getDefault().post("endMic"); @@ -729,6 +730,9 @@ public class SocketRyClient { .setNewNumber(map.getInteger("new_number")) .setMaxNumber(map.getInteger("max_number"))); break; + case SOCKET_LIVE_MSG_TO_USER: + sendToUserMsg(map); + break; } } @@ -830,6 +834,18 @@ public class SocketRyClient { } } + /** + * 七日留存新用户主播端弹幕显示接口 + */ + private void sendToUserMsg(JSONObject map) { + LiveChatBean bean = new LiveChatBean(); + bean.setId(CommonAppConfig.getInstance().getUid()); + bean.setAtUserID(map.getString("toUserID")); + bean.setContent(map.getString("ct")); + bean.setType(LiveChatBean.TYPE_TO_USER_MSG); + mListener.onChat(bean, 1); + } + private void wordLightEnterRoom(JSONObject map, SocketReceiveBean received) { String msgtype = map.getString("msgtype"); if ("2".equals(msgtype)) {//发言,点亮 @@ -1328,9 +1344,9 @@ public class SocketRyClient { IMRTCManager.getInstance().requestJoinOtherRoom(map.getString("uid"), true, msg1.toString(), new IRCRTCResultCallback() { @Override public void onSuccess() { - if(WordUtil.isNewZh()) { + if (WordUtil.isNewZh()) { ToastUtil.show("邀请 " + map.getString("uid") + " 发送成功"); - }else{ + } else { ToastUtil.show("invite " + map.getString("uid") + " successful"); } runOnUiThread(new Runnable() { @@ -1351,9 +1367,9 @@ public class SocketRyClient { }); //todo 安卓端状态码说明文档:https://docs.rongcloud.cn/v4/views/rtc/call/code/android.html Log.e("ry", rtcErrorCode + "aaaaaa" + CommonAppConfig.getInstance().getUid() + "VDSSSS" + map.getString("uid")); - if(WordUtil.isNewZh()) { + if (WordUtil.isNewZh()) { ToastUtil.show("邀请 " + map.getString("uid") + " 发送失败 :" + rtcErrorCode); - }else{ + } else { ToastUtil.show("invite " + map.getString("uid") + " lose :" + rtcErrorCode); } }