diff --git a/app/src/main/assets/svga/svga_notify_h5.svga b/app/src/main/assets/svga/svga_notify_h5.svga new file mode 100644 index 000000000..32784b04f Binary files /dev/null and b/app/src/main/assets/svga/svga_notify_h5.svga differ diff --git a/app/src/main/java/com/yizhuan/erban/avroom/activity/AVRoomActivity.java b/app/src/main/java/com/yizhuan/erban/avroom/activity/AVRoomActivity.java index 15840365c..cce55250d 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/activity/AVRoomActivity.java +++ b/app/src/main/java/com/yizhuan/erban/avroom/activity/AVRoomActivity.java @@ -99,6 +99,7 @@ import com.yizhuan.xchat_android_core.gift.bean.GiftInfo; import com.yizhuan.xchat_android_core.gift.bean.LuckyBagNoticeInfo; import com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.FairyMsgAttachment; +import com.yizhuan.xchat_android_core.im.custom.bean.NotifyH5Attachment; import com.yizhuan.xchat_android_core.im.custom.bean.RoomBoxPrizeAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.RoomBoxPrizeInfo; import com.yizhuan.xchat_android_core.im.custom.bean.RoomLuckySeaAttachment; @@ -1260,6 +1261,19 @@ public class AVRoomActivity extends BaseMvpActivity { + addPlayNotify(roomEvent.event, roomEvent.chatRoomMessage) + } + RoomEvent.RECEIVE_ROOM_LUCKY_BAG_NOTICE, RoomEvent.RECEIVE_SERVICE_LUCKY_BAG_NOTICE ->//全服福袋 //廳內福袋 addPlayNotify(roomEvent.event, roomEvent.chatRoomMessage) @@ -278,167 +281,195 @@ class RoomEffectView @JvmOverloads constructor( .observeOn(AndroidSchedulers.mainThread()) .takeWhile { messagesPlay.size > 0 && !mContext.isDestroyed() } .subscribe { - if (binding.flPlayNotify.childCount == 0) { - when (messagesPlay[0].event) { - RoomEvent.BOX_NOTIFY -> {//寻爱 - if ((mContext as AVRoomActivity).isTopActivity) { - isPlayAnim = true - val isPlay = onPlayAnimCallback?.invoke() ?: false - if (isPlay) { - margin( - binding.clNotify, - 0, - UIUtil.dip2px(context, 180.0), - 0, - 0 - ) - } else { - margin( - binding.clNotify, - 0, - UIUtil.dip2px(context, 60.0), - 0, - 0 - ) - } - showBoxNotify( - messagesPlay.removeAt(0) + if (binding.flPlayNotify.childCount != 0) { + return@subscribe + } + + when (messagesPlay[0].event) { + RoomEvent.BOX_NOTIFY -> {//寻爱 + if ((mContext as AVRoomActivity).isTopActivity) { + isPlayAnim = true + val isPlay = onPlayAnimCallback?.invoke() ?: false + if (isPlay) { + margin( + binding.clNotify, + 0, + UIUtil.dip2px(context, 180.0), + 0, + 0 + ) + } else { + margin( + binding.clNotify, + 0, + UIUtil.dip2px(context, 60.0), + 0, + 0 ) } + showBoxNotify( + messagesPlay.removeAt(0) + ) } + } - RoomEvent.BOX_NOTIFY_SVGA -> {//寻爱 - if ((mContext as AVRoomActivity).isTopActivity) { - isPlayAnim = true - val isPlay = onPlayAnimCallback?.invoke() ?: false - if (isPlay) { - margin( - binding.clNotify, - 0, - UIUtil.dip2px(context, 180.0), - 0, - 0 - ) - } else { - margin( - binding.clNotify, - 0, - UIUtil.dip2px(context, 60.0), - 0, - 0 - ) - } - showBoxNotifyBySVGA(messagesPlay.removeAt(0)) - } - } - - RoomEvent.TAROT_NOTIFY -> { - if ((mContext as AVRoomActivity).isTopActivity) { - isPlayAnim = true - val isPlay = onPlayAnimCallback?.invoke() ?: false - if (isPlay) { - margin( - binding.clNotify, - 0, - UIUtil.dip2px(context, 180.0), - 0, - 0 - ) - } else { - margin( - binding.clNotify, - 0, - UIUtil.dip2px(context, 60.0), - 0, - 0 - ) - } - showTarotNotify( - messagesPlay.removeAt(0) + RoomEvent.BOX_NOTIFY_SVGA -> {//寻爱 + if ((mContext as AVRoomActivity).isTopActivity) { + isPlayAnim = true + val isPlay = onPlayAnimCallback?.invoke() ?: false + if (isPlay) { + margin( + binding.clNotify, + 0, + UIUtil.dip2px(context, 180.0), + 0, + 0 + ) + } else { + margin( + binding.clNotify, + 0, + UIUtil.dip2px(context, 60.0), + 0, + 0 ) } + showBoxNotifyBySVGA(messagesPlay.removeAt(0)) } + } - RoomEvent.TAROT_NOTIFY_SVGA -> { - if ((mContext as AVRoomActivity).isTopActivity) { - isPlayAnim = true - val isPlay = onPlayAnimCallback?.invoke() ?: false - if (isPlay) { - margin( - binding.clNotify, - 0, - UIUtil.dip2px(context, 180.0), - 0, - 0 - ) - } else { - margin( - binding.clNotify, - 0, - UIUtil.dip2px(context, 60.0), - 0, - 0 - ) - } - showTarotNotifyBySVGA(messagesPlay.removeAt(0)) - } - } - - RoomEvent.RECEIVE_ROOM_LUCKY_BAG_NOTICE, RoomEvent.RECEIVE_SERVICE_LUCKY_BAG_NOTICE -> {//福袋 + RoomEvent.TAROT_NOTIFY -> { + if ((mContext as AVRoomActivity).isTopActivity) { isPlayAnim = true val isPlay = onPlayAnimCallback?.invoke() ?: false if (isPlay) { - margin(binding.clNotify, 0, UIUtil.dip2px(context, 180.0), 0, 0) + margin( + binding.clNotify, + 0, + UIUtil.dip2px(context, 180.0), + 0, + 0 + ) } else { - margin(binding.clNotify, 0, UIUtil.dip2px(context, 60.0), 0, 0) + margin( + binding.clNotify, + 0, + UIUtil.dip2px(context, 60.0), + 0, + 0 + ) } - showLuckyBagNotify( + showTarotNotify( messagesPlay.removeAt(0) ) } + } - RoomEvent.LUCKY_SEA_GIFT_ROOM_NOTIFY -> {//星级厨房 + RoomEvent.TAROT_NOTIFY_SVGA -> { + if ((mContext as AVRoomActivity).isTopActivity) { isPlayAnim = true val isPlay = onPlayAnimCallback?.invoke() ?: false if (isPlay) { - margin(binding.clNotify, 0, UIUtil.dip2px(context, 180.0), 0, 0) + margin( + binding.clNotify, + 0, + UIUtil.dip2px(context, 180.0), + 0, + 0 + ) } else { - margin(binding.clNotify, 0, UIUtil.dip2px(context, 60.0), 0, 0) + margin( + binding.clNotify, + 0, + UIUtil.dip2px(context, 60.0), + 0, + 0 + ) } - showLuckySeaNotify( - messagesPlay.removeAt(0) - ) + showTarotNotifyBySVGA(messagesPlay.removeAt(0)) + } + } + + RoomEvent.NOTIFY_H5 -> { + if (!(mContext as AVRoomActivity).isTopActivity) { + return@subscribe } - RoomEvent.LUCKY_SEA_GIFT_SERVER_NOTIFY -> {//星级厨房 - isPlayAnim = true - val isPlay = onPlayAnimCallback?.invoke() ?: false - if (isPlay) { - margin(binding.clNotify, 0, UIUtil.dip2px(context, 180.0), 0, 0) - } else { - margin(binding.clNotify, 0, UIUtil.dip2px(context, 60.0), 0, 0) - } - showLuckySeaNotifyBySVGA( - messagesPlay.removeAt(0) - ) + isPlayAnim = true + val isPlay = onPlayAnimCallback?.invoke() ?: false + margin( + binding.clNotify, + 0, + UIUtil.dip2px(context, if (isPlay) 180.0 else 60.0), + 0, + 0 + ) + + val msg = messagesPlay.removeAt(0) + val attachment = msg.chatRoomMessage.attachment as NotifyH5Attachment + val bean = attachment.bean ?: return@subscribe + if (bean.floatingType == 0) { + showNotifyH5(bean) + } else { + showNotifyH5WithAnim(bean) } - RoomEvent.FAIRY_DRAW_GIFT_L4, - RoomEvent.FAIRY_DRAW_GIFT_L5, - RoomEvent.FAIRY_CONVERT_L1, - RoomEvent.FAIRY_CONVERT_L2, - RoomEvent.FAIRY_CONVERT_L3 -> {//夺宝 - isPlayAnim = true - val isPlay = onPlayAnimCallback?.invoke() ?: false - if (isPlay) { - margin(binding.clNotify, 0, UIUtil.dip2px(context, 180.0), 0, 0) - } else { - margin(binding.clNotify, 0, UIUtil.dip2px(context, 60.0), 0, 0) - } - showFairyNotify( - messagesPlay.removeAt(0) - ) + } + + RoomEvent.RECEIVE_ROOM_LUCKY_BAG_NOTICE, RoomEvent.RECEIVE_SERVICE_LUCKY_BAG_NOTICE -> {//福袋 + isPlayAnim = true + val isPlay = onPlayAnimCallback?.invoke() ?: false + if (isPlay) { + margin(binding.clNotify, 0, UIUtil.dip2px(context, 180.0), 0, 0) + } else { + margin(binding.clNotify, 0, UIUtil.dip2px(context, 60.0), 0, 0) } + showLuckyBagNotify( + messagesPlay.removeAt(0) + ) + } + + RoomEvent.LUCKY_SEA_GIFT_ROOM_NOTIFY -> {//星级厨房 + isPlayAnim = true + val isPlay = onPlayAnimCallback?.invoke() ?: false + if (isPlay) { + margin(binding.clNotify, 0, UIUtil.dip2px(context, 180.0), 0, 0) + } else { + margin(binding.clNotify, 0, UIUtil.dip2px(context, 60.0), 0, 0) + } + showLuckySeaNotify( + messagesPlay.removeAt(0) + ) + } + + RoomEvent.LUCKY_SEA_GIFT_SERVER_NOTIFY -> {//星级厨房 + isPlayAnim = true + val isPlay = onPlayAnimCallback?.invoke() ?: false + if (isPlay) { + margin(binding.clNotify, 0, UIUtil.dip2px(context, 180.0), 0, 0) + } else { + margin(binding.clNotify, 0, UIUtil.dip2px(context, 60.0), 0, 0) + } + showLuckySeaNotifyBySVGA( + messagesPlay.removeAt(0) + ) + } + + RoomEvent.FAIRY_DRAW_GIFT_L4, + RoomEvent.FAIRY_DRAW_GIFT_L5, + RoomEvent.FAIRY_CONVERT_L1, + RoomEvent.FAIRY_CONVERT_L2, + RoomEvent.FAIRY_CONVERT_L3 -> {//夺宝 + isPlayAnim = true + val isPlay = onPlayAnimCallback?.invoke() ?: false + if (isPlay) { + margin(binding.clNotify, 0, UIUtil.dip2px(context, 180.0), 0, 0) + } else { + margin(binding.clNotify, 0, UIUtil.dip2px(context, 60.0), 0, 0) + } + showFairyNotify( + messagesPlay.removeAt(0) + ) } } } @@ -839,11 +870,80 @@ class RoomEffectView @JvmOverloads constructor( ) } + private fun showNotifyH5(data: NotifyH5Attachment.Bean) { + val textView = LayoutInflater.from(mContext) + .inflate(R.layout.layout_notify_h5, null) as TextView + textView.text = data.content + animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify) + binding.flPlayNotify.addView(textView) + textView.startAnimation(animationPlay) + binding.flPlayNotify.postDelayed( + { + animationPlay = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify_close) + textView.startAnimation(animationPlay) + }, + SHOW_TIME.toLong() + ) + binding.flPlayNotify.postDelayed({ + binding.flPlayNotify.removeView(textView) + isPlayAnim = false + }, CLOSE_TIME.toLong()) + } + + private fun showNotifyH5WithAnim(data: NotifyH5Attachment.Bean) { + + 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.flPlayNotify.post { + binding.flPlayNotify.removeView(svgaImageView) + isPlayAnim = false + } + } + } + binding.flPlayNotify.addView(svgaImageView) + shareParser().decodeFromAssets( + "svga/svga_notify_h5.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( + data.content, + 0, + data.content.length, + textPaint, + 0, + Layout.Alignment.ALIGN_CENTER, + 1.0f, + 0.0f, + false + ), "bg" + ) + val drawable = SVGADrawable(videoItem, dynamicEntity) + svgaImageView.setImageDrawable(drawable) + svgaImageView.stepToFrame(0, true) + } + + override fun onError() {} + }, + null + ) + } + private fun showTarotNotify(roomPlayBean: RoomPlayBean) { val chatRoomMessage = roomPlayBean.chatRoomMessage val attachment = chatRoomMessage.attachment as TarotAttachment val textView = - LayoutInflater.from(mContext).inflate(R.layout.layout_notify_tarot_intermediate, null) as TextView + LayoutInflater.from(mContext) + .inflate(R.layout.layout_notify_tarot_intermediate, null) as TextView val string = mContext.getString( R.string.avroom_widget_roomeffectview_026, StringUtils.abbreviate(RegexUtil.getPrintableString(attachment.tarotMsgBean.nick), 8), @@ -933,32 +1033,36 @@ class RoomEffectView @JvmOverloads constructor( } } binding.flPlayNotify.addView(svgaImageView) - shareParser().decodeFromAssets("svga/svga_tarot_senior.svga", object : SVGAParser.ParseCompletion { - override fun onComplete(videoItem: SVGAVideoEntity) { - val dynamicEntity = SVGADynamicEntity() - val textPaint = TextPaint() - textPaint.color = Color.WHITE //字體顏色 - textPaint.textSize = 22f - dynamicEntity.setDynamicText( - StaticLayout( - text, - 0, - text.length, - textPaint, - 0, - Layout.Alignment.ALIGN_CENTER, - 1.0f, - 0.0f, - false - ), "taxt" - ) - val drawable = SVGADrawable(videoItem, dynamicEntity) - svgaImageView.setImageDrawable(drawable) - svgaImageView.stepToFrame(0, true) - } + shareParser().decodeFromAssets( + "svga/svga_tarot_senior.svga", + object : SVGAParser.ParseCompletion { + override fun onComplete(videoItem: SVGAVideoEntity) { + val dynamicEntity = SVGADynamicEntity() + val textPaint = TextPaint() + textPaint.color = Color.WHITE //字體顏色 + textPaint.textSize = 22f + dynamicEntity.setDynamicText( + StaticLayout( + text, + 0, + text.length, + textPaint, + 0, + Layout.Alignment.ALIGN_CENTER, + 1.0f, + 0.0f, + false + ), "taxt" + ) + val drawable = SVGADrawable(videoItem, dynamicEntity) + svgaImageView.setImageDrawable(drawable) + svgaImageView.stepToFrame(0, true) + } - override fun onError() {} - }, null) + override fun onError() {} + }, + null + ) } private fun showBoxNotifyBySVGA(roomPlayBean: RoomPlayBean) { diff --git a/app/src/main/res/drawable-xhdpi/bg_notify_h5.webp b/app/src/main/res/drawable-xhdpi/bg_notify_h5.webp new file mode 100644 index 000000000..789d09f16 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/bg_notify_h5.webp differ diff --git a/app/src/main/res/layout/layout_notify_h5.xml b/app/src/main/res/layout/layout_notify_h5.xml new file mode 100644 index 000000000..0018a20e0 --- /dev/null +++ b/app/src/main/res/layout/layout_notify_h5.xml @@ -0,0 +1,17 @@ + + \ No newline at end of file diff --git a/app/src/module_treasure_box/res/layout/treasure_box_dialog_love_lack.xml b/app/src/module_treasure_box/res/layout/treasure_box_dialog_love_lack.xml index 186da43ad..130e3df3b 100644 --- a/app/src/module_treasure_box/res/layout/treasure_box_dialog_love_lack.xml +++ b/app/src/module_treasure_box/res/layout/treasure_box_dialog_love_lack.xml @@ -97,7 +97,6 @@ android:layout_height="20dp" android:layout_marginStart="@dimen/dp_4" android:layout_marginTop="@dimen/dp_4" - android:onClick="@{click}" android:src="@drawable/treasure_box_sub_normal" /> diff --git a/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/IMNetEaseManager.java b/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/IMNetEaseManager.java index 0755a3691..a5185a147 100644 --- a/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/IMNetEaseManager.java +++ b/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/IMNetEaseManager.java @@ -1360,6 +1360,8 @@ public final class IMNetEaseManager { || second == CUSTOM_MESS_TAROT_SENIOR_PRIZE_WINNING) { noticeTarot(msg, second); } + case CUSTOM_MSG_NOTIFY_H5: + noticeH5(msg); default: break; } @@ -3338,6 +3340,13 @@ public final class IMNetEaseManager { .setChatRoomMessage(msg)); } + private void noticeH5(ChatRoomMessage msg) { + getChatRoomEventObservable() + .onNext(new RoomEvent() + .setEvent(RoomEvent.NOTIFY_H5) + .setChatRoomMessage(msg)); + } + private void noticeRadish(ChatRoomMessage msg, int second) { int event = second == CUSTOM_MSG_SUB_RADISH_ALL_ROOM_NOTIFY ? RoomEvent.RADISH_NOTIFY : RoomEvent.RADISH_NOTIFY_SVGA; getChatRoomEventObservable() diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachParser.java b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachParser.java index 57a6c1492..2d4bfc057 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachParser.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachParser.java @@ -643,6 +643,9 @@ public class CustomAttachParser implements MsgAttachmentParser { attachment = new FairyMsgAttachment(first, second); } break; + case CustomAttachment.CUSTOM_MSG_NOTIFY_H5: + attachment = new NotifyH5Attachment(second); + break; default: LogUtils.e(ResUtil.getString(R.string.custom_bean_customattachparser_01) + first + " second=" + second); break; diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachment.java b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachment.java index 06c9e0c75..bdac1f714 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachment.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/CustomAttachment.java @@ -453,6 +453,21 @@ public class CustomAttachment implements MsgAttachment { public static final int CUSTOM_MSG_SUB_CONVERT_L2 = 9732; // 召唤L2 public static final int CUSTOM_MSG_SUB_CONVERT_L3 = 9733; // 召唤L3 + /** + * H5活动通用飘屏 + */ + public static final int CUSTOM_MSG_NOTIFY_H5 = 100; + + /** + * H5活动通用飘屏 - 房间 + */ + public static final int CUSTOM_MSG_NOTIFY_H5_SUB_ROOM = 1001; + + /** + * H5活动通用飘屏 - 全服 + */ + public static final int CUSTOM_MSG_NOTIFY_H5_SUB_WHOLE_SERVICE = 1002; + /** * 自定义消息附件的类型,根据该字段区分不同的自定义消息 */ diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/NotifyH5Attachment.kt b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/NotifyH5Attachment.kt new file mode 100644 index 000000000..dbd1b0826 --- /dev/null +++ b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/NotifyH5Attachment.kt @@ -0,0 +1,22 @@ +package com.yizhuan.xchat_android_core.im.custom.bean + +import com.alibaba.fastjson.JSONObject +import com.google.gson.Gson + +class NotifyH5Attachment(second: Int) : CustomAttachment(CUSTOM_MSG_NOTIFY_H5, second) { + var bean: Bean? = null + override fun parseData(data: JSONObject) { + bean = Gson().fromJson(data.toJSONString(), Bean::class.java) + } + + data class Bean( + val roomUid: Int, + + /** + * 飘屏类型 0 房间静态飘屏 1 全服动态飘屏 + */ + val floatingType: Int, + + val content: String, + ) +} \ No newline at end of file diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/manager/RoomEvent.java b/core/src/main/java/com/yizhuan/xchat_android_core/manager/RoomEvent.java index ddadf926f..7aefa207a 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/manager/RoomEvent.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/manager/RoomEvent.java @@ -261,6 +261,7 @@ public class RoomEvent { public static final int TAROT_NOTIFY = 107; public static final int TAROT_NOTIFY_SVGA = 108; + public static final int NOTIFY_H5 = 109; private int event = NONE; private int micPosition = Integer.MIN_VALUE;