增加星级厨房飘屏
This commit is contained in:
BIN
app/src/main/assets/svga/kitchen_notify.svga
Normal file
BIN
app/src/main/assets/svga/kitchen_notify.svga
Normal file
Binary file not shown.
@@ -1,6 +1,7 @@
|
||||
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_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_SUB_BOX_ME;
|
||||
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.SimpleItemAnimator;
|
||||
|
||||
import com.mango.core.im.custom.bean.RoomKitchenAttachment;
|
||||
import com.mango.core.im.custom.bean.WishListAttachment;
|
||||
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.common.ui.span.RadiusBackgroundSpan;
|
||||
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) {
|
||||
setWishListComplete(chatRoomMessage, tvContent);
|
||||
}
|
||||
} else if (first == CUSTOM_MSG_KITCHEN) {
|
||||
setKitchenMsg(chatRoomMessage, tvContent);
|
||||
} else {
|
||||
tvContent.setTextColor(Color.WHITE);
|
||||
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")
|
||||
private void setGiftCompoundMsg(ChatRoomMessage chatRoomMessage, TextView tvContent) {
|
||||
if (chatRoomMessage.getAttachment() instanceof GiftCompoundAttachment) {
|
||||
@@ -1000,17 +1016,17 @@ public class MessageView extends FrameLayout {
|
||||
GiftCompoundMsgBean msgInfo = giftCompoundAttachment.getMsgBean();
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent);
|
||||
text.append(
|
||||
msgInfo.getNick(),
|
||||
new ForegroundColorSpan(roomTipNickColor),
|
||||
new OriginalDrawStatusClickSpan() {
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
if (clickConsumer != null) {
|
||||
Single.just(String.valueOf(msgInfo.getUid())).subscribe(clickConsumer);
|
||||
}
|
||||
}
|
||||
msgInfo.getNick(),
|
||||
new ForegroundColorSpan(roomTipNickColor),
|
||||
new OriginalDrawStatusClickSpan() {
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
if (clickConsumer != null) {
|
||||
Single.just(String.valueOf(msgInfo.getUid())).subscribe(clickConsumer);
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
.append(msgInfo.getMsg(), new ForegroundColorSpan(whiteColor))
|
||||
.append(msgInfo.getGiftName(), new ForegroundColorSpan(roomTipNickColor));
|
||||
tvContent.setText(text.build());
|
||||
@@ -1143,15 +1159,15 @@ public class MessageView extends FrameLayout {
|
||||
case CustomAttachment.CUSTOM_MSG_SUB_DATING_PUBLISH_LIKE:
|
||||
if (notifyInfo.getHasSelectUser()) {
|
||||
text.append(notifyInfo.getNickname(), new ForegroundColorSpan(roomTipNickColor),
|
||||
new OriginalDrawStatusClickSpan() {
|
||||
new OriginalDrawStatusClickSpan() {
|
||||
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
if (clickConsumer != null) {
|
||||
Single.just(String.valueOf(notifyInfo.getUid())).subscribe(clickConsumer);
|
||||
}
|
||||
}
|
||||
})
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
if (clickConsumer != null) {
|
||||
Single.just(String.valueOf(notifyInfo.getUid())).subscribe(clickConsumer);
|
||||
}
|
||||
}
|
||||
})
|
||||
.append(" 的心动对象是 ", new ForegroundColorSpan(whiteColor))
|
||||
.append(notifyInfo.getTargetNickname(), new ForegroundColorSpan(roomTipNickColor),
|
||||
new OriginalDrawStatusClickSpan() {
|
||||
@@ -1165,15 +1181,15 @@ public class MessageView extends FrameLayout {
|
||||
});
|
||||
} else {
|
||||
text.append(notifyInfo.getNickname(), new ForegroundColorSpan(roomTipNickColor),
|
||||
new OriginalDrawStatusClickSpan() {
|
||||
new OriginalDrawStatusClickSpan() {
|
||||
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
if (clickConsumer != null) {
|
||||
Single.just(String.valueOf(notifyInfo.getUid())).subscribe(clickConsumer);
|
||||
}
|
||||
}
|
||||
})
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
if (clickConsumer != null) {
|
||||
Single.just(String.valueOf(notifyInfo.getUid())).subscribe(clickConsumer);
|
||||
}
|
||||
}
|
||||
})
|
||||
.append(" 未选择心动对象", new ForegroundColorSpan(whiteColor));
|
||||
}
|
||||
break;
|
||||
@@ -1431,15 +1447,15 @@ public class MessageView extends FrameLayout {
|
||||
|
||||
isHaveInTeam = true;
|
||||
text.append(value.getNick(), new ForegroundColorSpan(roomTipColor),
|
||||
new OriginalDrawStatusClickSpan() {
|
||||
new OriginalDrawStatusClickSpan() {
|
||||
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
if (clickConsumer != null) {
|
||||
Single.just(value.getUid()).subscribe(clickConsumer);
|
||||
}
|
||||
}
|
||||
})
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
if (clickConsumer != null) {
|
||||
Single.just(value.getUid()).subscribe(clickConsumer);
|
||||
}
|
||||
}
|
||||
})
|
||||
.append("进入");
|
||||
if (value.getGroupType() == PKTeamInfo.TEAM_RED) {
|
||||
text.append("红队", new ForegroundColorSpan(tvContent.getResources().getColor(R.color.color_FB3D74)))
|
||||
@@ -1464,7 +1480,7 @@ public class MessageView extends FrameLayout {
|
||||
RoomPkData roomPkData = attachment.getRoomPkData();
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
.append(String.format(Locale.getDefault(), "管理员发起房间PK,本次PK时间为 %s 秒,获得",
|
||||
roomPkData.getDuration()),
|
||||
roomPkData.getDuration()),
|
||||
new ForegroundColorSpan(whiteColor));
|
||||
switch (roomPkData.getVoteMode()) {
|
||||
case RoomPkData.VOTE_MODE_GIFT:
|
||||
@@ -1491,7 +1507,7 @@ public class MessageView extends FrameLayout {
|
||||
RoomPkData roomPkData = attachment.getRoomPkData();
|
||||
SpannableBuilder text = new SpannableBuilder(textView)
|
||||
.append(String.format(Locale.getDefault(),
|
||||
"PK开始啦!本次PK时间 %s 秒,快给喜欢的选手投票吧!", roomPkData.getDuration()),
|
||||
"PK开始啦!本次PK时间 %s 秒,快给喜欢的选手投票吧!", roomPkData.getDuration()),
|
||||
new ForegroundColorSpan(greyColor));
|
||||
textView.setText(text.build());
|
||||
}
|
||||
@@ -1500,7 +1516,7 @@ public class MessageView extends FrameLayout {
|
||||
RoomPkData roomPkData = attachment.getRoomPkData();
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent)
|
||||
.append(String.format(Locale.getDefault(), "管理员重新开始房间PK,本次PK时间为 %s 秒,获得",
|
||||
roomPkData.getDuration()),
|
||||
roomPkData.getDuration()),
|
||||
new ForegroundColorSpan(whiteColor));
|
||||
switch (roomPkData.getVoteMode()) {
|
||||
case RoomPkData.VOTE_MODE_GIFT:
|
||||
@@ -1534,8 +1550,8 @@ public class MessageView extends FrameLayout {
|
||||
text.append("平局!\n", new ForegroundColorSpan(whiteColor));
|
||||
if (blueTeam != null && redTeam != null) {
|
||||
text.append(String.format(Locale.getDefault(), "PK值 %s : %s",
|
||||
FormatUtils.formatPKValue(blueTeam.getScore()),
|
||||
FormatUtils.formatPKValue(redTeam.getScore())),
|
||||
FormatUtils.formatPKValue(blueTeam.getScore()),
|
||||
FormatUtils.formatPKValue(redTeam.getScore())),
|
||||
new ForegroundColorSpan(whiteColor));
|
||||
|
||||
UserInfo redProtector = redTeam.getProtector();
|
||||
@@ -1545,14 +1561,14 @@ public class MessageView extends FrameLayout {
|
||||
break;
|
||||
}
|
||||
text.append(String.format(Locale.getDefault(), "\n蓝队守护者:%s \n", blueProtector.getNick()),
|
||||
new ForegroundColorSpan(whiteColor))
|
||||
new ForegroundColorSpan(whiteColor))
|
||||
.append(String.format(Locale.getDefault(), "蓝队守护值:%s \n",
|
||||
FormatUtils.formatPKValue(blueTeam.getProtecScore())),
|
||||
FormatUtils.formatPKValue(blueTeam.getProtecScore())),
|
||||
new ForegroundColorSpan(whiteColor))
|
||||
.append(String.format(Locale.getDefault(), "红队守护者:%s \n", redProtector.getNick()),
|
||||
new ForegroundColorSpan(whiteColor))
|
||||
.append(String.format(Locale.getDefault(), "红队守护值:%s",
|
||||
FormatUtils.formatPKValue(redTeam.getProtecScore())),
|
||||
FormatUtils.formatPKValue(redTeam.getProtecScore())),
|
||||
new ForegroundColorSpan(whiteColor));
|
||||
}
|
||||
break;
|
||||
@@ -1561,21 +1577,21 @@ public class MessageView extends FrameLayout {
|
||||
text.append("蓝队胜利!\n", new ForegroundColorSpan(whiteColor));
|
||||
if (blueTeam != null && redTeam != null) {
|
||||
text.append(String.format(Locale.getDefault(), "PK值 %s : %s \n",
|
||||
FormatUtils.formatPKValue(blueTeam.getScore()),
|
||||
FormatUtils.formatPKValue(redTeam.getScore())),
|
||||
FormatUtils.formatPKValue(blueTeam.getScore()),
|
||||
FormatUtils.formatPKValue(redTeam.getScore())),
|
||||
new ForegroundColorSpan(whiteColor));
|
||||
|
||||
UserInfo blueProtector = blueTeam.getProtector();
|
||||
if (blueProtector == null) {
|
||||
text.append(String.format(Locale.getDefault(), "胜利方战斗值:%s",
|
||||
FormatUtils.formatPKValue(blueTeam.getScore())),
|
||||
FormatUtils.formatPKValue(blueTeam.getScore())),
|
||||
new ForegroundColorSpan(whiteColor));
|
||||
|
||||
} else {
|
||||
text.append(String.format(Locale.getDefault(), "胜方守护者:%s \n", blueProtector.getNick()),
|
||||
new ForegroundColorSpan(whiteColor))
|
||||
new ForegroundColorSpan(whiteColor))
|
||||
.append(String.format(Locale.getDefault(), "胜方守护值:%s",
|
||||
FormatUtils.formatPKValue(blueTeam.getProtecScore())),
|
||||
FormatUtils.formatPKValue(blueTeam.getProtecScore())),
|
||||
new ForegroundColorSpan(whiteColor));
|
||||
}
|
||||
}
|
||||
@@ -1585,20 +1601,20 @@ public class MessageView extends FrameLayout {
|
||||
text.append("红队胜利!\n", new ForegroundColorSpan(whiteColor));
|
||||
if (blueTeam != null && redTeam != null) {
|
||||
text.append(String.format(Locale.getDefault(), "PK值 %s : %s \n",
|
||||
FormatUtils.formatPKValue(redTeam.getScore()),
|
||||
FormatUtils.formatPKValue(blueTeam.getScore())),
|
||||
FormatUtils.formatPKValue(redTeam.getScore()),
|
||||
FormatUtils.formatPKValue(blueTeam.getScore())),
|
||||
new ForegroundColorSpan(whiteColor));
|
||||
|
||||
UserInfo redProtector = redTeam.getProtector();
|
||||
if (redProtector == null) {
|
||||
text.append(String.format(Locale.getDefault(), "胜利方战斗值:%s",
|
||||
FormatUtils.formatPKValue(redTeam.getScore())),
|
||||
FormatUtils.formatPKValue(redTeam.getScore())),
|
||||
new ForegroundColorSpan(whiteColor));
|
||||
} else {
|
||||
text.append(String.format(Locale.getDefault(), "红队守护者:%s \n", redProtector.getNick()),
|
||||
new ForegroundColorSpan(whiteColor))
|
||||
new ForegroundColorSpan(whiteColor))
|
||||
.append(String.format(Locale.getDefault(), "红队守护值:%s",
|
||||
FormatUtils.formatPKValue(redTeam.getProtecScore())),
|
||||
FormatUtils.formatPKValue(redTeam.getProtecScore())),
|
||||
new ForegroundColorSpan(whiteColor));
|
||||
}
|
||||
|
||||
@@ -1975,11 +1991,11 @@ public class MessageView extends FrameLayout {
|
||||
String vipIcon = NobleUtil.getResource(UserInfo.VIP_ICON, chatRoomMessage);
|
||||
builder.append(vipIcon, expLevelHeight)
|
||||
.append(isOfficial ? ResourcesCompat.getDrawable(getResources(),
|
||||
R.mipmap.ic_user_official_13dp, null) : null,
|
||||
R.mipmap.ic_user_official_13dp, null) : null,
|
||||
badgeWidth, badgeHeight)
|
||||
.append(getNewUserDrawable(chatRoomMessage), badgeWidth, badgeHeight)
|
||||
.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);
|
||||
|
||||
// 官方主播认证
|
||||
@@ -2273,13 +2289,13 @@ public class MessageView extends FrameLayout {
|
||||
for (GiftReceiver targetUser : attachment.getGiftMultiReceiverInfo().getTargetUsers()) {
|
||||
text.append(targetUser.getNick(), new ForegroundColorSpan(roomTipNickColor), new OriginalDrawStatusClickSpan() {
|
||||
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
if (clickConsumer != null) {
|
||||
Single.just(targetUser.getUid() + "").subscribe(clickConsumer);
|
||||
}
|
||||
}
|
||||
})
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
if (clickConsumer != null) {
|
||||
Single.just(targetUser.getUid() + "").subscribe(clickConsumer);
|
||||
}
|
||||
}
|
||||
})
|
||||
.append(",");
|
||||
}
|
||||
Editable msg = text.builder;
|
||||
@@ -2353,13 +2369,13 @@ public class MessageView extends FrameLayout {
|
||||
for (MagicReceiver targetUser : magicMultiReceiverInfo.getTargetUsers()) {
|
||||
text.append(targetUser.getNick(), new ForegroundColorSpan(roomTipNickColor), new OriginalDrawStatusClickSpan() {
|
||||
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
if (clickConsumer != null) {
|
||||
Single.just(targetUser.getUid() + "").subscribe(clickConsumer);
|
||||
}
|
||||
}
|
||||
})
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
if (clickConsumer != null) {
|
||||
Single.just(targetUser.getUid() + "").subscribe(clickConsumer);
|
||||
}
|
||||
}
|
||||
})
|
||||
.append(",");
|
||||
}
|
||||
Editable msg = text.builder;
|
||||
@@ -2556,14 +2572,14 @@ public class MessageView extends FrameLayout {
|
||||
mMessageAdapter.notifyItemChanged(position);
|
||||
long targetUid = JavaUtil.str2long(chatRoomMessage.getFromAccount());
|
||||
Single.zip(AvRoomModel.get().getWelcomeConfig(targetUid),
|
||||
UserModel.get().getUserInfo(targetUid), (roomWelcomeConfig, info) -> {
|
||||
WelcomeInfo welcomeInfo = new WelcomeInfo();
|
||||
welcomeInfo.setContent(roomWelcomeConfig.getMsg());
|
||||
welcomeInfo.setTargetUid(targetUid);
|
||||
welcomeInfo.setTargetNick(info.getNick());
|
||||
welcomeInfo.setFans(roomWelcomeConfig.isFans());
|
||||
return welcomeInfo;
|
||||
})
|
||||
UserModel.get().getUserInfo(targetUid), (roomWelcomeConfig, info) -> {
|
||||
WelcomeInfo welcomeInfo = new WelcomeInfo();
|
||||
welcomeInfo.setContent(roomWelcomeConfig.getMsg());
|
||||
welcomeInfo.setTargetUid(targetUid);
|
||||
welcomeInfo.setTargetNick(info.getNick());
|
||||
welcomeInfo.setFans(roomWelcomeConfig.isFans());
|
||||
return welcomeInfo;
|
||||
})
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.flatMap((Function<WelcomeInfo, SingleSource<ChatRoomMessage>>) welcomeInfo -> {
|
||||
WelcomeAttachment attachment = new WelcomeAttachment();
|
||||
@@ -2720,14 +2736,14 @@ public class MessageView extends FrameLayout {
|
||||
SpannableBuilder text = new SpannableBuilder(tvContent);
|
||||
addCommonTag(chatRoomMessage, text, tvContent);
|
||||
text.append(extension == null ? "我" : RegexUtil.getPrintableString(extension.getSenderNick()),
|
||||
new ForegroundColorSpan(greyColor),
|
||||
new OriginalDrawStatusClickSpan() {
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
Single.just(String.valueOf(chatRoomMessage.getFromAccount()))
|
||||
.doOnSuccess(clickConsumer).subscribe();
|
||||
}
|
||||
})
|
||||
new ForegroundColorSpan(greyColor),
|
||||
new OriginalDrawStatusClickSpan() {
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
Single.just(String.valueOf(chatRoomMessage.getFromAccount()))
|
||||
.doOnSuccess(clickConsumer).subscribe();
|
||||
}
|
||||
})
|
||||
.append(":" + welcomeInfo.getLastConent(), new ForegroundColorSpan(whiteColor))
|
||||
.append(welcomeInfo.getTargetNick(), new ForegroundColorSpan(roomTipNickColor),
|
||||
new OriginalDrawStatusClickSpan() {
|
||||
|
@@ -52,6 +52,9 @@ import com.mango.core.super_admin.util.SuperAdminUtil
|
||||
import com.mango.core.user.UserModel
|
||||
import com.mango.core.user.bean.UserInfo
|
||||
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 io.reactivex.Observable
|
||||
import io.reactivex.ObservableEmitter
|
||||
@@ -116,12 +119,19 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
private val messagesGiftCompound: MutableList<ChatRoomMessage> by lazy { ArrayList() }
|
||||
|
||||
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 val messagesRadishSVGA: MutableList<ChatRoomMessage> by lazy { java.util.ArrayList() }
|
||||
private val messagesRadishSVGA: MutableList<ChatRoomMessage> by lazy { ArrayList() }
|
||||
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 isHideCarEffect = false
|
||||
@@ -216,6 +226,8 @@ class RoomEffectView @JvmOverloads constructor(
|
||||
binding.svgaWishList.startAnimation()
|
||||
}
|
||||
}
|
||||
RoomEvent.KITCHEN_ROOM -> addKitchenNotify(roomEvent.chatRoomMessage)
|
||||
RoomEvent.KITCHEN_ALL_ROOM -> addKitchenNotifyBySVGA(roomEvent.chatRoomMessage)
|
||||
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
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加跑马灯
|
||||
* 以及反射一些参数影响跑马灯
|
||||
|
43
app/src/main/java/com/mango/moshen/utils/MsgBuilder.kt
Normal file
43
app/src/main/java/com/mango/moshen/utils/MsgBuilder.kt
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
BIN
app/src/main/res/drawable-xhdpi/bg_kitchen_notice.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/bg_kitchen_notice.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 60 KiB |
@@ -70,6 +70,20 @@
|
||||
app:layout_constraintDimensionRatio="75:11"
|
||||
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
|
||||
android:id="@+id/fl_box_notify"
|
||||
android:layout_width="match_parent"
|
||||
|
19
app/src/main/res/layout/layout_room_kitchen_notify.xml
Normal file
19
app/src/main/res/layout/layout_room_kitchen_notify.xml
Normal 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="哈哈哈哈哈哈啊哈哈啊哈哈哈哈哈哈哈哈哈哈哈" />
|
Reference in New Issue
Block a user