feat:新增守护星球公屏

This commit is contained in:
Max
2024-02-21 14:06:37 +08:00
parent 592dbc78f3
commit cee6060d62
6 changed files with 108 additions and 0 deletions

View File

@@ -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();

View File

@@ -4983,6 +4983,8 @@
<string name="room">房間</string>
<string name="congratulation">恭喜</string>
<string name="in_the_star_kitchen_draw">在星級厨房抽中</string>
<string name="guardian_planet_msg_1">在守護星球中成功擊敗怪獸,獲得</string>
<string name="guardian_planet_msg_2">鉆石獎勵!</string>
<string name="times_reward_get">倍獎勵,獲得</string>
<string name="diamond_point">鉆石!</string>
<string name="free_gift">免費禮物</string>

View File

@@ -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();

View File

@@ -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);

View File

@@ -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;

View File

@@ -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");
}
}
}