From 5baea0f156be198d44c254aab458c991beb14cfb Mon Sep 17 00:00:00 2001 From: Martin <13046765170@163.com> Date: Wed, 5 Jun 2024 15:12:35 +0800 Subject: [PATCH] =?UTF-8?q?fix[=E4=BF=AE=E5=A4=8D-=E6=B8=B8=E6=88=8F?= =?UTF-8?q?=E6=88=BF=E6=B6=88=E6=81=AF=E9=97=AE=E9=A2=98]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/shayu/phonelive/AppContext.java | 76 +++++++++++-------- .../common/event/SudGameSocketImEvent.java | 9 +++ .../manager/imrongcloud/GameSwMicManager.java | 8 ++ .../yunbao/live/views/LiveRoomViewHolder.java | 10 +-- live/src/main/res/layout/view_live_room.xml | 2 +- 5 files changed, 67 insertions(+), 38 deletions(-) diff --git a/app/src/main/java/com/shayu/phonelive/AppContext.java b/app/src/main/java/com/shayu/phonelive/AppContext.java index af4de4c66..90b419900 100644 --- a/app/src/main/java/com/shayu/phonelive/AppContext.java +++ b/app/src/main/java/com/shayu/phonelive/AppContext.java @@ -30,6 +30,7 @@ import com.tencent.imsdk.v2.V2TIMGroupMemberInfo; import com.tencent.imsdk.v2.V2TIMManager; import com.tencent.imsdk.v2.V2TIMSimpleMsgListener; import com.tencent.imsdk.v2.V2TIMUserInfo; +import com.yunbao.common.http.Data; import com.yunbao.common.manager.OpenAdManager; import com.yunbao.common.utils.MobclickAgent; import com.yunbao.common.BuildConfig; @@ -65,6 +66,7 @@ import java.io.IOException; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Arrays; +import java.util.Date; import java.util.List; import io.rong.imkit.config.RongConfigCenter; @@ -123,7 +125,7 @@ public class AppContext extends CommonAppContext { @Override public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) { activities.add(new WeakReference<>(activity)); - if(activity instanceof LoginActivity){ + if (activity instanceof LoginActivity) { AppManager.getInstance().clear(); } CrashSaveBean.getInstance().setActivitySize(activities); @@ -205,7 +207,7 @@ public class AppContext extends CommonAppContext { RongcloudIMManager.addRongcloudIMOnReceiveMessageListener(new RongIMClient.OnReceiveMessageWrapperListener() { @Override public boolean onReceived(io.rong.imlib.model.Message message, int i, boolean b, boolean b1) { - Log.e("wewe", message.getConversationType() + "112121 "+message.getContent()); + Log.e("wewe", message.getConversationType() + "112121 " + message.getContent()); MessageIMManager.get(sInstance).getSystemForRongcloud(message); //融云直播间聊天 Message msg = Message.obtain(); @@ -216,41 +218,51 @@ public class AppContext extends CommonAppContext { if (content.getContent().contains("_method_")) { msg.obj = content.getContent(); //观众页面 + + String time = String.valueOf(new Date().getTime()); //声网 - if (SocketSwClient.mSocketHandler != null && (TextUtils.equals("__system__", message.getTargetId()) || ("g" + PortraitLiveManager.liveID).contains(message.getTargetId()))) { - SocketSwClient.mSocketHandler.sendMessage(msg); - } else if (content.getContent().contains("LivePK_anchorStartLiveNotify")) {//开播通知 - SocketReceiveBean received = JSON.parseObject(content.getContent(), SocketReceiveBean.class); - JSONObject map = received.getMsg().getJSONObject(0); - sendStartAnchorLive(map); - } else if (message.getTargetId().contains("v")) { - String contentJson = ((TextMessage) message.getContent()).getContent(); - Log.e("wewe", contentJson); - SudGameSocketImEvent sudGameSocketImEvent = new Gson().fromJson(contentJson, SudGameSocketImEvent.class); - Bus.get().post(sudGameSocketImEvent); - } - //主播页面 - if (TextUtils.isEmpty(PortraitLiveManager.liveID) && SocketSwClient.mSocketHandler != null) { - SocketSwClient.mSocketHandler.sendMessage(msg); + if (SocketSwClient.mSocketHandler != null && (TextUtils.equals("__system__", message.getTargetId()) || ("g" + PortraitLiveManager.liveID).contains(message.getTargetId()))) { + SocketSwClient.mSocketHandler.sendMessage(msg); + } else if (content.getContent().contains("LivePK_anchorStartLiveNotify")) {//开播通知 + SocketReceiveBean received = JSON.parseObject(content.getContent(), SocketReceiveBean.class); + JSONObject map = received.getMsg().getJSONObject(0); + sendStartAnchorLive(map); + } else if (message.getTargetId().contains("v")) { + String contentJson = ((TextMessage) message.getContent()).getContent(); + Log.e("wewe", contentJson); + SudGameSocketImEvent sudGameSocketImEvent = new Gson().fromJson(contentJson, SudGameSocketImEvent.class); + if (sudGameSocketImEvent.getMsg().isEmpty()) { + return false; } + sudGameSocketImEvent.getMsg().get(0).setTime(time); + Bus.get().post(sudGameSocketImEvent); + } + //主播页面 + if (TextUtils.isEmpty(PortraitLiveManager.liveID) && SocketSwClient.mSocketHandler != null) { + SocketSwClient.mSocketHandler.sendMessage(msg); + } //融云 - if (SocketRyClient.mSocketHandler != null && (TextUtils.equals("__system__", message.getTargetId()) || ("g" + PortraitLiveManager.liveID).contains(message.getTargetId()))) { - SocketRyClient.mSocketHandler.sendMessage(msg); - } else if (content.getContent().contains("LivePK_anchorStartLiveNotify")) {//开播通知 - SocketReceiveBean received = JSON.parseObject(content.getContent(), SocketReceiveBean.class); - JSONObject map = received.getMsg().getJSONObject(0); - sendStartAnchorLive(map); - } else if (message.getTargetId().contains("v")) { - String contentJson = ((TextMessage) message.getContent()).getContent(); - Log.e("wewe", contentJson); - SudGameSocketImEvent sudGameSocketImEvent = new Gson().fromJson(contentJson, SudGameSocketImEvent.class); - Bus.get().post(sudGameSocketImEvent); - } - //主播页面 - if (TextUtils.isEmpty(PortraitLiveManager.liveID) && SocketRyClient.mSocketHandler != null) { - SocketRyClient.mSocketHandler.sendMessage(msg); + if (SocketRyClient.mSocketHandler != null && (TextUtils.equals("__system__", message.getTargetId()) || ("g" + PortraitLiveManager.liveID).contains(message.getTargetId()))) { + SocketRyClient.mSocketHandler.sendMessage(msg); + } else if (content.getContent().contains("LivePK_anchorStartLiveNotify")) {//开播通知 + SocketReceiveBean received = JSON.parseObject(content.getContent(), SocketReceiveBean.class); + JSONObject map = received.getMsg().getJSONObject(0); + sendStartAnchorLive(map); + } else if (message.getTargetId().contains("v")) { + String contentJson = ((TextMessage) message.getContent()).getContent(); + Log.e("wewe", contentJson); + SudGameSocketImEvent sudGameSocketImEvent = new Gson().fromJson(contentJson, SudGameSocketImEvent.class); + if (sudGameSocketImEvent.getMsg().isEmpty()) { + return false; } + sudGameSocketImEvent.getMsg().get(0).setTime(time); + Bus.get().post(sudGameSocketImEvent); + } + //主播页面 + if (TextUtils.isEmpty(PortraitLiveManager.liveID) && SocketRyClient.mSocketHandler != null) { + SocketRyClient.mSocketHandler.sendMessage(msg); + } } else if (message.getConversationType() == Conversation.ConversationType.PRIVATE) {//私聊信息 EventBus.getDefault().post(message); } diff --git a/common/src/main/java/com/yunbao/common/event/SudGameSocketImEvent.java b/common/src/main/java/com/yunbao/common/event/SudGameSocketImEvent.java index 31d9ec28e..6956f7d18 100644 --- a/common/src/main/java/com/yunbao/common/event/SudGameSocketImEvent.java +++ b/common/src/main/java/com/yunbao/common/event/SudGameSocketImEvent.java @@ -53,6 +53,15 @@ public class SudGameSocketImEvent extends BaseModel { private String method; @SerializedName("equipment") private String equipment; + private String time; + + public String getTime() { + return time; + } + + public void setTime(String time) { + this.time = time; + } public String getAction() { return action; diff --git a/common/src/main/java/com/yunbao/common/manager/imrongcloud/GameSwMicManager.java b/common/src/main/java/com/yunbao/common/manager/imrongcloud/GameSwMicManager.java index b4c9abc59..2b3f90f2b 100644 --- a/common/src/main/java/com/yunbao/common/manager/imrongcloud/GameSwMicManager.java +++ b/common/src/main/java/com/yunbao/common/manager/imrongcloud/GameSwMicManager.java @@ -433,6 +433,8 @@ public class GameSwMicManager { }); } + String lastTime = ""; + /** * 处理游戏房Im消息 */ @@ -441,6 +443,11 @@ public class GameSwMicManager { List msgDTOS = socketImModel.getMsg(); if (msgDTOS.isEmpty()) return; SudGameSocketImEvent.MsgDTO msgDTO = msgDTOS.get(0); + + if(lastTime.equals(msgDTO.getTime())){ + return; + } + lastTime = msgDTO.getTime(); //正常文字消息 if (TextUtils.equals(msgDTO.getMethod(), "SendMsg")) { getView().insertItem(new SudGameChatImModel().setWelcomMessage(false).setNickname(msgDTO.getUname()).setTextMessage(msgDTO.getCt())); @@ -498,6 +505,7 @@ public class GameSwMicManager { String contentJson = ((TextMessage) message.getContent()).getContent(); Log.e("wewe", contentJson); SudGameSocketImEvent sudGameSocketImEvent = new Gson().fromJson(contentJson, SudGameSocketImEvent.class); + sudGameSocketImEvent.getMsg().get(0).setTime("11"); processingMessage(sudGameSocketImEvent); } 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 1f520ef19..244446584 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -407,6 +407,11 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis return this; } + @Override + protected int getLayoutId() { + return R.layout.view_live_room; + } + @Subscribe(threadMode = ThreadMode.MAIN) public void onUpdata(String str) { if ("svga_new_user_gif".equals(str)) { @@ -713,11 +718,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis sudNameHandler.postDelayed(sudNameRunnable, 10000); } - @Override - protected int getLayoutId() { - return R.layout.view_live_room; - } - private View sudGameMin; public void onShowHideEvent() { diff --git a/live/src/main/res/layout/view_live_room.xml b/live/src/main/res/layout/view_live_room.xml index 501c5c43a..64345b088 100644 --- a/live/src/main/res/layout/view_live_room.xml +++ b/live/src/main/res/layout/view_live_room.xml @@ -691,7 +691,7 @@ android:layout_height="27dp" android:layout_below="@id/open_sidebar" android:layout_alignParentRight="true" - android:layout_marginTop="16dp" + android:layout_marginTop="20dp" android:layout_marginRight="9dp" android:background="@drawable/bg_live_other_ico" android:gravity="center">