|
31 | 31 | import com.netease.nimlib.sdk.NIMClient; |
32 | 32 | import com.netease.nimlib.sdk.friend.FriendService; |
33 | 33 | import com.netease.nimlib.sdk.friend.model.AddFriendNotify; |
| 34 | +import com.netease.nimlib.sdk.msg.MsgService; |
34 | 35 | import com.netease.nimlib.sdk.msg.attachment.AudioAttachment; |
35 | 36 | import com.netease.nimlib.sdk.msg.attachment.ImageAttachment; |
36 | 37 | import com.netease.nimlib.sdk.msg.attachment.LocationAttachment; |
37 | 38 | import com.netease.nimlib.sdk.msg.attachment.MsgAttachment; |
| 39 | +import com.netease.nimlib.sdk.msg.attachment.NotificationAttachment; |
38 | 40 | import com.netease.nimlib.sdk.msg.attachment.VideoAttachment; |
39 | 41 | import com.netease.nimlib.sdk.msg.constant.MsgDirectionEnum; |
40 | 42 | import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum; |
|
50 | 52 | import com.netease.nimlib.sdk.uinfo.UserInfoProvider; |
51 | 53 | import com.netease.nimlib.sdk.uinfo.model.NimUserInfo; |
52 | 54 |
|
| 55 | +import java.util.ArrayList; |
53 | 56 | import java.util.HashMap; |
54 | 57 | import java.util.List; |
55 | 58 | import java.util.Map; |
@@ -139,6 +142,35 @@ public static Object createRecentList(List<RecentContact> recents, int unreadNum |
139 | 142 | map.putString("fromAccount", fromAccount); |
140 | 143 |
|
141 | 144 | String content = contact.getContent(); |
| 145 | + switch (contact.getMsgType()) { |
| 146 | + case text: |
| 147 | + return contact.getContent(); |
| 148 | + case image: |
| 149 | + return "[图片]"; |
| 150 | + case video: |
| 151 | + return "[视频]"; |
| 152 | + case audio: |
| 153 | + return "[语音消息]"; |
| 154 | + case location: |
| 155 | + return "[位置]"; |
| 156 | + case tip: |
| 157 | + List<String> uuids = new ArrayList<>(); |
| 158 | + uuids.add(contact.getRecentMessageId()); |
| 159 | + List<IMMessage> messages = NIMClient.getService(MsgService.class).queryMessageListByUuidBlock(uuids); |
| 160 | + if (messages != null && messages.size() > 0) { |
| 161 | + content = messages.get(0).getContent(); |
| 162 | + } |
| 163 | + break; |
| 164 | + case notification: |
| 165 | + if (sessionType == SessionTypeEnum.Team) { |
| 166 | + content = TeamNotificationHelper.getTeamNotificationText(contact.getContactId(), |
| 167 | + contact.getFromAccount(), |
| 168 | + (NotificationAttachment) contact.getAttachment()); |
| 169 | + } |
| 170 | + break; |
| 171 | + default: |
| 172 | + break; |
| 173 | + } |
142 | 174 | map.putString("time", TimeUtil.getTimeShowString(contact.getTime(), true)); |
143 | 175 |
|
144 | 176 | String fromNick = ""; |
@@ -192,7 +224,7 @@ public static Object createRecentList(List<RecentContact> recents, int unreadNum |
192 | 224 | // if (sessionType == SessionTypeEnum.Team && !rpOpen.isSelf()) { |
193 | 225 | // content = ""; |
194 | 226 | // } else { |
195 | | - content = rpOpen.getTipMsg(false); |
| 227 | + content = rpOpen.getTipMsg(false); |
196 | 228 | // } |
197 | 229 | } |
198 | 230 | break; |
|
0 commit comments