feat:完成解锁礼物与装扮礼物公屏展示逻辑
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.nnbc123.app.avroom.widget;
|
||||
|
||||
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GIFT;
|
||||
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GIFT_COMPOUND;
|
||||
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_KITCHEN;
|
||||
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_PRIVILEGE;
|
||||
@@ -93,6 +94,7 @@ import com.nnbc123.core.im.custom.bean.CarveUpGoldAttachment;
|
||||
import com.nnbc123.core.im.custom.bean.CleanScreenAttachment;
|
||||
import com.nnbc123.core.im.custom.bean.CustomAttachment;
|
||||
import com.nnbc123.core.im.custom.bean.DatingAttachment;
|
||||
import com.nnbc123.core.im.custom.bean.DressUpGiftAttachment;
|
||||
import com.nnbc123.core.im.custom.bean.FaceAttachment;
|
||||
import com.nnbc123.core.im.custom.bean.FansTeamMsgAttachment;
|
||||
import com.nnbc123.core.im.custom.bean.GiftAttachment;
|
||||
@@ -121,6 +123,7 @@ import com.nnbc123.core.im.custom.bean.RoomReceivedLuckyGiftAttachment;
|
||||
import com.nnbc123.core.im.custom.bean.RoomTipAttachment;
|
||||
import com.nnbc123.core.im.custom.bean.TarotAttachment;
|
||||
import com.nnbc123.core.im.custom.bean.TarotMsgBean;
|
||||
import com.nnbc123.core.im.custom.bean.UnLockGiftAttachment;
|
||||
import com.nnbc123.core.im.custom.bean.VipMessageAttachment;
|
||||
import com.nnbc123.core.im.custom.bean.WelcomeAttachment;
|
||||
import com.nnbc123.core.im.custom.bean.WishListAttachment;
|
||||
@@ -215,6 +218,7 @@ public class MessageView extends FrameLayout {
|
||||
private int whiteColor;
|
||||
private int greyColor;
|
||||
private int appColor;
|
||||
private int giftColor;
|
||||
private int badgeWidth;
|
||||
private int badgeHeight;
|
||||
private int sysIconHeight;
|
||||
@@ -277,6 +281,7 @@ public class MessageView extends FrameLayout {
|
||||
whiteColor = ContextCompat.getColor(context, R.color.white);
|
||||
greyColor = ContextCompat.getColor(context, R.color.white_transparent_50);
|
||||
appColor = ContextCompat.getColor(context, R.color.app_color);
|
||||
giftColor = ContextCompat.getColor(context, R.color.color_5CEFFF);
|
||||
paddingWidth = Utils.dip2px(context, 10);
|
||||
paddingHeight = Utils.dip2px(context, 8);
|
||||
badgeWidth = Utils.dip2px(context, 15);
|
||||
@@ -1011,6 +1016,12 @@ public class MessageView extends FrameLayout {
|
||||
if (second == CustomAttachment.CUSTOM_MSG_PRIVILEGE_SECOND || second == CustomAttachment.CUSTOM_MSG_PRIVILEGE_SECOND_VIDEO) {
|
||||
setPrivilegeNoticeMessage(chatRoomMessage, tvContent);
|
||||
}
|
||||
} else if (first == CUSTOM_MSG_GIFT) {
|
||||
if (second == CustomAttachment.CUSTOM_MSG_GIFT_UNLOCK) {
|
||||
setUnLockGiftMsg(tvContent, (UnLockGiftAttachment) attachment, chatRoomMessage);
|
||||
} else if (second == CustomAttachment.CUSTOM_MSG_GIFT_DRESS) {
|
||||
setDressGiftMsg(tvContent, (DressUpGiftAttachment) attachment, chatRoomMessage);
|
||||
}
|
||||
} else {
|
||||
tvContent.setTextColor(Color.WHITE);
|
||||
tvContent.setText(tvContent.getResources().getText(R.string.not_support_message_tip));
|
||||
@@ -2928,6 +2939,53 @@ public class MessageView extends FrameLayout {
|
||||
|
||||
}
|
||||
|
||||
private void setUnLockGiftMsg(TextView tvContent, UnLockGiftAttachment attachment, ChatRoomMessage chatRoomMessage) {
|
||||
if (attachment == null) return;
|
||||
String nick = RegexUtil.getPrintableString(attachment.getNick());
|
||||
String giftName = attachment.getGiftNameNotNull();
|
||||
String giftImage = attachment.getGiftUrlNotNull();
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
.append(getNewUserDrawable(chatRoomMessage), badgeWidth, badgeHeight)
|
||||
.append(nick, new ForegroundColorSpan(appColor), new OriginalDrawStatusClickSpan() {
|
||||
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
if (clickConsumer != null) {
|
||||
Single.just(chatRoomMessage.getFromAccount()).subscribe(clickConsumer);
|
||||
}
|
||||
}
|
||||
})
|
||||
.append(" 已解锁礼物 ", new ForegroundColorSpan(whiteColor))
|
||||
.append(giftImage, giftLength, giftLength)
|
||||
.append(giftName, new ForegroundColorSpan(giftColor));
|
||||
tvContent.setText(text.build());
|
||||
tvContent.setOnClickListener(null);
|
||||
tvContent.setMovementMethod(new LinkMovementMethod());
|
||||
}
|
||||
|
||||
private void setDressGiftMsg(TextView tvContent, DressUpGiftAttachment attachment, ChatRoomMessage chatRoomMessage) {
|
||||
if (attachment == null) return;
|
||||
String nick = RegexUtil.getPrintableString(attachment.getNick());
|
||||
String dressName = attachment.getDressNameNotNull();
|
||||
String dressImage = attachment.getDressUrlNotNull();
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
.append(getNewUserDrawable(chatRoomMessage), badgeWidth, badgeHeight)
|
||||
.append(nick, new ForegroundColorSpan(appColor), new OriginalDrawStatusClickSpan() {
|
||||
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
if (clickConsumer != null) {
|
||||
Single.just(chatRoomMessage.getFromAccount()).subscribe(clickConsumer);
|
||||
}
|
||||
}
|
||||
})
|
||||
.append(" 获得 "+dressName+"装扮 ", new ForegroundColorSpan(whiteColor))
|
||||
.append(dressImage, giftLength, giftLength);
|
||||
tvContent.setText(text.build());
|
||||
tvContent.setOnClickListener(null);
|
||||
tvContent.setMovementMethod(new LinkMovementMethod());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Drawable getNewUserDrawable(ChatRoomMessage chatRoomMessage) {
|
||||
boolean newUser = NobleUtil.getIsNewUser(UserInfo.IS_NEW_USER, chatRoomMessage);
|
||||
|
@@ -629,5 +629,5 @@
|
||||
<color name="color_FFD46C">#FFD46C</color>
|
||||
<color name="color_695CEB">#695CEB</color>
|
||||
<color name="color_FFF265">#FFFFF265</color>
|
||||
|
||||
<color name="color_5CEFFF">#FF5CEFFF</color>
|
||||
</resources>
|
||||
|
@@ -1443,6 +1443,14 @@ public final class IMNetEaseManager {
|
||||
.setEvent(RoomEvent.ROOM_HOUR_RANK));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CUSTOM_MSG_GIFT:
|
||||
if (customAttachment.getSecond() == CUSTOM_MSG_GIFT_UNLOCK) {
|
||||
addMessages(msg);
|
||||
} else if (customAttachment.getSecond() == CUSTOM_MSG_GIFT_DRESS) {
|
||||
addMessages(msg);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@@ -19,6 +19,7 @@ import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_EXPER_
|
||||
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_EXPER_LEVEL_UP_NOTICE;
|
||||
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GAME_INVITE;
|
||||
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GAME_INVITE_SECOND;
|
||||
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GIFT;
|
||||
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GROUP_CHAT_MEMBER_COUNT;
|
||||
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GROUP_CHAT_ROOM_NOTIFY;
|
||||
import static com.nnbc123.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GROUP_CHAT_TOPIC;
|
||||
@@ -622,6 +623,13 @@ public class CustomAttachParser implements MsgAttachmentParser {
|
||||
attachment = new GameInviteAttachment(first, second);
|
||||
}
|
||||
break;
|
||||
case CUSTOM_MSG_GIFT:
|
||||
if (second == CustomAttachment.CUSTOM_MSG_GIFT_UNLOCK) {
|
||||
attachment = new UnLockGiftAttachment(first, second);
|
||||
} else if (second == CustomAttachment.CUSTOM_MSG_GIFT_DRESS) {
|
||||
attachment = new DressUpGiftAttachment(first, second);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
LogUtils.e("未定义的first,请现在CustomAttachParser中解析first=" + first + " second=" + second);
|
||||
break;
|
||||
|
@@ -437,6 +437,10 @@ public class CustomAttachment implements MsgAttachment {
|
||||
public static final int CUSTOM_MSG_HOUR_RANK = 97; // 小时榜
|
||||
public static final int CUSTOM_MSG_HOUR_RANK_UPDATE = 971; // 小时榜更新
|
||||
|
||||
public static final int CUSTOM_MSG_GIFT = 98; // 礼物相关
|
||||
public static final int CUSTOM_MSG_GIFT_UNLOCK = 981; // 解锁了礼物
|
||||
public static final int CUSTOM_MSG_GIFT_DRESS = 982; // 获得装扮礼物
|
||||
|
||||
public static final int CUSTOM_MSG_PRIVILEGE = 102; //特权卡
|
||||
public static final int CUSTOM_MSG_PRIVILEGE_SECOND = 1020;//特权卡(图片、gif)
|
||||
public static final int CUSTOM_MSG_PRIVILEGE_SECOND_VIDEO = 1021;//特权卡(视频类型)
|
||||
|
@@ -0,0 +1,49 @@
|
||||
package com.nnbc123.core.im.custom.bean
|
||||
|
||||
import com.alibaba.fastjson.JSONObject
|
||||
|
||||
/**
|
||||
* Created by Max on 2024/1/29 15:54
|
||||
* Desc:
|
||||
**/
|
||||
class DressUpGiftAttachment : CustomAttachment {
|
||||
|
||||
var uid: Long? = null
|
||||
var nick: String? = null
|
||||
var dressId: Long? = null
|
||||
var dressName: String? = null
|
||||
var dressUrl: String? = null
|
||||
|
||||
constructor() : super()
|
||||
constructor(first: Int, second: Int) : super(first, second)
|
||||
|
||||
fun getDressNameNotNull(): String {
|
||||
return dressName ?: ""
|
||||
}
|
||||
|
||||
fun getDressUrlNotNull(): String {
|
||||
return dressName ?: ""
|
||||
}
|
||||
|
||||
override fun parseData(data: JSONObject?) {
|
||||
super.parseData(data)
|
||||
if (data == null) {
|
||||
return
|
||||
}
|
||||
if (data.containsKey("uid")) {
|
||||
this.uid = data.getLong("uid")
|
||||
}
|
||||
if (data.containsKey("nick")) {
|
||||
this.nick = data.getString("nick")
|
||||
}
|
||||
if (data.containsKey("dressId")) {
|
||||
this.dressId = data.getLong("dressId")
|
||||
}
|
||||
if (data.containsKey("dressName")) {
|
||||
this.dressName = data.getString("dressName")
|
||||
}
|
||||
if (data.containsKey("dressUrl")) {
|
||||
this.dressUrl = data.getString("dressUrl")
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
package com.nnbc123.core.im.custom.bean
|
||||
|
||||
import com.alibaba.fastjson.JSONObject
|
||||
|
||||
/**
|
||||
* Created by Max on 2024/1/29 15:54
|
||||
* Desc:
|
||||
**/
|
||||
class UnLockGiftAttachment : CustomAttachment{
|
||||
|
||||
var uid: Long? = null
|
||||
var nick: String? = null
|
||||
var giftId: Long? = null
|
||||
var giftName: String? = null
|
||||
var giftUrl: String? = null
|
||||
|
||||
constructor() : super()
|
||||
constructor(first: Int, second: Int) : super(first, second)
|
||||
|
||||
|
||||
fun getGiftNameNotNull(): String {
|
||||
return giftName ?: ""
|
||||
}
|
||||
|
||||
fun getGiftUrlNotNull(): String {
|
||||
return giftUrl ?: ""
|
||||
}
|
||||
|
||||
override fun parseData(data: JSONObject?) {
|
||||
super.parseData(data)
|
||||
if (data == null) {
|
||||
return
|
||||
}
|
||||
if (data.containsKey("uid")) {
|
||||
this.uid = data.getLong("uid")
|
||||
}
|
||||
if (data.containsKey("nick")) {
|
||||
this.nick = data.getString("nick")
|
||||
}
|
||||
if (data.containsKey("giftId")) {
|
||||
this.giftId = data.getLong("giftId")
|
||||
}
|
||||
if (data.containsKey("giftName")) {
|
||||
this.giftName = data.getString("giftName")
|
||||
}
|
||||
if (data.containsKey("giftUrl")) {
|
||||
this.giftUrl = data.getString("giftUrl")
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user