增加星级厨房飘屏

This commit is contained in:
huangjian
2023-02-13 19:12:33 +08:00
parent c55c762a3b
commit 99f1f65a55
13 changed files with 661 additions and 331 deletions

Binary file not shown.

View File

@@ -1,6 +1,7 @@
package com.mango.moshen.avroom.widget; package com.mango.moshen.avroom.widget;
import static com.mango.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GIFT_COMPOUND; import static com.mango.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_GIFT_COMPOUND;
import static com.mango.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_KITCHEN;
import static com.mango.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_RED_PACKAGE; import static com.mango.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_RED_PACKAGE;
import static com.mango.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ME; import static com.mango.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_BOX_ME;
import static com.mango.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_FANS_TEAM_JOIN; import static com.mango.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_FANS_TEAM_JOIN;
@@ -41,8 +42,10 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.SimpleItemAnimator; import androidx.recyclerview.widget.SimpleItemAnimator;
import com.mango.core.im.custom.bean.RoomKitchenAttachment;
import com.mango.core.im.custom.bean.WishListAttachment; import com.mango.core.im.custom.bean.WishListAttachment;
import com.mango.core.room.wishlist.WishListModel; import com.mango.core.room.wishlist.WishListModel;
import com.mango.moshen.utils.MsgBuilder;
import com.netease.nim.uikit.business.uinfo.UserInfoHelper; import com.netease.nim.uikit.business.uinfo.UserInfoHelper;
import com.netease.nim.uikit.common.ui.span.RadiusBackgroundSpan; import com.netease.nim.uikit.common.ui.span.RadiusBackgroundSpan;
import com.netease.nim.uikit.common.util.log.LogUtil; import com.netease.nim.uikit.common.util.log.LogUtil;
@@ -979,6 +982,8 @@ public class MessageView extends FrameLayout {
if (second == CustomAttachment.CUSTOM_MSG_WISH_LIST_FINISH) { if (second == CustomAttachment.CUSTOM_MSG_WISH_LIST_FINISH) {
setWishListComplete(chatRoomMessage, tvContent); setWishListComplete(chatRoomMessage, tvContent);
} }
} else if (first == CUSTOM_MSG_KITCHEN) {
setKitchenMsg(chatRoomMessage, tvContent);
} else { } else {
tvContent.setTextColor(Color.WHITE); tvContent.setTextColor(Color.WHITE);
tvContent.setText(tvContent.getResources().getText(R.string.not_support_message_tip)); tvContent.setText(tvContent.getResources().getText(R.string.not_support_message_tip));
@@ -992,6 +997,17 @@ public class MessageView extends FrameLayout {
} }
} }
private void setKitchenMsg(ChatRoomMessage chatRoomMessage, TextView tvContent) {
if (chatRoomMessage.getAttachment() instanceof RoomKitchenAttachment) {
RoomKitchenAttachment attachment = (RoomKitchenAttachment) chatRoomMessage.getAttachment();
tvContent.setText(MsgBuilder.buildKitchenMsg(attachment, roomTipNickColor).build());
if (MsgBuilder.setUpKitchenClick(tvContent, attachment.getSkipUrl(), attachment.getNeedLevel())) {
tvContent.setOnClickListener(null);
}
}
}
@SuppressLint("CheckResult") @SuppressLint("CheckResult")
private void setGiftCompoundMsg(ChatRoomMessage chatRoomMessage, TextView tvContent) { private void setGiftCompoundMsg(ChatRoomMessage chatRoomMessage, TextView tvContent) {
if (chatRoomMessage.getAttachment() instanceof GiftCompoundAttachment) { if (chatRoomMessage.getAttachment() instanceof GiftCompoundAttachment) {
@@ -1000,17 +1016,17 @@ public class MessageView extends FrameLayout {
GiftCompoundMsgBean msgInfo = giftCompoundAttachment.getMsgBean(); GiftCompoundMsgBean msgInfo = giftCompoundAttachment.getMsgBean();
SpannableBuilder text = new SpannableBuilder(tvContent); SpannableBuilder text = new SpannableBuilder(tvContent);
text.append( text.append(
msgInfo.getNick(), msgInfo.getNick(),
new ForegroundColorSpan(roomTipNickColor), new ForegroundColorSpan(roomTipNickColor),
new OriginalDrawStatusClickSpan() { new OriginalDrawStatusClickSpan() {
@Override @Override
public void onClick(@NonNull View widget) { public void onClick(@NonNull View widget) {
if (clickConsumer != null) { if (clickConsumer != null) {
Single.just(String.valueOf(msgInfo.getUid())).subscribe(clickConsumer); Single.just(String.valueOf(msgInfo.getUid())).subscribe(clickConsumer);
}
}
} }
) }
}
)
.append(msgInfo.getMsg(), new ForegroundColorSpan(whiteColor)) .append(msgInfo.getMsg(), new ForegroundColorSpan(whiteColor))
.append(msgInfo.getGiftName(), new ForegroundColorSpan(roomTipNickColor)); .append(msgInfo.getGiftName(), new ForegroundColorSpan(roomTipNickColor));
tvContent.setText(text.build()); tvContent.setText(text.build());
@@ -1143,15 +1159,15 @@ public class MessageView extends FrameLayout {
case CustomAttachment.CUSTOM_MSG_SUB_DATING_PUBLISH_LIKE: case CustomAttachment.CUSTOM_MSG_SUB_DATING_PUBLISH_LIKE:
if (notifyInfo.getHasSelectUser()) { if (notifyInfo.getHasSelectUser()) {
text.append(notifyInfo.getNickname(), new ForegroundColorSpan(roomTipNickColor), text.append(notifyInfo.getNickname(), new ForegroundColorSpan(roomTipNickColor),
new OriginalDrawStatusClickSpan() { new OriginalDrawStatusClickSpan() {
@Override @Override
public void onClick(@NonNull View widget) { public void onClick(@NonNull View widget) {
if (clickConsumer != null) { if (clickConsumer != null) {
Single.just(String.valueOf(notifyInfo.getUid())).subscribe(clickConsumer); Single.just(String.valueOf(notifyInfo.getUid())).subscribe(clickConsumer);
} }
} }
}) })
.append(" 的心动对象是 ", new ForegroundColorSpan(whiteColor)) .append(" 的心动对象是 ", new ForegroundColorSpan(whiteColor))
.append(notifyInfo.getTargetNickname(), new ForegroundColorSpan(roomTipNickColor), .append(notifyInfo.getTargetNickname(), new ForegroundColorSpan(roomTipNickColor),
new OriginalDrawStatusClickSpan() { new OriginalDrawStatusClickSpan() {
@@ -1165,15 +1181,15 @@ public class MessageView extends FrameLayout {
}); });
} else { } else {
text.append(notifyInfo.getNickname(), new ForegroundColorSpan(roomTipNickColor), text.append(notifyInfo.getNickname(), new ForegroundColorSpan(roomTipNickColor),
new OriginalDrawStatusClickSpan() { new OriginalDrawStatusClickSpan() {
@Override @Override
public void onClick(@NonNull View widget) { public void onClick(@NonNull View widget) {
if (clickConsumer != null) { if (clickConsumer != null) {
Single.just(String.valueOf(notifyInfo.getUid())).subscribe(clickConsumer); Single.just(String.valueOf(notifyInfo.getUid())).subscribe(clickConsumer);
} }
} }
}) })
.append(" 未选择心动对象", new ForegroundColorSpan(whiteColor)); .append(" 未选择心动对象", new ForegroundColorSpan(whiteColor));
} }
break; break;
@@ -1431,15 +1447,15 @@ public class MessageView extends FrameLayout {
isHaveInTeam = true; isHaveInTeam = true;
text.append(value.getNick(), new ForegroundColorSpan(roomTipColor), text.append(value.getNick(), new ForegroundColorSpan(roomTipColor),
new OriginalDrawStatusClickSpan() { new OriginalDrawStatusClickSpan() {
@Override @Override
public void onClick(@NonNull View widget) { public void onClick(@NonNull View widget) {
if (clickConsumer != null) { if (clickConsumer != null) {
Single.just(value.getUid()).subscribe(clickConsumer); Single.just(value.getUid()).subscribe(clickConsumer);
} }
} }
}) })
.append("进入"); .append("进入");
if (value.getGroupType() == PKTeamInfo.TEAM_RED) { if (value.getGroupType() == PKTeamInfo.TEAM_RED) {
text.append("红队", new ForegroundColorSpan(tvContent.getResources().getColor(R.color.color_FB3D74))) text.append("红队", new ForegroundColorSpan(tvContent.getResources().getColor(R.color.color_FB3D74)))
@@ -1464,7 +1480,7 @@ public class MessageView extends FrameLayout {
RoomPkData roomPkData = attachment.getRoomPkData(); RoomPkData roomPkData = attachment.getRoomPkData();
SpannableBuilder text = new SpannableBuilder(tvContent) SpannableBuilder text = new SpannableBuilder(tvContent)
.append(String.format(Locale.getDefault(), "管理员发起房间PK本次PK时间为 %s 秒,获得", .append(String.format(Locale.getDefault(), "管理员发起房间PK本次PK时间为 %s 秒,获得",
roomPkData.getDuration()), roomPkData.getDuration()),
new ForegroundColorSpan(whiteColor)); new ForegroundColorSpan(whiteColor));
switch (roomPkData.getVoteMode()) { switch (roomPkData.getVoteMode()) {
case RoomPkData.VOTE_MODE_GIFT: case RoomPkData.VOTE_MODE_GIFT:
@@ -1491,7 +1507,7 @@ public class MessageView extends FrameLayout {
RoomPkData roomPkData = attachment.getRoomPkData(); RoomPkData roomPkData = attachment.getRoomPkData();
SpannableBuilder text = new SpannableBuilder(textView) SpannableBuilder text = new SpannableBuilder(textView)
.append(String.format(Locale.getDefault(), .append(String.format(Locale.getDefault(),
"PK开始啦本次PK时间 %s 秒,快给喜欢的选手投票吧!", roomPkData.getDuration()), "PK开始啦本次PK时间 %s 秒,快给喜欢的选手投票吧!", roomPkData.getDuration()),
new ForegroundColorSpan(greyColor)); new ForegroundColorSpan(greyColor));
textView.setText(text.build()); textView.setText(text.build());
} }
@@ -1500,7 +1516,7 @@ public class MessageView extends FrameLayout {
RoomPkData roomPkData = attachment.getRoomPkData(); RoomPkData roomPkData = attachment.getRoomPkData();
SpannableBuilder text = new SpannableBuilder(tvContent) SpannableBuilder text = new SpannableBuilder(tvContent)
.append(String.format(Locale.getDefault(), "管理员重新开始房间PK本次PK时间为 %s 秒,获得", .append(String.format(Locale.getDefault(), "管理员重新开始房间PK本次PK时间为 %s 秒,获得",
roomPkData.getDuration()), roomPkData.getDuration()),
new ForegroundColorSpan(whiteColor)); new ForegroundColorSpan(whiteColor));
switch (roomPkData.getVoteMode()) { switch (roomPkData.getVoteMode()) {
case RoomPkData.VOTE_MODE_GIFT: case RoomPkData.VOTE_MODE_GIFT:
@@ -1534,8 +1550,8 @@ public class MessageView extends FrameLayout {
text.append("平局!\n", new ForegroundColorSpan(whiteColor)); text.append("平局!\n", new ForegroundColorSpan(whiteColor));
if (blueTeam != null && redTeam != null) { if (blueTeam != null && redTeam != null) {
text.append(String.format(Locale.getDefault(), "PK值 %s : %s", text.append(String.format(Locale.getDefault(), "PK值 %s : %s",
FormatUtils.formatPKValue(blueTeam.getScore()), FormatUtils.formatPKValue(blueTeam.getScore()),
FormatUtils.formatPKValue(redTeam.getScore())), FormatUtils.formatPKValue(redTeam.getScore())),
new ForegroundColorSpan(whiteColor)); new ForegroundColorSpan(whiteColor));
UserInfo redProtector = redTeam.getProtector(); UserInfo redProtector = redTeam.getProtector();
@@ -1545,14 +1561,14 @@ public class MessageView extends FrameLayout {
break; break;
} }
text.append(String.format(Locale.getDefault(), "\n蓝队守护者%s \n", blueProtector.getNick()), text.append(String.format(Locale.getDefault(), "\n蓝队守护者%s \n", blueProtector.getNick()),
new ForegroundColorSpan(whiteColor)) new ForegroundColorSpan(whiteColor))
.append(String.format(Locale.getDefault(), "蓝队守护值:%s \n", .append(String.format(Locale.getDefault(), "蓝队守护值:%s \n",
FormatUtils.formatPKValue(blueTeam.getProtecScore())), FormatUtils.formatPKValue(blueTeam.getProtecScore())),
new ForegroundColorSpan(whiteColor)) new ForegroundColorSpan(whiteColor))
.append(String.format(Locale.getDefault(), "红队守护者:%s \n", redProtector.getNick()), .append(String.format(Locale.getDefault(), "红队守护者:%s \n", redProtector.getNick()),
new ForegroundColorSpan(whiteColor)) new ForegroundColorSpan(whiteColor))
.append(String.format(Locale.getDefault(), "红队守护值:%s", .append(String.format(Locale.getDefault(), "红队守护值:%s",
FormatUtils.formatPKValue(redTeam.getProtecScore())), FormatUtils.formatPKValue(redTeam.getProtecScore())),
new ForegroundColorSpan(whiteColor)); new ForegroundColorSpan(whiteColor));
} }
break; break;
@@ -1561,21 +1577,21 @@ public class MessageView extends FrameLayout {
text.append("蓝队胜利!\n", new ForegroundColorSpan(whiteColor)); text.append("蓝队胜利!\n", new ForegroundColorSpan(whiteColor));
if (blueTeam != null && redTeam != null) { if (blueTeam != null && redTeam != null) {
text.append(String.format(Locale.getDefault(), "PK值 %s : %s \n", text.append(String.format(Locale.getDefault(), "PK值 %s : %s \n",
FormatUtils.formatPKValue(blueTeam.getScore()), FormatUtils.formatPKValue(blueTeam.getScore()),
FormatUtils.formatPKValue(redTeam.getScore())), FormatUtils.formatPKValue(redTeam.getScore())),
new ForegroundColorSpan(whiteColor)); new ForegroundColorSpan(whiteColor));
UserInfo blueProtector = blueTeam.getProtector(); UserInfo blueProtector = blueTeam.getProtector();
if (blueProtector == null) { if (blueProtector == null) {
text.append(String.format(Locale.getDefault(), "胜利方战斗值:%s", text.append(String.format(Locale.getDefault(), "胜利方战斗值:%s",
FormatUtils.formatPKValue(blueTeam.getScore())), FormatUtils.formatPKValue(blueTeam.getScore())),
new ForegroundColorSpan(whiteColor)); new ForegroundColorSpan(whiteColor));
} else { } else {
text.append(String.format(Locale.getDefault(), "胜方守护者:%s \n", blueProtector.getNick()), text.append(String.format(Locale.getDefault(), "胜方守护者:%s \n", blueProtector.getNick()),
new ForegroundColorSpan(whiteColor)) new ForegroundColorSpan(whiteColor))
.append(String.format(Locale.getDefault(), "胜方守护值:%s", .append(String.format(Locale.getDefault(), "胜方守护值:%s",
FormatUtils.formatPKValue(blueTeam.getProtecScore())), FormatUtils.formatPKValue(blueTeam.getProtecScore())),
new ForegroundColorSpan(whiteColor)); new ForegroundColorSpan(whiteColor));
} }
} }
@@ -1585,20 +1601,20 @@ public class MessageView extends FrameLayout {
text.append("红队胜利!\n", new ForegroundColorSpan(whiteColor)); text.append("红队胜利!\n", new ForegroundColorSpan(whiteColor));
if (blueTeam != null && redTeam != null) { if (blueTeam != null && redTeam != null) {
text.append(String.format(Locale.getDefault(), "PK值 %s : %s \n", text.append(String.format(Locale.getDefault(), "PK值 %s : %s \n",
FormatUtils.formatPKValue(redTeam.getScore()), FormatUtils.formatPKValue(redTeam.getScore()),
FormatUtils.formatPKValue(blueTeam.getScore())), FormatUtils.formatPKValue(blueTeam.getScore())),
new ForegroundColorSpan(whiteColor)); new ForegroundColorSpan(whiteColor));
UserInfo redProtector = redTeam.getProtector(); UserInfo redProtector = redTeam.getProtector();
if (redProtector == null) { if (redProtector == null) {
text.append(String.format(Locale.getDefault(), "胜利方战斗值:%s", text.append(String.format(Locale.getDefault(), "胜利方战斗值:%s",
FormatUtils.formatPKValue(redTeam.getScore())), FormatUtils.formatPKValue(redTeam.getScore())),
new ForegroundColorSpan(whiteColor)); new ForegroundColorSpan(whiteColor));
} else { } else {
text.append(String.format(Locale.getDefault(), "红队守护者:%s \n", redProtector.getNick()), text.append(String.format(Locale.getDefault(), "红队守护者:%s \n", redProtector.getNick()),
new ForegroundColorSpan(whiteColor)) new ForegroundColorSpan(whiteColor))
.append(String.format(Locale.getDefault(), "红队守护值:%s", .append(String.format(Locale.getDefault(), "红队守护值:%s",
FormatUtils.formatPKValue(redTeam.getProtecScore())), FormatUtils.formatPKValue(redTeam.getProtecScore())),
new ForegroundColorSpan(whiteColor)); new ForegroundColorSpan(whiteColor));
} }
@@ -1975,11 +1991,11 @@ public class MessageView extends FrameLayout {
String vipIcon = NobleUtil.getResource(UserInfo.VIP_ICON, chatRoomMessage); String vipIcon = NobleUtil.getResource(UserInfo.VIP_ICON, chatRoomMessage);
builder.append(vipIcon, expLevelHeight) builder.append(vipIcon, expLevelHeight)
.append(isOfficial ? ResourcesCompat.getDrawable(getResources(), .append(isOfficial ? ResourcesCompat.getDrawable(getResources(),
R.mipmap.ic_user_official_13dp, null) : null, R.mipmap.ic_user_official_13dp, null) : null,
badgeWidth, badgeHeight) badgeWidth, badgeHeight)
.append(getNewUserDrawable(chatRoomMessage), badgeWidth, badgeHeight) .append(getNewUserDrawable(chatRoomMessage), badgeWidth, badgeHeight)
.append(AvRoomDataManager.get().isSuperAdmin(chatRoomMessage.getFromAccount()) ? ResourcesCompat.getDrawable(getResources(), .append(AvRoomDataManager.get().isSuperAdmin(chatRoomMessage.getFromAccount()) ? ResourcesCompat.getDrawable(getResources(),
R.drawable.ic_room_super_admin, null) : null, R.drawable.ic_room_super_admin, null) : null,
SizeUtils.dp2px(tvContent.getContext(), 23), expLevelHeight); SizeUtils.dp2px(tvContent.getContext(), 23), expLevelHeight);
// 官方主播认证 // 官方主播认证
@@ -2273,13 +2289,13 @@ public class MessageView extends FrameLayout {
for (GiftReceiver targetUser : attachment.getGiftMultiReceiverInfo().getTargetUsers()) { for (GiftReceiver targetUser : attachment.getGiftMultiReceiverInfo().getTargetUsers()) {
text.append(targetUser.getNick(), new ForegroundColorSpan(roomTipNickColor), new OriginalDrawStatusClickSpan() { text.append(targetUser.getNick(), new ForegroundColorSpan(roomTipNickColor), new OriginalDrawStatusClickSpan() {
@Override @Override
public void onClick(@NonNull View widget) { public void onClick(@NonNull View widget) {
if (clickConsumer != null) { if (clickConsumer != null) {
Single.just(targetUser.getUid() + "").subscribe(clickConsumer); Single.just(targetUser.getUid() + "").subscribe(clickConsumer);
} }
} }
}) })
.append(","); .append(",");
} }
Editable msg = text.builder; Editable msg = text.builder;
@@ -2353,13 +2369,13 @@ public class MessageView extends FrameLayout {
for (MagicReceiver targetUser : magicMultiReceiverInfo.getTargetUsers()) { for (MagicReceiver targetUser : magicMultiReceiverInfo.getTargetUsers()) {
text.append(targetUser.getNick(), new ForegroundColorSpan(roomTipNickColor), new OriginalDrawStatusClickSpan() { text.append(targetUser.getNick(), new ForegroundColorSpan(roomTipNickColor), new OriginalDrawStatusClickSpan() {
@Override @Override
public void onClick(@NonNull View widget) { public void onClick(@NonNull View widget) {
if (clickConsumer != null) { if (clickConsumer != null) {
Single.just(targetUser.getUid() + "").subscribe(clickConsumer); Single.just(targetUser.getUid() + "").subscribe(clickConsumer);
} }
} }
}) })
.append(","); .append(",");
} }
Editable msg = text.builder; Editable msg = text.builder;
@@ -2556,14 +2572,14 @@ public class MessageView extends FrameLayout {
mMessageAdapter.notifyItemChanged(position); mMessageAdapter.notifyItemChanged(position);
long targetUid = JavaUtil.str2long(chatRoomMessage.getFromAccount()); long targetUid = JavaUtil.str2long(chatRoomMessage.getFromAccount());
Single.zip(AvRoomModel.get().getWelcomeConfig(targetUid), Single.zip(AvRoomModel.get().getWelcomeConfig(targetUid),
UserModel.get().getUserInfo(targetUid), (roomWelcomeConfig, info) -> { UserModel.get().getUserInfo(targetUid), (roomWelcomeConfig, info) -> {
WelcomeInfo welcomeInfo = new WelcomeInfo(); WelcomeInfo welcomeInfo = new WelcomeInfo();
welcomeInfo.setContent(roomWelcomeConfig.getMsg()); welcomeInfo.setContent(roomWelcomeConfig.getMsg());
welcomeInfo.setTargetUid(targetUid); welcomeInfo.setTargetUid(targetUid);
welcomeInfo.setTargetNick(info.getNick()); welcomeInfo.setTargetNick(info.getNick());
welcomeInfo.setFans(roomWelcomeConfig.isFans()); welcomeInfo.setFans(roomWelcomeConfig.isFans());
return welcomeInfo; return welcomeInfo;
}) })
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.flatMap((Function<WelcomeInfo, SingleSource<ChatRoomMessage>>) welcomeInfo -> { .flatMap((Function<WelcomeInfo, SingleSource<ChatRoomMessage>>) welcomeInfo -> {
WelcomeAttachment attachment = new WelcomeAttachment(); WelcomeAttachment attachment = new WelcomeAttachment();
@@ -2720,14 +2736,14 @@ public class MessageView extends FrameLayout {
SpannableBuilder text = new SpannableBuilder(tvContent); SpannableBuilder text = new SpannableBuilder(tvContent);
addCommonTag(chatRoomMessage, text, tvContent); addCommonTag(chatRoomMessage, text, tvContent);
text.append(extension == null ? "" : RegexUtil.getPrintableString(extension.getSenderNick()), text.append(extension == null ? "" : RegexUtil.getPrintableString(extension.getSenderNick()),
new ForegroundColorSpan(greyColor), new ForegroundColorSpan(greyColor),
new OriginalDrawStatusClickSpan() { new OriginalDrawStatusClickSpan() {
@Override @Override
public void onClick(@NonNull View widget) { public void onClick(@NonNull View widget) {
Single.just(String.valueOf(chatRoomMessage.getFromAccount())) Single.just(String.valueOf(chatRoomMessage.getFromAccount()))
.doOnSuccess(clickConsumer).subscribe(); .doOnSuccess(clickConsumer).subscribe();
} }
}) })
.append("" + welcomeInfo.getLastConent(), new ForegroundColorSpan(whiteColor)) .append("" + welcomeInfo.getLastConent(), new ForegroundColorSpan(whiteColor))
.append(welcomeInfo.getTargetNick(), new ForegroundColorSpan(roomTipNickColor), .append(welcomeInfo.getTargetNick(), new ForegroundColorSpan(roomTipNickColor),
new OriginalDrawStatusClickSpan() { new OriginalDrawStatusClickSpan() {

View File

@@ -52,6 +52,9 @@ import com.mango.core.super_admin.util.SuperAdminUtil
import com.mango.core.user.UserModel import com.mango.core.user.UserModel
import com.mango.core.user.bean.UserInfo import com.mango.core.user.bean.UserInfo
import com.mango.core.utils.subAndReplaceDot import com.mango.core.utils.subAndReplaceDot
import com.mango.moshen.ui.webview.CommonWebViewActivity
import com.mango.moshen.utils.MsgBuilder
import com.mango.moshen.utils.UserUtils
import com.mango.xchat_android_library.utils.ListUtils import com.mango.xchat_android_library.utils.ListUtils
import io.reactivex.Observable import io.reactivex.Observable
import io.reactivex.ObservableEmitter import io.reactivex.ObservableEmitter
@@ -116,12 +119,19 @@ class RoomEffectView @JvmOverloads constructor(
private val messagesGiftCompound: MutableList<ChatRoomMessage> by lazy { ArrayList() } private val messagesGiftCompound: MutableList<ChatRoomMessage> by lazy { ArrayList() }
private var animationRadish: Animation? = null private var animationRadish: Animation? = null
private val messagesRadish: MutableList<ChatRoomMessage> by lazy { java.util.ArrayList() } private val messagesRadish: MutableList<ChatRoomMessage> by lazy { ArrayList() }
private var radishDisposable: Disposable? = null private var radishDisposable: Disposable? = null
private val messagesRadishSVGA: MutableList<ChatRoomMessage> by lazy { java.util.ArrayList() } private val messagesRadishSVGA: MutableList<ChatRoomMessage> by lazy { ArrayList() }
private var radishSVGADisposable: Disposable? = null private var radishSVGADisposable: Disposable? = null
private var kitchenAnimation: Animation? = null
private var kitchenDisposable: Disposable? = null
private val kitchenMessages: MutableList<ChatRoomMessage> by lazy { ArrayList() }
private var kitchenSVGADisposable: Disposable? = null
private val kitchenMessagesSVGA: MutableList<ChatRoomMessage> by lazy { ArrayList() }
private var isSvgaPlaying = false private var isSvgaPlaying = false
private var isHideCarEffect = false private var isHideCarEffect = false
@@ -216,6 +226,8 @@ class RoomEffectView @JvmOverloads constructor(
binding.svgaWishList.startAnimation() binding.svgaWishList.startAnimation()
} }
} }
RoomEvent.KITCHEN_ROOM -> addKitchenNotify(roomEvent.chatRoomMessage)
RoomEvent.KITCHEN_ALL_ROOM -> addKitchenNotifyBySVGA(roomEvent.chatRoomMessage)
else -> {} else -> {}
} }
} }
@@ -577,6 +589,117 @@ class RoomEffectView @JvmOverloads constructor(
) )
} }
/**
* 幸运池飘屏
*
* @param chatRoomMessage
*/
private fun addKitchenNotify(chatRoomMessage: ChatRoomMessage) {
if (binding.clNotify.visibility == GONE) {
binding.clNotify.visibility = VISIBLE
}
kitchenMessages.add(chatRoomMessage)
if (kitchenDisposable == null || kitchenMessages.size == 1) {
kitchenDisposable = Observable.interval(0, PERIOD.toLong(), TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.takeWhile { kitchenMessages.size > 0 }
.subscribe {
showKitchenNotify(
kitchenMessages.removeAt(0)
)
}
}
}
private fun showKitchenNotify(chatRoomMessage: ChatRoomMessage) {
val attachment = chatRoomMessage.attachment as RoomKitchenAttachment
val textView =
LayoutInflater.from(mContext).inflate(R.layout.layout_room_box_notify, null) as TextView
val text = MsgBuilder.buildKitchenMsg(attachment)
textView.text = text.build()
MsgBuilder.setUpKitchenClick(textView, attachment.skipUrl, attachment.needLevel)
kitchenAnimation = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify)
binding.flKitchenNotify.addView(textView)
textView.startAnimation(kitchenAnimation)
binding.flKitchenNotify.postDelayed(
{ binding.flKitchenNotify.removeView(textView) },
SHOW_TIME.toLong()
)
}
/**
* 幸运池飘屏 五级 SVGA背景的
*
* @param chatRoomMessage
*/
private fun addKitchenNotifyBySVGA(chatRoomMessage: ChatRoomMessage) {
if (binding.clNotify.visibility == GONE) {
binding.clNotify.visibility = VISIBLE
}
kitchenMessagesSVGA.add(chatRoomMessage)
if (kitchenSVGADisposable == null || kitchenMessagesSVGA.size == 1) {
kitchenSVGADisposable = Observable.interval(0, PERIOD.toLong(), TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.takeWhile { kitchenMessagesSVGA.size > 0 }
.subscribe {
showKitchenNotifyBySVGA(
kitchenMessagesSVGA.removeAt(0)
)
}
}
}
private fun showKitchenNotifyBySVGA(chatRoomMessage: ChatRoomMessage) {
val attachment = chatRoomMessage.attachment as RoomKitchenAttachment
val text = MsgBuilder.buildKitchenMsg(attachment)
val svgaImageView = SVGAImageView(mContext)
svgaImageView.loops = 1
svgaImageView.clearsAfterStop = true
val params = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)
svgaImageView.layoutParams = params
svgaImageView.callback = object : SimpleSvgaCallback() {
override fun onFinished() {
binding.flKitchenSvgaNotify.post {
binding.flKitchenSvgaNotify.removeView(
svgaImageView
)
}
}
}
MsgBuilder.setUpKitchenClick(svgaImageView, attachment.skipUrl, attachment.needLevel)
binding.flKitchenSvgaNotify.addView(svgaImageView)
shareParser().decodeFromAssets(
"svga/kitchen_notify.svga",
object : SVGAParser.ParseCompletion {
override fun onComplete(videoItem: SVGAVideoEntity) {
val dynamicEntity = SVGADynamicEntity()
val textPaint = TextPaint()
textPaint.color = Color.WHITE //字体颜色
textPaint.textSize = 24f //字体大小
dynamicEntity.setDynamicText(
StaticLayout(
text.build(),
0,
text.build().length,
textPaint,
0,
Layout.Alignment.ALIGN_CENTER,
1.0f,
0.0f,
false
), "noble_text_tx"
)
val drawable = SVGADrawable(videoItem, dynamicEntity)
svgaImageView.setImageDrawable(drawable)
svgaImageView.stepToFrame(0, true)
}
override fun onError() {}
},
null
)
}
/** /**
* 添加跑马灯 * 添加跑马灯
* 以及反射一些参数影响跑马灯 * 以及反射一些参数影响跑马灯

View File

@@ -0,0 +1,43 @@
package com.mango.moshen.utils
import android.graphics.Color
import android.text.style.ForegroundColorSpan
import android.view.View
import com.mango.core.im.custom.bean.RoomKitchenAttachment
import com.mango.moshen.ui.webview.CommonWebViewActivity
class MsgBuilder {
companion object {
@JvmStatic
fun buildKitchenMsg(
attachment: RoomKitchenAttachment,
nickColor: Int = Color.parseColor("#FFFE95")
): SpannableBuilder {
return SpannableBuilder()
.append("恭喜 ", ForegroundColorSpan(Color.WHITE))
.append(attachment.nick, ForegroundColorSpan(nickColor))
.append("在星级厨房抽中", ForegroundColorSpan(Color.WHITE))
.append(attachment.itemMultiple, ForegroundColorSpan(Color.parseColor("#00EAFF")))
.append("倍奖励,获得", ForegroundColorSpan(Color.WHITE))
.append(attachment.diamonds, ForegroundColorSpan(Color.parseColor("#00EAFF")))
.append("钻石!", ForegroundColorSpan(Color.WHITE))
}
@JvmStatic
fun setUpKitchenClick(view: View, skipUrl: String, needLevel: Int): Boolean {
val expLevel = UserUtils.getExpLevel()
if (expLevel != 0 && needLevel != 0 && expLevel >= needLevel) {
view.setOnClickListener {
CommonWebViewActivity.start(
view.context,
skipUrl
)
}
return true
}
return false
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

View File

@@ -70,6 +70,20 @@
app:layout_constraintDimensionRatio="75:11" app:layout_constraintDimensionRatio="75:11"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<FrameLayout
android:id="@+id/fl_kitchen_notify"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintDimensionRatio="75:12"
app:layout_constraintTop_toTopOf="parent" />
<FrameLayout
android:id="@+id/fl_kitchen_svga_notify"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintDimensionRatio="75:12"
app:layout_constraintTop_toTopOf="parent" />
<FrameLayout <FrameLayout
android:id="@+id/fl_box_notify" android:id="@+id/fl_box_notify"
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<com.coorchice.library.SuperTextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:background="@drawable/bg_kitchen_notice"
android:ellipsize="end"
android:gravity="center"
android:includeFontPadding="false"
android:lineSpacingExtra="0dp"
android:lineSpacingMultiplier="0.9"
android:maxLines="2"
android:paddingStart="80dp"
android:paddingTop="10dp"
android:paddingEnd="80dp"
android:textSize="12sp"
tools:layout_height="wrap_content"
tools:text="哈哈哈哈哈哈啊哈哈啊哈哈哈哈哈哈哈哈哈哈哈" />

View File

@@ -1416,6 +1416,15 @@ public final class IMNetEaseManager {
break; break;
} }
break; break;
case CUSTOM_MSG_KITCHEN:
if (customAttachment.getSecond() == CUSTOM_MSG_SUB_KITCHEN_ROOM) {
noticeRoomEvent(msg, RoomEvent.KITCHEN_ROOM);
addMessages(msg);
} else if (customAttachment.getSecond() == CUSTOM_MSG_SUB_KITCHEN_ALL_ROOM) {
noticeRoomEvent(msg, RoomEvent.KITCHEN_ALL_ROOM);
addMessages(msg);
}
break;
default: default:
break; break;
} }
@@ -1436,10 +1445,10 @@ public final class IMNetEaseManager {
UserModel.get().getCacheLoginUserInfo().setGroupType(PKTeamInfo.TEAM_NONE); UserModel.get().getCacheLoginUserInfo().setGroupType(PKTeamInfo.TEAM_NONE);
//在麦上就更新信息 //在麦上就更新信息
AvRoomModel.get().updateMyMicQueue( AvRoomModel.get().updateMyMicQueue(
AvRoomDataManager.get().getMicPosition(AuthModel.get().getCurrentUid()), AvRoomDataManager.get().getMicPosition(AuthModel.get().getCurrentUid()),
String.valueOf(AvRoomDataManager.get().mCurrentRoomInfo.getRoomId()), String.valueOf(AvRoomDataManager.get().mCurrentRoomInfo.getRoomId()),
UserModel.get().getCacheLoginUserInfo() UserModel.get().getCacheLoginUserInfo()
) )
.subscribe(); .subscribe();
} }
} }
@@ -2140,31 +2149,31 @@ public final class IMNetEaseManager {
public Single<List<ChatRoomMember>> fetchRoomMembersByIds(final List<String> accounts) { public Single<List<ChatRoomMember>> fetchRoomMembersByIds(final List<String> accounts) {
return Single.create((SingleOnSubscribe<List<ChatRoomMember>>) e -> { return Single.create((SingleOnSubscribe<List<ChatRoomMember>>) e -> {
final RoomInfo mCurrentRoomInfo = AvRoomDataManager.get().mCurrentRoomInfo; final RoomInfo mCurrentRoomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
if (mCurrentRoomInfo == null || ListUtils.isListEmpty(accounts)) { if (mCurrentRoomInfo == null || ListUtils.isListEmpty(accounts)) {
e.onError(new IllegalArgumentException("RoomInfo is null or accounts is null")); e.onError(new IllegalArgumentException("RoomInfo is null or accounts is null"));
return; return;
} }
NIMChatRoomSDK.getChatRoomService() NIMChatRoomSDK.getChatRoomService()
.fetchRoomMembersByIds(String.valueOf(mCurrentRoomInfo.getRoomId()), accounts) .fetchRoomMembersByIds(String.valueOf(mCurrentRoomInfo.getRoomId()), accounts)
.setCallback(new RequestCallback<List<ChatRoomMember>>() { .setCallback(new RequestCallback<List<ChatRoomMember>>() {
@Override @Override
public void onSuccess(List<ChatRoomMember> param) { public void onSuccess(List<ChatRoomMember> param) {
e.onSuccess(param); e.onSuccess(param);
} }
@Override @Override
public void onFailed(int code) { public void onFailed(int code) {
e.onError(new Exception("错误码: " + code)); e.onError(new Exception("错误码: " + code));
} }
@Override @Override
public void onException(Throwable exception) { public void onException(Throwable exception) {
e.onError(exception); e.onError(exception);
} }
}); });
}).subscribeOn(Schedulers.computation()) }).subscribeOn(Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread()); .observeOn(AndroidSchedulers.mainThread());
} }
@@ -2380,16 +2389,16 @@ public final class IMNetEaseManager {
if (roomInfo == null) return null; if (roomInfo == null) return null;
String downMicUid = AvRoomDataManager.get().getRoomQueueMemberUidByMicPosition(micPosition); String downMicUid = AvRoomDataManager.get().getRoomQueueMemberUidByMicPosition(micPosition);
return Single.create((SingleOnSubscribe<String>) e -> { return Single.create((SingleOnSubscribe<String>) e -> {
RequestResult<Entry<String, String>> result = NIMClient.syncRequest(NIMChatRoomSDK.getChatRoomService() RequestResult<Entry<String, String>> result = NIMClient.syncRequest(NIMChatRoomSDK.getChatRoomService()
.pollQueue(String.valueOf(roomInfo.getRoomId()), String.valueOf(micPosition))); .pollQueue(String.valueOf(roomInfo.getRoomId()), String.valueOf(micPosition)));
if (result.exception != null) if (result.exception != null)
e.onError(result.exception); e.onError(result.exception);
else if (result.code != BaseMvpModel.RESULT_OK) else if (result.code != BaseMvpModel.RESULT_OK)
e.onError(new Throwable("错误码: " + result.code)); e.onError(new Throwable("错误码: " + result.code));
else { else {
e.onSuccess("下麦回调成功"); e.onSuccess("下麦回调成功");
} }
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
.doOnSuccess(s -> GiftValueMrg.get().requestDownMic(micPosition, downMicUid)); .doOnSuccess(s -> GiftValueMrg.get().requestDownMic(micPosition, downMicUid));
} }
@@ -2458,10 +2467,10 @@ public final class IMNetEaseManager {
@Override @Override
public void subscribe(SingleEmitter<String> e) throws Exception { public void subscribe(SingleEmitter<String> e) throws Exception {
NIMChatRoomSDK.getChatRoomService().kickMember( NIMChatRoomSDK.getChatRoomService().kickMember(
String.valueOf(roomId), String.valueOf(roomId),
String.valueOf(account), String.valueOf(account),
notifyExtension notifyExtension
) )
.setCallback(new RequestCallback<Void>() { .setCallback(new RequestCallback<Void>() {
@Override @Override
public void onSuccess(Void param) { public void onSuccess(Void param) {
@@ -2567,28 +2576,28 @@ public final class IMNetEaseManager {
return Single.error(new ErrorThrowable(ErrorThrowable.ROOM_INFO_NULL_ERROR)); return Single.error(new ErrorThrowable(ErrorThrowable.ROOM_INFO_NULL_ERROR));
final long micUid = baseInfo.getUid(); final long micUid = baseInfo.getUid();
return Single.create( return Single.create(
new SingleOnSubscribe<ChatRoomMessage>() { new SingleOnSubscribe<ChatRoomMessage>() {
@Override @Override
public void subscribe(SingleEmitter<ChatRoomMessage> e) throws Exception { public void subscribe(SingleEmitter<ChatRoomMessage> e) throws Exception {
RoomQueueMsgAttachment queueMsgAttachment = new RoomQueueMsgAttachment(CUSTOM_MSG_HEADER_TYPE_QUEUE, RoomQueueMsgAttachment queueMsgAttachment = new RoomQueueMsgAttachment(CUSTOM_MSG_HEADER_TYPE_QUEUE,
CUSTOM_MSG_HEADER_TYPE_QUEUE_INVITE); CUSTOM_MSG_HEADER_TYPE_QUEUE_INVITE);
queueMsgAttachment.uid = String.valueOf(micUid); queueMsgAttachment.uid = String.valueOf(micUid);
queueMsgAttachment.micPosition = position; queueMsgAttachment.micPosition = position;
queueMsgAttachment.handleUid = AuthModel.get().getCurrentUid(); queueMsgAttachment.handleUid = AuthModel.get().getCurrentUid();
UserInfo myInfo = UserModel.get().getCacheLoginUserInfo(); UserInfo myInfo = UserModel.get().getCacheLoginUserInfo();
if (myInfo != null) { if (myInfo != null) {
queueMsgAttachment.handleNick = myInfo.getNick() == null ? "" : myInfo.getNick(); queueMsgAttachment.handleNick = myInfo.getNick() == null ? "" : myInfo.getNick();
} }
queueMsgAttachment.targetNick = baseInfo.getNick(); queueMsgAttachment.targetNick = baseInfo.getNick();
if (baseInfo.getGroupType() != 0) { if (baseInfo.getGroupType() != 0) {
queueMsgAttachment.groupType = baseInfo.getGroupType(); queueMsgAttachment.groupType = baseInfo.getGroupType();
} }
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage( ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(
String.valueOf(roomInfo.getRoomId()), queueMsgAttachment); String.valueOf(roomInfo.getRoomId()), queueMsgAttachment);
e.onSuccess(message); e.onSuccess(message);
} }
}).subscribeOn(Schedulers.io()) }).subscribeOn(Schedulers.io())
.unsubscribeOn(Schedulers.io()) .unsubscribeOn(Schedulers.io())
.filter(new Predicate<ChatRoomMessage>() { .filter(new Predicate<ChatRoomMessage>() {
@Override @Override
@@ -2675,17 +2684,17 @@ public final class IMNetEaseManager {
if (roomInfo == null) if (roomInfo == null)
return Single.error(new ErrorThrowable(ErrorThrowable.ROOM_INFO_NULL_ERROR)); return Single.error(new ErrorThrowable(ErrorThrowable.ROOM_INFO_NULL_ERROR));
return Single.create( return Single.create(
(SingleOnSubscribe<ChatRoomMessage>) e -> { (SingleOnSubscribe<ChatRoomMessage>) e -> {
NobleAttachment nobleMsgAttachment = new NobleAttachment(CUSTOM_MESS_HEAD_NOBLE, NobleAttachment nobleMsgAttachment = new NobleAttachment(CUSTOM_MESS_HEAD_NOBLE,
CUSTOM_MESS_SUB_ROOM_WELCOME); CUSTOM_MESS_SUB_ROOM_WELCOME);
nobleMsgAttachment.uid = uid; nobleMsgAttachment.uid = uid;
nobleMsgAttachment.nick = nick; nobleMsgAttachment.nick = nick;
nobleMsgAttachment.nobleInfo = nobleInfo; nobleMsgAttachment.nobleInfo = nobleInfo;
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage( ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(
String.valueOf(roomInfo.getRoomId()), nobleMsgAttachment); String.valueOf(roomInfo.getRoomId()), nobleMsgAttachment);
e.onSuccess(message); e.onSuccess(message);
}).subscribeOn(Schedulers.io()) }).subscribeOn(Schedulers.io())
.unsubscribeOn(Schedulers.io()) .unsubscribeOn(Schedulers.io())
.filter(chatRoomMessage -> nobleInfo != null && !TextUtils.isEmpty(nick) && uid != 0) .filter(chatRoomMessage -> nobleInfo != null && !TextUtils.isEmpty(nick) && uid != 0)
.toSingle() .toSingle()
@@ -2705,19 +2714,19 @@ public final class IMNetEaseManager {
if (roomInfo == null) if (roomInfo == null)
return Single.error(new ErrorThrowable(ErrorThrowable.ROOM_INFO_NULL_ERROR)); return Single.error(new ErrorThrowable(ErrorThrowable.ROOM_INFO_NULL_ERROR));
return Single.create( return Single.create(
(SingleOnSubscribe<ChatRoomMessage>) e -> { (SingleOnSubscribe<ChatRoomMessage>) e -> {
CarAttachment carAttachment = new CarAttachment(CUSTOM_MESS_HEAD_CAR, CarAttachment carAttachment = new CarAttachment(CUSTOM_MESS_HEAD_CAR,
CUSTOM_MESS_SUB_CAR_ENTER_ROOM); CUSTOM_MESS_SUB_CAR_ENTER_ROOM);
carAttachment.uid = uid; carAttachment.uid = uid;
carAttachment.nick = nick; carAttachment.nick = nick;
carAttachment.effect = carInfo.getEffect(); carAttachment.effect = carInfo.getEffect();
carAttachment.viewUrl = carInfo.getViewUrl(); carAttachment.viewUrl = carInfo.getViewUrl();
carAttachment.otherViewType = carInfo.getOtherViewType(); carAttachment.otherViewType = carInfo.getOtherViewType();
ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage( ChatRoomMessage message = ChatRoomMessageBuilder.createChatRoomCustomMessage(
String.valueOf(roomInfo.getRoomId()), carAttachment); String.valueOf(roomInfo.getRoomId()), carAttachment);
e.onSuccess(message); e.onSuccess(message);
}).subscribeOn(Schedulers.io()) }).subscribeOn(Schedulers.io())
.unsubscribeOn(Schedulers.io()) .unsubscribeOn(Schedulers.io())
.filter(chatRoomMessage -> carInfo != null && !TextUtils.isEmpty(nick) && uid != 0) .filter(chatRoomMessage -> carInfo != null && !TextUtils.isEmpty(nick) && uid != 0)
.toSingle() .toSingle()
@@ -2802,28 +2811,28 @@ public final class IMNetEaseManager {
long delayTime, ReconnectListener listener) { long delayTime, ReconnectListener listener) {
return Single.create((SingleOnSubscribe<RetryChatRoomMessage>) emitter -> { return Single.create((SingleOnSubscribe<RetryChatRoomMessage>) emitter -> {
retryChatRoomMessage.setRetryCount(retryChatRoomMessage.getRetryCount() + 1); retryChatRoomMessage.setRetryCount(retryChatRoomMessage.getRetryCount() + 1);
ImRetryManager.logIde("start send im msg :" + retryChatRoomMessage.getRetryCount()); ImRetryManager.logIde("start send im msg :" + retryChatRoomMessage.getRetryCount());
if (isExitRoom()) { if (isExitRoom()) {
String error = "exite room when send msg"; String error = "exite room when send msg";
emitter.onError(new Throwable(error)); emitter.onError(new Throwable(error));
return; return;
} }
if (isChangeRoom(retryChatRoomMessage.getMessage())) { if (isChangeRoom(retryChatRoomMessage.getMessage())) {
String error = "changed room when send msg"; String error = "changed room when send msg";
emitter.onError(new Throwable(error)); emitter.onError(new Throwable(error));
return; return;
} }
sendChatRoomMessage(retryChatRoomMessage.getMessage(), false) sendChatRoomMessage(retryChatRoomMessage.getMessage(), false)
.subscribe((message, throwable) -> { .subscribe((message, throwable) -> {
if (throwable == null) { if (throwable == null) {
retryChatRoomMessage.setMessage(message); retryChatRoomMessage.setMessage(message);
emitter.onSuccess(retryChatRoomMessage); emitter.onSuccess(retryChatRoomMessage);
} else { } else {
emitter.onError(throwable); emitter.onError(throwable);
} }
}); });
}) })
.retryWhen(flowable -> flowable .retryWhen(flowable -> flowable
.flatMap(new Function<Throwable, Publisher<?>>() { .flatMap(new Function<Throwable, Publisher<?>>() {
@Override @Override

View File

@@ -28,6 +28,7 @@ import static com.mango.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_HEADER_T
import static com.mango.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_HEADER_TYPE_SHARE_IN_APP; import static com.mango.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_HEADER_TYPE_SHARE_IN_APP;
import static com.mango.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_HEAD_SHIFT_OUT; import static com.mango.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_HEAD_SHIFT_OUT;
import static com.mango.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_IM_TIP; import static com.mango.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_IM_TIP;
import static com.mango.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_KITCHEN;
import static com.mango.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_KTV; import static com.mango.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_KTV;
import static com.mango.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LEAVE_MODE; import static com.mango.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LEAVE_MODE;
import static com.mango.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LEAVE_MODE_NOTICE; import static com.mango.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LEAVE_MODE_NOTICE;
@@ -601,6 +602,9 @@ public class CustomAttachParser implements MsgAttachmentParser {
case CUSTOM_MSG_WISH_LIST: case CUSTOM_MSG_WISH_LIST:
attachment = new WishListAttachment(first, second); attachment = new WishListAttachment(first, second);
break; break;
case CUSTOM_MSG_KITCHEN:
attachment = new RoomKitchenAttachment(first, second);
break;
default: default:
LogUtils.e("未定义的first,请现在CustomAttachParser中解析first=" + first + " second=" + second); LogUtils.e("未定义的first,请现在CustomAttachParser中解析first=" + first + " second=" + second);
break; break;

View File

@@ -428,6 +428,11 @@ public class CustomAttachment implements MsgAttachment {
// 关闭心愿礼物 // 关闭心愿礼物
public static final int CUSTOM_MSG_WISH_LIST_CLOSE = 955; public static final int CUSTOM_MSG_WISH_LIST_CLOSE = 955;
public static final int CUSTOM_MSG_KITCHEN = 96; // 深海奇缘消息
public static final int CUSTOM_MSG_SUB_KITCHEN_ROOM = 960; // 深海奇缘礼物房间飘屏通知(静态)
public static final int CUSTOM_MSG_SUB_KITCHEN_ALL_ROOM = 961; // 深海奇缘礼物房间飘屏通知(动态)
public static final int CUSTOM_MSG_SUB_kitchen_ALL_APP = 962; // 深海奇缘礼物全服飘屏通知
/** /**
* 自定义消息附件的类型,根据该字段区分不同的自定义消息 * 自定义消息附件的类型,根据该字段区分不同的自定义消息

View File

@@ -0,0 +1,130 @@
package com.mango.core.im.custom.bean;
import com.alibaba.fastjson.JSONObject;
import com.netease.nim.uikit.common.util.string.StringUtil;
/**
* Created by chenran on 2017/10/4.
*/
public class RoomKitchenAttachment extends CustomAttachment {
private long uid;
private String nick;
private long roomUid;
private long itemId;
private String itemMultiple;
private String diamonds;
private int bannerId;
private String skipUrl;
private int needLevel;
public RoomKitchenAttachment(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 getRoomUid() {
return roomUid;
}
public void setRoomUid(long roomUid) {
this.roomUid = roomUid;
}
public long getItemId() {
return itemId;
}
public void setItemId(long itemId) {
this.itemId = itemId;
}
public String getItemMultiple() {
return itemMultiple;
}
public void setItemMultiple(String itemMultiple) {
this.itemMultiple = itemMultiple;
}
public String getDiamonds() {
return diamonds;
}
public void setDiamonds(String diamonds) {
this.diamonds = diamonds;
}
public int getBannerId() {
return bannerId;
}
public void setBannerId(int bannerId) {
this.bannerId = bannerId;
}
public String getSkipUrl() {
return skipUrl;
}
public void setSkipUrl(String skipUrl) {
this.skipUrl = skipUrl;
}
public int getNeedLevel() {
return needLevel;
}
public void setNeedLevel(int needLevel) {
this.needLevel = needLevel;
}
@Override
protected void parseData(JSONObject jsonObject) {
uid = jsonObject.getLongValue("uid");
nick = jsonObject.getString("nick");
roomUid = jsonObject.getLongValue("roomUid");
itemId = jsonObject.getLongValue("itemId");
diamonds = jsonObject.getString("diamonds");
itemMultiple = jsonObject.getString("itemMultiple");
bannerId = jsonObject.getIntValue("bannerId");
skipUrl = jsonObject.getString("skipUrl");
needLevel = jsonObject.getIntValue("needLevel");
}
@Override
protected JSONObject packData() {
return null;
}
@Override
public String toString() {
return "RoomKitchenAttachment{" +
"uid=" + uid +
", nick='" + nick + '\'' +
", roomUid=" + roomUid +
", itemId=" + itemId +
", itemMultiple='" + itemMultiple + '\'' +
", diamonds='" + diamonds + '\'' +
", bannerId=" + bannerId +
", skipUrl='" + skipUrl + '\'' +
", needLevel=" + needLevel +
'}';
}
}

View File

@@ -251,6 +251,10 @@ public class RoomEvent {
public static final int WISH_LIST_EFFECT = 99; public static final int WISH_LIST_EFFECT = 99;
public static final int KITCHEN_ROOM = 100;
public static final int KITCHEN_ALL_ROOM = 101;
private int event = NONE; private int event = NONE;
private int micPosition = Integer.MIN_VALUE; private int micPosition = Integer.MIN_VALUE;
private int posState = -1; private int posState = -1;

View File

@@ -17,7 +17,7 @@ import lombok.ToString;
*/ */
@Data @Data
@ToString @ToString
public class RoomInfo implements Parcelable,Serializable { public class RoomInfo implements Parcelable, Serializable {
public static final int ROOMTYPE_DEFAULT = -1;//使用服务器的房间类型 public static final int ROOMTYPE_DEFAULT = -1;//使用服务器的房间类型
public static final int ROOMTYPE_AUCTION = 1;//竞拍房间 public static final int ROOMTYPE_AUCTION = 1;//竞拍房间
public static final int ROOMTYPE_LIGHT_CHAT = 2;//轻聊房 public static final int ROOMTYPE_LIGHT_CHAT = 2;//轻聊房
@@ -29,34 +29,68 @@ public class RoomInfo implements Parcelable,Serializable {
public static final String DATING_STATE_FLOW = "1";//嘉宾交流 public static final String DATING_STATE_FLOW = "1";//嘉宾交流
public static final String DATING_STATE_SELECT = "2";//心动选人 public static final String DATING_STATE_SELECT = "2";//心动选人
public static final String DATING_STATE_PUBLISH = "3";//公布心动 public static final String DATING_STATE_PUBLISH = "3";//公布心动
// 限制类型
public static final String LOCK = "lock";//密码可进
public static final String IS_FRIEND = "isFriend";//密码可进
public static final String IS_INVITE = "isInvite";//密码可进
public static final Creator<RoomInfo> CREATOR = new Creator<RoomInfo>() {
@Override
public RoomInfo createFromParcel(Parcel in) {
return new RoomInfo(in);
}
@Override
public RoomInfo[] newArray(int size) {
return new RoomInfo[size];
}
};
public String title;
/**
* 是否需要打开全服红包 true为开启 false为关闭
*/
public boolean serverRedEnvelopeSwitch;
// 是否有桌球游戏
public boolean hasDragonGame;
public String roomPwd;
/**
* 主题类型id
*/
public int tagId;
public String tagPict;
/**
* 房间在线人数 (会减去超管的人数)
*/
public int onlineNum;
//是否有ktv权限的意思
public boolean hasKTVPriv;
//房间是否打开了ktv
public boolean isOpenKTV;
public boolean isOpenGame;
public BoxSwitchVo boxSwitchVo;
public String nick;
public int gender;
private long uid; private long uid;
// private long openTime;
/** /**
* 官方账号与非官方账号 * 官方账号与非官方账号
*/ */
private int officeUser; private int officeUser;
private long roomId; private long roomId;
private long roomUid; private long roomUid;
public String title;
//头像 //头像
private String avatar; private String avatar;
private int type; private int type;
/**
/** 房间主题 */ * 房间主题
*/
private String roomDesc; private String roomDesc;
private String backPic; private String backPic;
private List<String> speakTemplate; private List<String> speakTemplate;
/** /**
* 房间是否开启,是否正在直播 * 房间是否开启,是否正在直播
*/ */
private boolean valid; private boolean valid;
/** /**
* 1:房主在房间2 :房主不在房间 * 1:房主在房间2 :房主不在房间
*/ */
@@ -67,97 +101,82 @@ public class RoomInfo implements Parcelable,Serializable {
private int audioQuality; private int audioQuality;
// true为关闭 false为开启 // true为关闭 false为开启
private boolean isCloseScreen; private boolean isCloseScreen;
/**
* 是否需要打开全服红包 true为开启 false为关闭
*/
public boolean serverRedEnvelopeSwitch;
// 是否有桌球游戏
public boolean hasDragonGame;
private String meetingName; private String meetingName;
// private long openTime;
public String roomPwd;
private String sortName; private String sortName;
private String roomTag; private String roomTag;
/** 主题类型id */
public int tagId;
public String tagPict;
/** 房间在线人数 (会减去超管的人数)*/
public int onlineNum;
/** /**
* 是否是皇帝推荐的 * 是否是皇帝推荐的
*/ */
private byte isRecom; private byte isRecom;
private boolean isRoomFans; private boolean isRoomFans;
private BackgroundBean background; private BackgroundBean background;
//是否有ktv权限的意思
public boolean hasKTVPriv;
//房间是否打开了ktv
public boolean isOpenKTV;
public boolean isOpenGame;
public BoxSwitchVo boxSwitchVo;
private String singingMusicName; private String singingMusicName;
// 限制类型
public static final String LOCK = "lock";//密码可进
public static final String IS_FRIEND = "isFriend";//密码可进
public static final String IS_INVITE = "isInvite";//密码可进
private String limitType; private String limitType;
private String introduction; private String introduction;
/** /**
* {@link RoomModeType} * {@link RoomModeType}
*/ */
private int roomModeType; private int roomModeType;
private int isPermitRoom; // 1:牌照房, 3:新秀房,其他:普通房 private int isPermitRoom; // 1:牌照房, 3:新秀房,其他:普通房
/** /**
* 是否为房间纯净模式 * 是否为房间纯净模式
*/ */
private boolean isPureMode; private boolean isPureMode;
/** /**
* 是否关闭抽奖 * 是否关闭抽奖
*/ */
private boolean closeBox; private boolean closeBox;
/** /**
* 离开模式 * 离开模式
*/ */
private boolean leaveMode; private boolean leaveMode;
public String nick;
public int gender;
private long worldId; // >0:语音派对房 private long worldId; // >0:语音派对房
private boolean showPkBeginTime; private boolean showPkBeginTime;
private long pkBeginTime; private long pkBeginTime;
/** /**
* 个播匹配开始时间 * 个播匹配开始时间
*/ */
private long pkMatchStartTime; private long pkMatchStartTime;
/** /**
* 是否有心愿礼物权限 * 是否有心愿礼物权限
*/ */
private boolean hasWishGiftPermit; private boolean hasWishGiftPermit;
/** /**
* 是否已经开启心愿礼物 * 是否已经开启心愿礼物
*/ */
private boolean hasOpenWishGift; private boolean hasOpenWishGift;
/**
* 是否开启礼物值目前ktv房cp房都不支持
*/
private boolean showGiftValue;
/**
* 0.不隐藏; 1.全局+排行榜
*/
private int hideFlag;
/**
* 公屏操作人0.房主或管理员1.超管
*/
private int closeScreenFlag;
private boolean redEnvelopeOpen;
/**
* COMMUNICATING(1, "交谈"),
* PICK(2, "心动选人"),
* PUBLISH(3, "公布心动"),
* FINISH(4, "结束"),
*/
private String blindDateState = "";
private long blindDateVipUid;
private boolean canOpenBlindDate;
/**
* {@link RoomAudioSdkType}
*/
private String audioSdkType;
private String trtcSig;
private boolean isReselect;
private long mgId;
private String mgName;
private int mgMicNum;
private long clearScreenTime;
protected RoomInfo(Parcel in) { protected RoomInfo(Parcel in) {
uid = in.readLong(); uid = in.readLong();
@@ -179,8 +198,8 @@ public class RoomInfo implements Parcelable,Serializable {
hasDragonGame = in.readByte() != 0; hasDragonGame = in.readByte() != 0;
meetingName = in.readString(); meetingName = in.readString();
roomPwd = in.readString(); roomPwd = in.readString();
roomTag = in.readString();
sortName = in.readString(); sortName = in.readString();
roomTag = in.readString();
tagId = in.readInt(); tagId = in.readInt();
tagPict = in.readString(); tagPict = in.readString();
onlineNum = in.readInt(); onlineNum = in.readInt();
@@ -204,6 +223,9 @@ public class RoomInfo implements Parcelable,Serializable {
worldId = in.readLong(); worldId = in.readLong();
showPkBeginTime = in.readByte() != 0; showPkBeginTime = in.readByte() != 0;
pkBeginTime = in.readLong(); pkBeginTime = in.readLong();
pkMatchStartTime = in.readLong();
hasWishGiftPermit = in.readByte() != 0;
hasOpenWishGift = in.readByte() != 0;
showGiftValue = in.readByte() != 0; showGiftValue = in.readByte() != 0;
hideFlag = in.readInt(); hideFlag = in.readInt();
closeScreenFlag = in.readInt(); closeScreenFlag = in.readInt();
@@ -220,6 +242,9 @@ public class RoomInfo implements Parcelable,Serializable {
clearScreenTime = in.readLong(); clearScreenTime = in.readLong();
} }
public RoomInfo() {
}
@Override @Override
public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(uid); dest.writeLong(uid);
@@ -241,8 +266,8 @@ public class RoomInfo implements Parcelable,Serializable {
dest.writeByte((byte) (hasDragonGame ? 1 : 0)); dest.writeByte((byte) (hasDragonGame ? 1 : 0));
dest.writeString(meetingName); dest.writeString(meetingName);
dest.writeString(roomPwd); dest.writeString(roomPwd);
dest.writeString(roomTag);
dest.writeString(sortName); dest.writeString(sortName);
dest.writeString(roomTag);
dest.writeInt(tagId); dest.writeInt(tagId);
dest.writeString(tagPict); dest.writeString(tagPict);
dest.writeInt(onlineNum); dest.writeInt(onlineNum);
@@ -266,6 +291,9 @@ public class RoomInfo implements Parcelable,Serializable {
dest.writeLong(worldId); dest.writeLong(worldId);
dest.writeByte((byte) (showPkBeginTime ? 1 : 0)); dest.writeByte((byte) (showPkBeginTime ? 1 : 0));
dest.writeLong(pkBeginTime); dest.writeLong(pkBeginTime);
dest.writeLong(pkMatchStartTime);
dest.writeByte((byte) (hasWishGiftPermit ? 1 : 0));
dest.writeByte((byte) (hasOpenWishGift ? 1 : 0));
dest.writeByte((byte) (showGiftValue ? 1 : 0)); dest.writeByte((byte) (showGiftValue ? 1 : 0));
dest.writeInt(hideFlag); dest.writeInt(hideFlag);
dest.writeInt(closeScreenFlag); dest.writeInt(closeScreenFlag);
@@ -286,18 +314,10 @@ public class RoomInfo implements Parcelable,Serializable {
public int describeContents() { public int describeContents() {
return 0; return 0;
} }
// /**
public static final Creator<RoomInfo> CREATOR = new Creator<RoomInfo>() { // * 房间角标
@Override // */
public RoomInfo createFromParcel(Parcel in) { // private String badge;
return new RoomInfo(in);
}
@Override
public RoomInfo[] newArray(int size) {
return new RoomInfo[size];
}
};
/** /**
* 获取房间类型,目前是用于统计 * 获取房间类型,目前是用于统计
@@ -311,62 +331,18 @@ public class RoomInfo implements Parcelable,Serializable {
return "普通房"; return "普通房";
} }
/** public static class BackgroundBean implements Parcelable, Serializable {
* 是否开启礼物值目前ktv房cp房都不支持 public static final Creator<BackgroundBean> CREATOR = new Creator<BackgroundBean>() {
*/ @Override
private boolean showGiftValue; public BackgroundBean createFromParcel(Parcel in) {
return new BackgroundBean(in);
}
/** @Override
* 0.不隐藏; 1.全局+排行榜 public BackgroundBean[] newArray(int size) {
*/ return new BackgroundBean[size];
private int hideFlag; }
};
/**
* 公屏操作人0.房主或管理员1.超管
*/
private int closeScreenFlag;
private boolean redEnvelopeOpen;
/**
* COMMUNICATING(1, "交谈"),
* PICK(2, "心动选人"),
* PUBLISH(3, "公布心动"),
* FINISH(4, "结束"),
*/
private String blindDateState = "";
private long blindDateVipUid;
private boolean canOpenBlindDate;
/**
* {@link RoomAudioSdkType}
*/
private String audioSdkType;
private String trtcSig;
private boolean isReselect;
private long mgId;
private String mgName;
private int mgMicNum;
private long clearScreenTime;
// /**
// * 房间角标
// */
// private String badge;
public RoomInfo() {
}
public static class BackgroundBean implements Parcelable{
/** /**
* id : 4 * id : 4
* name : 背景名称ABC * name : 背景名称ABC
@@ -403,7 +379,6 @@ public class RoomInfo implements Parcelable,Serializable {
private int status; private int status;
private int uid; private int uid;
protected BackgroundBean(Parcel in) { protected BackgroundBean(Parcel in) {
id = in.readInt(); id = in.readInt();
name = in.readString(); name = in.readString();
@@ -443,18 +418,6 @@ public class RoomInfo implements Parcelable,Serializable {
dest.writeInt(uid); dest.writeInt(uid);
} }
public static final Creator<BackgroundBean> CREATOR = new Creator<BackgroundBean>() {
@Override
public BackgroundBean createFromParcel(Parcel in) {
return new BackgroundBean(in);
}
@Override
public BackgroundBean[] newArray(int size) {
return new BackgroundBean[size];
}
};
public int getId() { public int getId() {
return id; return id;
} }