diff --git a/app/src/main/assets/svga/lucky_sea_notify.svga b/app/src/main/assets/svga/lucky_sea_notify.svga new file mode 100644 index 000000000..8a2c4a484 Binary files /dev/null and b/app/src/main/assets/svga/lucky_sea_notify.svga differ diff --git a/app/src/main/java/com/yizhuan/erban/avroom/fragment/BaseRoomFragment.kt b/app/src/main/java/com/yizhuan/erban/avroom/fragment/BaseRoomFragment.kt index 502fce1b6..d248fb1b8 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/fragment/BaseRoomFragment.kt +++ b/app/src/main/java/com/yizhuan/erban/avroom/fragment/BaseRoomFragment.kt @@ -20,7 +20,6 @@ import android.widget.RelativeLayout import android.widget.TextView import androidx.annotation.CallSuper import androidx.core.content.ContextCompat -import androidx.core.view.isVisible import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.chad.library.adapter.base.BaseQuickAdapter @@ -470,7 +469,10 @@ open class BaseRoomFragment?> : bannerAdapter.notifyDataSetChanged() bannerAdapter.setRoomActClickListener(RoomActClickListener { url -> StatisticManager.Instance() - .onEvent(StatisticsProtocol.EVENT_ROOM_PROMOTE_CLICK, ResUtil.getString(R.string.avroom_fragment_baseroomfragment_03)) + .onEvent( + StatisticsProtocol.EVENT_ROOM_PROMOTE_CLICK, + ResUtil.getString(R.string.avroom_fragment_baseroomfragment_03) + ) DialogWebViewActivity.start(mContext, url) }) @@ -628,13 +630,19 @@ open class BaseRoomFragment?> : when (v.id) { R.id.input_send -> { StatisticManager.Instance() - .onEvent(StatisticsProtocol.EVENT_ROOM_CHAT_CLICK, ResUtil.getString(R.string.avroom_fragment_baseroomfragment_05)) + .onEvent( + StatisticsProtocol.EVENT_ROOM_CHAT_CLICK, + ResUtil.getString(R.string.avroom_fragment_baseroomfragment_05) + ) sendMsg() } R.id.contribute_list -> { DialogWebViewActivity.start(mContext, UriProvider.getRoomRanking()) StatisticManager.Instance() - .onEvent(StatisticsProtocol.EVENT_MP_ROOM_RANKING_LIST_CLICK, ResUtil.getString(R.string.avroom_fragment_baseroomfragment_06)) + .onEvent( + StatisticsProtocol.EVENT_MP_ROOM_RANKING_LIST_CLICK, + ResUtil.getString(R.string.avroom_fragment_baseroomfragment_06) + ) mvpPresenter?.loadRoomRank() } R.id.iv_first_charge_enter -> FirstChargeDialog.start(mContext) diff --git a/app/src/main/java/com/yizhuan/erban/avroom/widget/RoomEffectBoxView.kt b/app/src/main/java/com/yizhuan/erban/avroom/widget/RoomEffectBoxView.kt index b90168655..4fc7abced 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/widget/RoomEffectBoxView.kt +++ b/app/src/main/java/com/yizhuan/erban/avroom/widget/RoomEffectBoxView.kt @@ -30,7 +30,6 @@ import com.yizhuan.erban.avroom.activity.AVRoomActivity import com.yizhuan.erban.avroom.helper.AnimHelper import com.yizhuan.erban.common.svga.SimpleSvgaCallback import com.yizhuan.erban.databinding.LayoutRoomEffectBinding -import com.yizhuan.erban.treasure_box.activity.TreasureBoxActivity import com.yizhuan.erban.ui.utils.ImageLoadUtils import com.yizhuan.erban.ui.utils.isDestroyed import com.yizhuan.erban.ui.utils.load diff --git a/app/src/main/java/com/yizhuan/erban/avroom/widget/RoomEffectView.kt b/app/src/main/java/com/yizhuan/erban/avroom/widget/RoomEffectView.kt index 232bd479a..d02985bf9 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/widget/RoomEffectView.kt +++ b/app/src/main/java/com/yizhuan/erban/avroom/widget/RoomEffectView.kt @@ -19,6 +19,7 @@ import android.view.animation.AnimationUtils import android.widget.FrameLayout import android.widget.ImageView import android.widget.TextView +import androidx.core.content.ContextCompat import com.coorchice.library.SuperTextView import com.netease.nim.uikit.common.util.sys.ScreenUtil import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage @@ -30,11 +31,11 @@ import com.yizhuan.erban.avroom.activity.AVRoomActivity import com.yizhuan.erban.avroom.helper.AnimHelper import com.yizhuan.erban.common.svga.SimpleSvgaCallback import com.yizhuan.erban.databinding.LayoutRoomEffectBinding -import com.yizhuan.erban.treasure_box.activity.TreasureBoxActivity import com.yizhuan.erban.ui.utils.ImageLoadUtils import com.yizhuan.erban.ui.utils.isDestroyed import com.yizhuan.erban.ui.utils.load import com.yizhuan.erban.ui.utils.loadAnim +import com.yizhuan.erban.ui.webview.DialogWebViewActivity import com.yizhuan.erban.ui.widget.SimpleAnimListener import com.yizhuan.erban.ui.widget.drawgift.DrawGiftPlayHelper import com.yizhuan.erban.utils.SpannableBuilder @@ -127,6 +128,13 @@ class RoomEffectView @JvmOverloads constructor( private val drawGiftPlayHelper: DrawGiftPlayHelper by lazy { DrawGiftPlayHelper(context as Activity) } + private var animationLuckySea: Animation? = null + private var luckySeaDisposable: Disposable? = null + private val messagesLuckySea: MutableList by lazy { ArrayList() } + + private var luckySeaSVGADisposable: Disposable? = null + private val messagesLuckySeaSVGA: MutableList by lazy { ArrayList() } + private fun loopCarAnim() { if (context.isDestroyed()) return isSvgaPlaying = false @@ -151,13 +159,13 @@ class RoomEffectView @JvmOverloads constructor( if (roomEvent == null || AvRoomDataManager.get().isSelfGamePlaying) return@subscribe when (roomEvent.event) { RoomEvent.BOX_NOTIFY -> { - if((mContext as AVRoomActivity).isTopActivity) { + if ((mContext as AVRoomActivity).isTopActivity) { addBoxNotify(roomEvent.chatRoomMessage) } } RoomEvent.DATING_ALL_NOTIFY -> addDatingAllNotify(roomEvent.chatRoomMessage) RoomEvent.BOX_NOTIFY_SVGA -> { - if((mContext as AVRoomActivity).isTopActivity) { + if ((mContext as AVRoomActivity).isTopActivity) { addBoxNotifyBySVGA(roomEvent.chatRoomMessage) } } @@ -206,6 +214,12 @@ class RoomEffectView @JvmOverloads constructor( false ) } + RoomEvent.LUCKY_SEA_GIFT_ROOM_NOTIFY -> {// 深海奇缘礼物房间飘屏通知 + addLuckySeaNotify(roomEvent.chatRoomMessage) + } + RoomEvent.LUCKY_SEA_GIFT_SERVER_NOTIFY -> {// 深海奇缘礼物全服飘屏通知 + addLuckySeaNotifyBySVGA(roomEvent.chatRoomMessage) + } else -> {} } } @@ -410,6 +424,171 @@ class RoomEffectView @JvmOverloads constructor( } } + /** + * 星级厨房飘屏 + * + * @param chatRoomMessage + */ + private fun addLuckySeaNotify(chatRoomMessage: ChatRoomMessage) { + if (binding.clNotify.visibility == GONE) { + binding.clNotify.visibility = VISIBLE + } + messagesLuckySea.add(chatRoomMessage) + if (luckySeaDisposable == null || messagesLuckySea.size == 1) { + luckySeaDisposable = Observable.interval(0, PERIOD.toLong(), TimeUnit.MILLISECONDS) + .observeOn(AndroidSchedulers.mainThread()) + .takeWhile { messagesLuckySea.size > 0 } + .subscribe { + showLuckySeaNotify( + messagesLuckySea.removeAt(0) + ) + } + } + } + + private fun showLuckySeaNotify(chatRoomMessage: ChatRoomMessage) { + val attachment = chatRoomMessage.attachment as RoomLuckySeaAttachment + val bean = attachment.roomLuckySeaMsgInfo + val textView = + LayoutInflater.from(mContext) + .inflate(R.layout.layout_room_lucky_sea_notify, null) as TextView + val text = SpannableBuilder() + .append( + ResUtil.getString(R.string.congratulation), + ForegroundColorSpan(Color.WHITE) + ) + .append( + bean.nick + " ", + ForegroundColorSpan(ContextCompat.getColor(context, R.color.notice_nick)) + ) + .append( + ResUtil.getString(R.string.in_the_star_kitchen_draw), + ForegroundColorSpan(Color.WHITE) + ) + .append( + bean.itemMultiple.toString(), + ForegroundColorSpan(ContextCompat.getColor(context, R.color.color_00EAFF)) + ) + .append( + ResUtil.getString(R.string.times_reward_get), + ForegroundColorSpan(Color.WHITE) + ) + .append( + bean.diamonds.toString(), + ForegroundColorSpan(ContextCompat.getColor(context, R.color.color_00EAFF)) + ) + .append( + ResUtil.getString(R.string.diamond_point), + ForegroundColorSpan(Color.WHITE) + ) + textView.text = text.build() + animationLuckySea = AnimationUtils.loadAnimation(mContext, R.anim.anim_box_notify) + binding.flLuckySeaNotify.addView(textView) + textView.startAnimation(animationLuckySea) + binding.flLuckySeaNotify.postDelayed( + { binding.flLuckySeaNotify.removeView(textView) }, + SHOW_TIME.toLong() + ) + } + + /** + * 星级厨房飘屏 SVGA背景的 + * + * @param chatRoomMessage + */ + private fun addLuckySeaNotifyBySVGA(chatRoomMessage: ChatRoomMessage) { + if (binding.clNotify.visibility == GONE) { + binding.clNotify.visibility = VISIBLE + } + messagesLuckySeaSVGA.add(chatRoomMessage) + if (luckySeaSVGADisposable == null || messagesLuckySeaSVGA.size == 1) { + luckySeaSVGADisposable = Observable.interval(0, PERIOD.toLong(), TimeUnit.MILLISECONDS) + .observeOn(AndroidSchedulers.mainThread()) + .takeWhile { messagesLuckySeaSVGA.size > 0 } + .subscribe { + showLuckySeaNotifyBySVGA( + messagesLuckySeaSVGA.removeAt(0) + ) + } + } + } + + private fun showLuckySeaNotifyBySVGA(chatRoomMessage: ChatRoomMessage) { + val attachment = chatRoomMessage.attachment as RoomLuckySeaAttachment + val bean = attachment.roomLuckySeaMsgInfo + val text = SpannableBuilder() + .append( + ResUtil.getString(R.string.congratulation), + ForegroundColorSpan(Color.WHITE) + ) + .append( + bean.nick + " ", + ForegroundColorSpan(ContextCompat.getColor(context, R.color.notice_nick)) + ) + .append( + ResUtil.getString(R.string.in_the_star_kitchen_draw), + ForegroundColorSpan(Color.WHITE) + ) + .append( + bean.itemMultiple.toString(), + ForegroundColorSpan(ContextCompat.getColor(context, R.color.color_00EAFF)) + ) + .append( + ResUtil.getString(R.string.times_reward_get), + ForegroundColorSpan(Color.WHITE) + ) + .append( + bean.diamonds.toString(), + ForegroundColorSpan(ContextCompat.getColor(context, R.color.color_00EAFF)) + ) + .append( + ResUtil.getString(R.string.diamond_point), + ForegroundColorSpan(Color.WHITE) + ) + val svgaImageView = SVGAImageView(mContext) + svgaImageView.loops = 1 + svgaImageView.clearsAfterDetached = true + val params = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT) + svgaImageView.layoutParams = params + svgaImageView.callback = object : SimpleSvgaCallback() { + override fun onFinished() { + binding.flSvgaLuckySeaNotify.post { binding.flSvgaLuckySeaNotify.removeView(svgaImageView) } + } + } + binding.flSvgaLuckySeaNotify.addView(svgaImageView) + shareParser().decodeFromAssets("svga/lucky_sea_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" + ) + svgaImageView.setOnClickListener { + if(!TextUtils.isEmpty(bean.skipUrl)) { + DialogWebViewActivity.start(mContext, bean.skipUrl) + } + } + val drawable = SVGADrawable(videoItem, dynamicEntity) + svgaImageView.setImageDrawable(drawable) + svgaImageView.stepToFrame(0, true) + } + + override fun onError() {} + }, null) + } + /** * 幸運池飄屏 * @@ -482,7 +661,7 @@ class RoomEffectView @JvmOverloads constructor( .observeOn(AndroidSchedulers.mainThread()) .takeWhile { messagesBoxSVGA.size > 0 } .subscribe { - if((mContext as AVRoomActivity).isTopActivity) { + if ((mContext as AVRoomActivity).isTopActivity) { showBoxNotifyBySVGA( messagesBoxSVGA.removeAt(0) ) diff --git a/app/src/main/java/com/yizhuan/erban/home/fragment/HomeTabHomeFragment.java b/app/src/main/java/com/yizhuan/erban/home/fragment/HomeTabHomeFragment.java index a3e82fbee..2802fb9c4 100644 --- a/app/src/main/java/com/yizhuan/erban/home/fragment/HomeTabHomeFragment.java +++ b/app/src/main/java/com/yizhuan/erban/home/fragment/HomeTabHomeFragment.java @@ -206,7 +206,7 @@ public class HomeTabHomeFragment extends BaseFragment { @Subscribe(threadMode = ThreadMode.MAIN) public void onRefreshHomeDataEvent(RefreshHomeDataEvent event) { -// if (isResumed()) getData(); + if (isResumed()) getData(); } } diff --git a/app/src/main/res/drawable-xhdpi/bg_lucky_sea_notice.webp b/app/src/main/res/drawable-xhdpi/bg_lucky_sea_notice.webp new file mode 100644 index 000000000..af1742e29 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/bg_lucky_sea_notice.webp differ diff --git a/app/src/main/res/layout/layout_room_effect.xml b/app/src/main/res/layout/layout_room_effect.xml index ffa86510d..d01715fb6 100644 --- a/app/src/main/res/layout/layout_room_effect.xml +++ b/app/src/main/res/layout/layout_room_effect.xml @@ -122,6 +122,20 @@ app:layout_constraintDimensionRatio="75:12" app:layout_constraintTop_toTopOf="parent" /> + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2faed98ea..bccb00bfe 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -5006,5 +5006,9 @@ 只能查看前3個月的結算統計 更換綁定 房間 + 恭喜 + 在星級厨房抽中 + 倍獎勵,獲得 + 鉆石! \ No newline at end of file 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 e0f733aa2..e04415791 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 @@ -1328,6 +1328,15 @@ public final class IMNetEaseManager { noticeRoomEvent(msg, RoomEvent.DRAW_GIFT_EFFECT); } break; + case CUSTOM_MSG_LUCKY_SEA: + if (second == CUSTOM_MSG_LUCKY_SEA_GIFT_ROOM_NOTIFY) { + addMessages(msg); + noticeRoomEvent(msg, RoomEvent.LUCKY_SEA_GIFT_ROOM_NOTIFY); + }else if(second == CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_NOTIFY){ + addMessages(msg); + noticeRoomEvent(msg, RoomEvent.LUCKY_SEA_GIFT_SERVER_NOTIFY); + } + break; default: break; } 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 578bb3908..016917002 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 @@ -32,6 +32,9 @@ import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUS import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LEAVE_MODE; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LEAVE_MODE_NOTICE; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LEVEL_UP; +import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_SEA; +import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_SEA_GIFT_ROOM_NOTIFY; +import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_NOTIFY; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_MENTORING_RELATIONSHIP; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_MINI_WORLD; import static com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment.CUSTOM_MSG_MODULE_HALL; @@ -606,6 +609,14 @@ public class CustomAttachParser implements MsgAttachmentParser { attachment = new DrawGiftAttachment(first, second); } break; + case CUSTOM_MSG_LUCKY_SEA: + switch (second) { + case CUSTOM_MSG_LUCKY_SEA_GIFT_ROOM_NOTIFY: + case CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_NOTIFY: + attachment = new RoomLuckySeaAttachment(CUSTOM_MSG_LUCKY_SEA, second); + break; + } + 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 76847db66..6b83839f1 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 @@ -418,6 +418,10 @@ public class CustomAttachment implements MsgAttachment { public static final int CUSTOM_MSG_DRAW_GIFT_EFFECT = 94; public static final int CUSTOM_MSG_SUB_TYPE_DRAW_GIFT_EFFECT = 941; + //星级厨房 + public static final int CUSTOM_MSG_LUCKY_SEA = 95; // 深海奇缘消息 + public static final int CUSTOM_MSG_LUCKY_SEA_GIFT_ROOM_NOTIFY = 950; // 深海奇缘礼物房间飘屏通知 + public static final int CUSTOM_MSG_LUCKY_SEA_GIFT_SERVER_NOTIFY = 951;// 深海奇缘礼物全服飘屏通知 /** * 自定义消息附件的类型,根据该字段区分不同的自定义消息 diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/RoomLuckySeaAttachment.java b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/RoomLuckySeaAttachment.java new file mode 100644 index 000000000..6d1a7e6f6 --- /dev/null +++ b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/RoomLuckySeaAttachment.java @@ -0,0 +1,33 @@ +package com.yizhuan.xchat_android_core.im.custom.bean; + +import com.alibaba.fastjson.JSONObject; +import com.google.gson.Gson; + +/** + * 星级厨房 + * Created by wushaocheng on 2022/12/8. + */ +public class RoomLuckySeaAttachment extends CustomAttachment { + + private RoomLuckySeaMsgBean roomLuckySeaMsgBean; + + public RoomLuckySeaAttachment(int first, int second) { + super(first, second); + } + + @Override + protected void parseData(JSONObject data) { + roomLuckySeaMsgBean = new Gson().fromJson(data.toJSONString(), RoomLuckySeaMsgBean.class); + } + + @Override + protected JSONObject packData() { + String jsonStr = new Gson().toJson(roomLuckySeaMsgBean); + return JSONObject.parseObject(jsonStr); + } + + public RoomLuckySeaMsgBean getRoomLuckySeaMsgInfo() { + return roomLuckySeaMsgBean; + } + +} diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/RoomLuckySeaMsgBean.java b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/RoomLuckySeaMsgBean.java new file mode 100644 index 000000000..f108e4d1f --- /dev/null +++ b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/RoomLuckySeaMsgBean.java @@ -0,0 +1,15 @@ +package com.yizhuan.xchat_android_core.im.custom.bean; + +import lombok.Data; + +@Data +public class RoomLuckySeaMsgBean { + private long uid; + private String nick; + private long roomUid;//房间uid + private long itemId;//中奖选项id + private int itemMultiple;//倍数 + private long diamonds;//钻石 + private int bannerId;//bannerId + private String skipUrl;//跳转id +} 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 291e22423..e2c248aef 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 @@ -247,6 +247,11 @@ public class RoomEvent { public static final int DRAW_GIFT_EFFECT = 98; + //深海奇缘礼物房间飘屏通知 + public static final int LUCKY_SEA_GIFT_ROOM_NOTIFY = 99; + //深海奇缘礼物全服飘屏通知 + public static final int LUCKY_SEA_GIFT_SERVER_NOTIFY = 100; + private int event = NONE; private int micPosition = Integer.MIN_VALUE; private int posState = -1;