From 8f9a5bd5659b8e245a80040a2a776ea26d02dca1 Mon Sep 17 00:00:00 2001 From: wzq Date: Tue, 17 Oct 2023 14:08:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=BF=E9=97=B4=E7=9B=B8=E5=86=8C=20?= =?UTF-8?q?=E5=85=AC=E5=B1=8F=E6=B6=88=E6=81=AFUI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../erban/avroom/widget/MessageView.java | 33 ++++- .../com/yizhuan/erban/ui/im/ImInitHelper.java | 4 +- app/src/main/res/drawable/bg_9168fa_6.xml | 8 ++ .../layout_msg_view_holder_room_album.xml | 116 ++++++++++++++++++ .../manager/IMNetEaseManager.java | 1 - .../im/custom/bean/CustomAttachParser.java | 8 +- .../im/custom/bean/CustomAttachment.java | 4 + .../im/custom/bean/RoomAlbumAttachment.java | 15 +++ 8 files changed, 182 insertions(+), 7 deletions(-) create mode 100644 app/src/main/res/drawable/bg_9168fa_6.xml create mode 100644 app/src/main/res/layout/layout_msg_view_holder_room_album.xml create mode 100644 core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/RoomAlbumAttachment.java diff --git a/app/src/main/java/com/yizhuan/erban/avroom/widget/MessageView.java b/app/src/main/java/com/yizhuan/erban/avroom/widget/MessageView.java index bb3638313..4b817295b 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/widget/MessageView.java +++ b/app/src/main/java/com/yizhuan/erban/avroom/widget/MessageView.java @@ -3,6 +3,7 @@ package com.yizhuan.erban.avroom.widget; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_FAIRY; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GIFT_COMPOUND; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_RED_PACKAGE; +import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ROOM_ALBUM; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ME; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_CONVERT_L1; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_CONVERT_L2; @@ -42,6 +43,7 @@ import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; +import android.widget.ImageView; import android.widget.TextView; import androidx.annotation.NonNull; @@ -59,6 +61,7 @@ import com.netease.nim.uikit.common.util.sys.ScreenUtil; import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage; import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessageExtension; import com.netease.nimlib.sdk.chatroom.model.ChatRoomNotificationAttachment; +import com.netease.nimlib.sdk.msg.attachment.MsgAttachment; import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum; import com.netease.nimlib.sdk.msg.constant.NotificationType; import com.netease.nimlib.sdk.msg.model.IMMessage; @@ -735,8 +738,28 @@ public class MessageView extends FrameLayout { this.data = data; } + @Override + public int getItemViewType(int position) { + ChatRoomMessage chatRoomMessage = data.get(position); + if (chatRoomMessage.getMsgType() == MsgTypeEnum.custom) { + MsgAttachment attachment = chatRoomMessage.getAttachment(); + if (attachment instanceof CustomAttachment) { + if (((CustomAttachment) attachment).getFirst() == CustomAttachment.CUSTOM_MSG_ROOM_ALBUM) { + return CustomAttachment.CUSTOM_MSG_ROOM_ALBUM; + } + } + } + + return super.getItemViewType(position); + } + @Override public MessageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { + if (viewType == CustomAttachment.CUSTOM_MSG_ROOM_ALBUM) { + return new MessageViewHolder(LayoutInflater.from(parent.getContext()) + .inflate(R.layout.layout_msg_view_holder_room_album, parent, false)); + + } return new MessageViewHolder(LayoutInflater.from(parent.getContext()) .inflate(R.layout.list_item_chatrrom_msg, parent, false)); } @@ -995,6 +1018,8 @@ public class MessageView extends FrameLayout { setGiftCompoundMsg(chatRoomMessage, tvContent); } else if (first == CUSTOM_MSG_FAIRY) { setFairyMsg(chatRoomMessage, tvContent); + } else if (first == CUSTOM_MSG_ROOM_ALBUM) { + setRoomAlbumMsg(chatRoomMessage, baseViewHolder); } else { tvContent.setTextColor(Color.WHITE); tvContent.setText(tvContent.getResources().getText(R.string.not_support_message_tip)); @@ -1008,6 +1033,12 @@ public class MessageView extends FrameLayout { } } + private void setRoomAlbumMsg(ChatRoomMessage chatRoomMessage, MessageViewHolder baseViewHolder) { + ImageView ivUserLevel = baseViewHolder.itemView.findViewById(R.id.iv_user_level); + ImageView ivUserCharm = baseViewHolder.itemView.findViewById(R.id.iv_user_charm); + + } + private void setFairyMsg(ChatRoomMessage chatRoomMessage, TextView tvContent) { if (chatRoomMessage.getAttachment() instanceof FairyMsgAttachment) { FairyMsgAttachment attachment = (FairyMsgAttachment) chatRoomMessage.getAttachment(); @@ -1326,7 +1357,7 @@ public class MessageView extends FrameLayout { case CustomAttachment.CUSTOM_MESS_TAROT_SENIOR_PRIZE_WINNING: text.append(ResUtil.getString(R.string.avroom_widget_messageview_026), new ForegroundColorSpan(textColor)) .append(nickName, new ForegroundColorSpan(roomTipNickColor)) - .append(ResUtil.getString(R.string.avroom_widget_messageview_0160), new ForegroundColorSpan(textColor)) + .append(ResUtil.getString(R.string.avroom_widget_messageview_0160), new ForegroundColorSpan(textColor)) .append(tarotMsgBean.getDrawGoldNum() + ResUtil.getString(R.string.avroom_widget_messageview_027), new ForegroundColorSpan(roomTipColor)); tvContent.setText(text.build()); break; diff --git a/app/src/main/java/com/yizhuan/erban/ui/im/ImInitHelper.java b/app/src/main/java/com/yizhuan/erban/ui/im/ImInitHelper.java index 41b0ec718..cfc0a8106 100644 --- a/app/src/main/java/com/yizhuan/erban/ui/im/ImInitHelper.java +++ b/app/src/main/java/com/yizhuan/erban/ui/im/ImInitHelper.java @@ -22,13 +22,13 @@ import com.yizhuan.erban.ui.im.avtivity.NimP2PMessageActivity; import com.yizhuan.erban.ui.im.chat.MsgViewHolderAudioParty; import com.yizhuan.erban.ui.im.chat.MsgViewHolderChatHint; import com.yizhuan.erban.ui.im.chat.MsgViewHolderContent; -import com.yizhuan.erban.ui.im.chat.MsgViewHolderP2PContactRecharge; import com.yizhuan.erban.ui.im.chat.MsgViewHolderFairy; import com.yizhuan.erban.ui.im.chat.MsgViewHolderGift; import com.yizhuan.erban.ui.im.chat.MsgViewHolderHello; import com.yizhuan.erban.ui.im.chat.MsgViewHolderLevel; import com.yizhuan.erban.ui.im.chat.MsgViewHolderLottery; import com.yizhuan.erban.ui.im.chat.MsgViewHolderOnline; +import com.yizhuan.erban.ui.im.chat.MsgViewHolderP2PContactRecharge; import com.yizhuan.erban.ui.im.chat.MsgViewHolderRedPackage; import com.yizhuan.erban.ui.im.chat.MsgViewHolderRedPacket; import com.yizhuan.erban.ui.im.chat.MsgViewHolderSkill; @@ -44,7 +44,6 @@ import com.yizhuan.xchat_android_core.im.custom.bean.CarAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.CarveUpGoldThirdLevelAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.ChatHintAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.CpInviteAttachment; -import com.yizhuan.xchat_android_core.im.custom.bean.P2PContactRechargeAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.FairySendAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.GiftAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.InAppSharingFamilyAttachment; @@ -60,6 +59,7 @@ import com.yizhuan.xchat_android_core.im.custom.bean.NobleAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.NoticeAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.OpenRoomNotiAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.OpenSignInAttachment; +import com.yizhuan.xchat_android_core.im.custom.bean.P2PContactRechargeAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.RedPackageAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.RedPacketAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.SkillMsgAttachment; diff --git a/app/src/main/res/drawable/bg_9168fa_6.xml b/app/src/main/res/drawable/bg_9168fa_6.xml new file mode 100644 index 000000000..91f5ee8d4 --- /dev/null +++ b/app/src/main/res/drawable/bg_9168fa_6.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/layout_msg_view_holder_room_album.xml b/app/src/main/res/layout/layout_msg_view_holder_room_album.xml new file mode 100644 index 000000000..1ee048e82 --- /dev/null +++ b/app/src/main/res/layout/layout_msg_view_holder_room_album.xml @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/IMNetEaseManager.java b/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/IMNetEaseManager.java index 2ae919950..961ef620f 100644 --- a/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/IMNetEaseManager.java +++ b/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/IMNetEaseManager.java @@ -97,7 +97,6 @@ import com.yizhuan.xchat_android_core.im.custom.bean.MonsterAttackAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.MonsterHuntingResultAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.MonsterStatusAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.MultiGiftAttachment; -import com.yizhuan.xchat_android_core.im.custom.bean.MultiLuckyGiftAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.NobleAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.RoomBoxPrizeAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.RoomFreeGiftAttachment; diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachParser.java b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachParser.java index c7ee3519d..e5255c18c 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachParser.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachParser.java @@ -100,7 +100,6 @@ import com.yizhuan.xchat_android_core.community.attachment.DynamicSysAttachment; import com.yizhuan.xchat_android_core.community.attachment.UnReadCountAttachment; import com.yizhuan.xchat_android_core.community.im.WorldDynamicAttachment; import com.yizhuan.xchat_android_core.gift.GiftModel; -import com.yizhuan.xchat_android_core.gift.event.UpdateKnapFreeGiftNumEvent; import com.yizhuan.xchat_android_core.im.custom.AttachManager; import com.yizhuan.xchat_android_core.mentoring_relationship.attachment.MentoringApprenticeMissionFourAttachment; import com.yizhuan.xchat_android_core.mentoring_relationship.attachment.MentoringApprenticeMissionOneAttachment; @@ -127,8 +126,6 @@ import com.yizhuan.xchat_android_core.utils.LogUtils; import com.yizhuan.xchat_android_library.utils.ResUtil; import com.yizhuan.xchat_android_library.utils.log.MLog; -import org.greenrobot.eventbus.EventBus; - /** * 云信自定义消息解析器 * @@ -651,6 +648,11 @@ public class CustomAttachParser implements MsgAttachmentParser { attachment = new P2PContactRechargeAttachment(); } break; + case CustomAttachment.CUSTOM_MSG_ROOM_ALBUM: + if (second == CustomAttachment.CUSTOM_MSG_ROOM_ALBUM_SUB) { + attachment = new RoomAlbumAttachment(); + } + break; default: LogUtils.e(ResUtil.getString(R.string.custom_bean_customattachparser_01) + first + " second=" + second); break; diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachment.java b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachment.java index ab4356be0..ded3ced58 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachment.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachment.java @@ -475,6 +475,10 @@ public class CustomAttachment implements MsgAttachment { */ public static final int CUSTOM_MSG_NOTIFY_H5_SUB_WHOLE_SERVICE = 1102; + public static final int CUSTOM_MSG_ROOM_ALBUM = 101; + public static final int CUSTOM_MSG_ROOM_ALBUM_SUB = 1011; + + /** * 自定义消息附件的类型,根据该字段区分不同的自定义消息 */ diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/RoomAlbumAttachment.java b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/RoomAlbumAttachment.java new file mode 100644 index 000000000..ca4cf929f --- /dev/null +++ b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/RoomAlbumAttachment.java @@ -0,0 +1,15 @@ +package com.yizhuan.xchat_android_core.im.custom.bean; + +import com.alibaba.fastjson.JSONObject; + +public class RoomAlbumAttachment extends CustomAttachment { + + public RoomAlbumAttachment() { + super(CUSTOM_MSG_ROOM_ALBUM, CUSTOM_MSG_ROOM_ALBUM_SUB); + } + + @Override + protected void parseData(JSONObject data) { + } + +}