diff --git a/app/src/main/java/com/yizhuan/erban/avroom/widget/RoomEffectView.java b/app/src/main/java/com/yizhuan/erban/avroom/widget/RoomEffectView.java index 3ad0ae327..907e93989 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/widget/RoomEffectView.java +++ b/app/src/main/java/com/yizhuan/erban/avroom/widget/RoomEffectView.java @@ -53,6 +53,8 @@ import com.yizhuan.xchat_android_core.im.custom.bean.RoomBoxPrizeAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.RoomPKAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.RoomPkBean; import com.yizhuan.xchat_android_core.im.custom.bean.RoomReceivedLuckyGiftAttachment; +import com.yizhuan.xchat_android_core.im.custom.bean.SingleRoomRankAttachment; +import com.yizhuan.xchat_android_core.im.custom.bean.SingleRoomRankMsgBean; import com.yizhuan.xchat_android_core.manager.AvRoomDataManager; import com.yizhuan.xchat_android_core.manager.IMNetEaseManager; import com.yizhuan.xchat_android_core.manager.RoomEvent; @@ -183,6 +185,9 @@ public class RoomEffectView extends FrameLayout { case RoomEvent.SINGLE_ROOM_PK_NOTIFY: addSingleRoomPKNotify(roomEvent.getChatRoomMessage()); break; + case RoomEvent.SINGLE_ROOM_RANK_TOP_NOTIFY: + showSingleRoomRankNotify(roomEvent.getChatRoomMessage()); + break; default: break; } @@ -869,6 +874,21 @@ public class RoomEffectView extends FrameLayout { binding.flSingleRoomPkNotify.postDelayed(() -> binding.flSingleRoomPkNotify.removeView(rootView), SHOW_TIME); } + private void showSingleRoomRankNotify(ChatRoomMessage chatRoomMessage) { + if (binding.clNotify.getVisibility() == View.GONE) { + binding.clNotify.setVisibility(View.VISIBLE); + } + SingleRoomRankMsgBean roomPkBean = ((SingleRoomRankAttachment) chatRoomMessage.getAttachment()).getMsgBean(); + View rootView = LayoutInflater.from(mContext).inflate(R.layout.layout_single_room_rank_notify, null); + ((TextView) rootView.findViewById(R.id.tv_nick)).setText(StringExtensionKt.subAndReplaceDot(roomPkBean.getNick(), 6)); + ((TextView) rootView.findViewById(R.id.tv_desc)).setText(roomPkBean.getDesc()); + ImageLoadUtils.loadImage(getContext(), roomPkBean.getAvatar(), rootView.findViewById(R.id.iv_avatar)); + rootView.findViewById(R.id.tv_go_room).setOnClickListener(v -> AVRoomActivity.start(getContext(), roomPkBean.getUid())); + binding.flSingleRoomRankNotify.addView(rootView); + animationLuckyGift = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify); + rootView.startAnimation(animationLuckyGift); + binding.flSingleRoomRankNotify.postDelayed(() -> binding.flSingleRoomRankNotify.removeView(rootView), SHOW_TIME); + } @Override protected void onDetachedFromWindow() { diff --git a/app/src/main/res/drawable-xhdpi/single_room_bg_rank_notice.png b/app/src/main/res/drawable-xhdpi/single_room_bg_rank_notice.png new file mode 100644 index 000000000..82585cf11 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/single_room_bg_rank_notice.png differ diff --git a/app/src/main/res/drawable-xhdpi/single_room_bg_rank_notice_btn.png b/app/src/main/res/drawable-xhdpi/single_room_bg_rank_notice_btn.png new file mode 100644 index 000000000..418ab24fc Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/single_room_bg_rank_notice_btn.png differ diff --git a/app/src/main/res/layout/layout_room_effect.xml b/app/src/main/res/layout/layout_room_effect.xml index 3d82a73ea..8ca320e0f 100644 --- a/app/src/main/res/layout/layout_room_effect.xml +++ b/app/src/main/res/layout/layout_room_effect.xml @@ -87,6 +87,12 @@ app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintDimensionRatio="375:71" /> + + + + + + + + + + + + + + + + \ 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 a38199d70..4a8e2de32 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 @@ -1293,6 +1293,11 @@ public final class IMNetEaseManager { break; } break; + case CUSTOM_MSG_SINGLE_ROOM_RANK: + if (second == CUSTOM_MSG_SUB_SINGLE_ROOM_RANK_TOP) { + noticeRoomEvent(msg, RoomEvent.SINGLE_ROOM_RANK_TOP_NOTIFY); + } + break; default: break; } 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 afb446c62..7074959ad 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 @@ -563,6 +563,9 @@ public class CustomAttachParser implements MsgAttachmentParser { case CustomAttachment.CUSTOM_MSG_FANS_TEAM: attachment = new FansTeamMsgAttachment(second); break; + case CustomAttachment.CUSTOM_MSG_SINGLE_ROOM_RANK: + attachment = new SingleRoomRankAttachment(second); + break; default: LogUtils.e("未定义的first,请现在CustomAttachParser中解析"); 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 a98936876..47079031d 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 @@ -441,6 +441,9 @@ public class CustomAttachment implements MsgAttachment { public static final int CP_INVITE_MESSAGE = 88; public static final int CP_INVITE_MESSAGE_TOP_NOTICE = 881; + public static final int CUSTOM_MSG_SINGLE_ROOM_RANK = 89; + public static final int CUSTOM_MSG_SUB_SINGLE_ROOM_RANK_TOP = 891; + public static final int CUSTOM_MSG_FANS_TEAM = 90; public static final int CUSTOM_MSG_SUB_FANS_TEAM_OPEN = 901; //开通粉丝团 public static final int CUSTOM_MSG_SUB_FANS_TEAM_OPEN_FAILED = 902; // 开通粉丝团失败 diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/SingleRoomRankAttachment.java b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/SingleRoomRankAttachment.java new file mode 100644 index 000000000..67e073b76 --- /dev/null +++ b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/SingleRoomRankAttachment.java @@ -0,0 +1,31 @@ +package com.yizhuan.xchat_android_core.im.custom.bean; + +import com.alibaba.fastjson.JSONObject; +import com.google.gson.Gson; + +public class SingleRoomRankAttachment extends CustomAttachment { + + private SingleRoomRankMsgBean msgBean; + + public SingleRoomRankAttachment(int second) { + super(CUSTOM_MSG_SINGLE_ROOM_RANK, second); + } + + public SingleRoomRankMsgBean getMsgBean() { + return msgBean; + } + + public void setMsgBean(SingleRoomRankMsgBean msgBean) { + this.msgBean = msgBean; + } + + @Override + protected void parseData(JSONObject data) { + msgBean = new Gson().fromJson(data.toJSONString(), SingleRoomRankMsgBean.class); + } + + @Override + protected JSONObject packData() { + return null; + } +} diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/SingleRoomRankMsgBean.java b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/SingleRoomRankMsgBean.java new file mode 100644 index 000000000..b2f54dbbe --- /dev/null +++ b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/SingleRoomRankMsgBean.java @@ -0,0 +1,11 @@ +package com.yizhuan.xchat_android_core.im.custom.bean; + +import lombok.Data; + +@Data +public class SingleRoomRankMsgBean { + private long uid; + private String nick; + private String avatar; + private String desc; +} diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/manager/RoomEvent.java b/core/src/main/java/com/yizhuan/xchat_android_core/manager/RoomEvent.java index c90a0dbf7..d9fca90f8 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/manager/RoomEvent.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/manager/RoomEvent.java @@ -227,6 +227,7 @@ public class RoomEvent { public static final int FANS_TEAM_EXIT = 87; public static final int SINGLE_ROOM_PK_NOTIFY = 88; + public static final int SINGLE_ROOM_RANK_TOP_NOTIFY = 89; private int event = NONE; private int micPosition = Integer.MIN_VALUE;