From cee6060d62a30b7ebdb0190ac69daa418b6e6087 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 21 Feb 2024 14:06:37 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E6=96=B0=E5=A2=9E=E5=AE=88?= =?UTF-8?q?=E6=8A=A4=E6=98=9F=E7=90=83=E5=85=AC=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../erban/avroom/widget/MessageView.java | 35 ++++++++++++ app/src/main/res/values/strings.xml | 2 + .../manager/IMNetEaseManager.java | 8 +++ .../im/custom/bean/CustomAttachParser.java | 4 ++ .../im/custom/bean/CustomAttachment.java | 5 ++ .../custom/bean/GuardianPlanetAttachment.java | 54 +++++++++++++++++++ 6 files changed, 108 insertions(+) create mode 100644 core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/GuardianPlanetAttachment.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 507bf28f9..f0d24d640 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 @@ -2,6 +2,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_GUARDIAN_PLANET; 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; @@ -119,6 +120,7 @@ import com.yizhuan.xchat_android_core.im.custom.bean.GiftAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.GiftBatchAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.GiftCompoundAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.GiftCompoundMsgBean; +import com.yizhuan.xchat_android_core.im.custom.bean.GuardianPlanetAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.JoinMiniWorldAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.JoinMiniWorldNoticeAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.MagicAllMicAttachment; @@ -1032,6 +1034,8 @@ public class MessageView extends FrameLayout { setFairyMsg(chatRoomMessage, tvContent); } else if (first == CUSTOM_MSG_ROOM_ALBUM) { setRoomAlbumMsg(chatRoomMessage, baseViewHolder); + } else if (first == CUSTOM_MSG_GUARDIAN_PLANET) { + setGuardianPlanetMsg(chatRoomMessage, tvContent); } else { tvContent.setTextColor(Color.WHITE); tvContent.setText(tvContent.getResources().getText(R.string.not_support_message_tip)); @@ -1948,6 +1952,37 @@ public class MessageView extends FrameLayout { tvContent.setText(text.build()); } + private void setGuardianPlanetMsg(ChatRoomMessage chatRoomMessage, TextView tvContent) { + GuardianPlanetAttachment attachment = (GuardianPlanetAttachment) chatRoomMessage.getAttachment(); + // 內容 + SpannableBuilder text = new SpannableBuilder(tvContent) + .append(ResUtil.getString(R.string.congratulation), new ForegroundColorSpan(greyColor)) + .append(attachment.getNick(), new ForegroundColorSpan(roomTipNickColor), + new OriginalDrawStatusClickSpan() { + @Override + public void onClick(@NonNull View widget) { + if (clickConsumer != null) { + Single.just(String.valueOf(attachment.getUid())).subscribe(clickConsumer); + } + } + }) + .append( + ResUtil.getString(R.string.guardian_planet_msg_1), + new ForegroundColorSpan(greyColor) + ) + .append( + String.valueOf(attachment.getDiamonds()), + new ForegroundColorSpan(whiteColor) + ) + .append( + ResUtil.getString(R.string.guardian_planet_msg_2), + new ForegroundColorSpan(greyColor) + ); + tvContent.setText(text.build()); + tvContent.setOnClickListener(null); + tvContent.setMovementMethod(new LinkMovementMethod()); + } + private void setLuckySeaMsg(ChatRoomMessage chatRoomMessage, TextView tvContent) { RoomLuckySeaAttachment attachment = (RoomLuckySeaAttachment) chatRoomMessage.getAttachment(); RoomLuckySeaMsgBean bean = attachment.getRoomLuckySeaMsgInfo(); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3d275e11c..2e49b31d2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -4983,6 +4983,8 @@ 房間 恭喜 在星級厨房抽中 + 在守護星球中成功擊敗怪獸,獲得 + 鉆石獎勵! 倍獎勵,獲得 鉆石! 免費禮物 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 485e75583..4d7b960c1 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 @@ -1001,6 +1001,14 @@ public final class IMNetEaseManager { break; } break; + case CUSTOM_MSG_GUARDIAN_PLANET: + switch (second){ + case CUSTOM_MSG_SUB_GUARDIAN_PLANET_ROOM: + case CUSTOM_MSG_SUB_GUARDIAN_PLANET_ALL_ROOM: + addMessages(msg); + break; + } + break; case CUSTOM_MSG_RADISH: RoomBoxPrizeAttachment boxPrizeAttachment = ((RoomBoxPrizeAttachment) msg.getAttachment()); UserInfo userInfo = UserModel.get().getCacheLoginUserInfo(); 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 42780e771..e4161c257 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 @@ -23,6 +23,7 @@ import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUS import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GROUP_CHAT_ROOM_NOTIFY; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GROUP_CHAT_TOPIC; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GROUP_ROOM_JOIN_NOTICE; +import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GUARDIAN_PLANET; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_HEADER_COMMON_SYSTEM_MSG; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_HEADER_TYPE_KICK_MIC; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_HEADER_TYPE_LUCKY_MONEY; @@ -613,6 +614,9 @@ public class CustomAttachParser implements MsgAttachmentParser { case CUSTOM_MSG_RADISH: attachment = new RoomBoxPrizeAttachment(CUSTOM_MSG_RADISH, second); break; + case CUSTOM_MSG_GUARDIAN_PLANET: + attachment = new GuardianPlanetAttachment(CUSTOM_MSG_GUARDIAN_PLANET, second); + break; case CUSTOM_MSG_DRAW_GIFT_EFFECT: if (second == CUSTOM_MSG_SUB_TYPE_DRAW_GIFT_EFFECT) { attachment = new DrawGiftAttachment(first, second); 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 60fce8273..319de4b0d 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 @@ -140,6 +140,11 @@ public class CustomAttachment implements MsgAttachment { public static final int CUSTOM_MSG_SUB_BOX_ALL_ROOM = 983;//所有房间可见 public static final int CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY = 984;//所有房间可见+小秘书 public static final int CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA = 985;//所有房间可见+小秘书+高大上的SVGA + + //守护星球 + public static final int CUSTOM_MSG_GUARDIAN_PLANET = 102; + public static final int CUSTOM_MSG_SUB_GUARDIAN_PLANET_ROOM = 1021;//单房间 + public static final int CUSTOM_MSG_SUB_GUARDIAN_PLANET_ALL_ROOM = 1022;//全部房间 //KTV public static final int CUSTOM_MSG_KTV = 27; public static final int CUSTOM_MSG_SUB_KTV_ADD = 271; diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/GuardianPlanetAttachment.java b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/GuardianPlanetAttachment.java new file mode 100644 index 000000000..6848a3cee --- /dev/null +++ b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/GuardianPlanetAttachment.java @@ -0,0 +1,54 @@ +package com.yizhuan.xchat_android_core.im.custom.bean; + +import com.alibaba.fastjson.JSONObject; + +/** + * Created by Max on 2024/02/21. + */ + +public class GuardianPlanetAttachment extends CustomAttachment { + private long uid; + private String nick; + private long diamonds; + + public GuardianPlanetAttachment(int first, int second) { + super(first, second); + } + + public long getUid() { + return uid; + } + + public void setUid(long uid) { + this.uid = uid; + } + + public String getNick() { + return nick; + } + + public void setNick(String nick) { + this.nick = nick; + } + + public long getDiamonds() { + return diamonds; + } + + public void setDiamonds(long diamonds) { + this.diamonds = diamonds; + } + + @Override + protected void parseData(JSONObject jsonObject) { + if (jsonObject.containsKey("uid")) { + uid = jsonObject.getLongValue("uid"); + } + if (jsonObject.containsKey("nick")) { + nick = jsonObject.getString("nick"); + } + if (jsonObject.containsKey("diamonds")) { + diamonds = jsonObject.getLongValue("diamonds"); + } + } +}