From 5900702ca60232a9160aa42aca00b5e2ff9c140a Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 31 Oct 2023 15:14:04 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E5=85=AC?= =?UTF-8?q?=E5=B1=8F=E5=8E=86=E5=8F=B2=E6=B6=88=E6=81=AF=E6=9C=AA=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E7=9B=B8=E5=86=8C=E7=B1=BB=E5=9E=8B=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../room/model/AvRoomModel.java | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/room/model/AvRoomModel.java b/core/src/main/java/com/yizhuan/xchat_android_core/room/model/AvRoomModel.java index 94ba017a1..ab80bf96a 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/room/model/AvRoomModel.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/room/model/AvRoomModel.java @@ -18,6 +18,7 @@ import com.netease.nimlib.sdk.chatroom.model.ChatRoomMember; import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage; import com.netease.nimlib.sdk.chatroom.model.EnterChatRoomData; import com.netease.nimlib.sdk.chatroom.model.EnterChatRoomResultData; +import com.netease.nimlib.sdk.msg.attachment.MsgAttachment; import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum; import com.netease.nimlib.sdk.msg.model.QueryDirectionEnum; import com.orhanobut.logger.Logger; @@ -28,6 +29,7 @@ import com.yizhuan.xchat_android_core.decoration.car.bean.CarInfo; import com.yizhuan.xchat_android_core.decoration.headwear.bean.HeadWearInfo; import com.yizhuan.xchat_android_core.gift.bean.GiftInfo; import com.yizhuan.xchat_android_core.home.bean.HomeRoomInfo; +import com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment; import com.yizhuan.xchat_android_core.initial.InitialModel; import com.yizhuan.xchat_android_core.initial.bean.InitInfo; import com.yizhuan.xchat_android_core.level.UserLevelVo; @@ -61,6 +63,7 @@ import com.yizhuan.xchat_android_library.utils.ResUtil; import org.greenrobot.eventbus.EventBus; +import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -661,19 +664,37 @@ public class AvRoomModel extends RoomBaseModel implements IAvRoomModel { startTime, count, startTime == 0 ? QueryDirectionEnum.QUERY_OLD : QueryDirectionEnum.QUERY_NEW, - new MsgTypeEnum[]{MsgTypeEnum.text}) + new MsgTypeEnum[]{MsgTypeEnum.text, MsgTypeEnum.custom}) .setCallback(new RequestCallbackWrapper>() { @Override public void onResult(int code, List result, Throwable exception) { if (code == ResponseCode.RES_SUCCESS && result != null && result.size() > 0) { - if (startTime != 0 && result.size() >= finalCount) { + // 过滤后的消息列表 + // TODO:过滤后消息数量大概率不符合预期展示数量,比如查到50条数据,经过筛选只有5条,但问了iOS目前只是简单这样处理,没有多次查询,所以暂且这样,保持一致。 + List newList = new ArrayList(); + for (int i = 0; i < result.size(); i++) { + ChatRoomMessage message = result.get(i); + if (message.getMsgType() == MsgTypeEnum.custom) { + MsgAttachment attachment = message.getAttachment(); + if (attachment instanceof CustomAttachment) { + // 找出相册消息 + if (((CustomAttachment) attachment).getFirst() == CustomAttachment.CUSTOM_MSG_ROOM_ALBUM) { + newList.add(message); + } + } + } else { + // 普通text消息 + newList.add(message); + } + } + if (startTime != 0 && newList.size() >= finalCount) { loadMessageHistory(0); return; } if (startTime == 0) { - Collections.reverse(result); + Collections.reverse(newList); } - AvRoomDataManager.get().addChatRoomMessages(result); + AvRoomDataManager.get().addChatRoomMessages(newList); } } });