fix:修复公屏历史消息未查询相册类型消息问题
This commit is contained in:
@@ -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<List<ChatRoomMessage>>() {
|
||||
@Override
|
||||
public void onResult(int code, List<ChatRoomMessage> result, Throwable exception) {
|
||||
if (code == ResponseCode.RES_SUCCESS && result != null && result.size() > 0) {
|
||||
if (startTime != 0 && result.size() >= finalCount) {
|
||||
// 过滤后的消息列表
|
||||
// TODO:过滤后消息数量大概率不符合预期展示数量,比如查到50条数据,经过筛选只有5条,但问了iOS目前只是简单这样处理,没有多次查询,所以暂且这样,保持一致。
|
||||
List<ChatRoomMessage> newList = new ArrayList<ChatRoomMessage>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user