|
|
@@ -2,8 +2,10 @@ package com.adealink.weparty.message.conversation.comp
|
|
|
|
|
|
import android.content.Intent
|
|
|
import android.graphics.PointF
|
|
|
+import android.os.Bundle
|
|
|
import android.widget.ImageView
|
|
|
import androidx.lifecycle.LifecycleOwner
|
|
|
+import com.adealink.frame.aab.util.getCompatString
|
|
|
import com.adealink.frame.base.Rlt
|
|
|
import com.adealink.frame.base.fastLazy
|
|
|
import com.adealink.frame.effect.svga.data.PathType
|
|
|
@@ -11,10 +13,13 @@ import com.adealink.frame.effect.svga.data.SVGAEffectEntity
|
|
|
import com.adealink.frame.effect.video.data.VideoEffectEntity
|
|
|
import com.adealink.frame.effect.view.EffectView
|
|
|
import com.adealink.frame.mvvm.view.ViewComponent
|
|
|
+import com.adealink.frame.router.Router
|
|
|
import com.adealink.frame.tceffect.effect.data.TCEffectEntity
|
|
|
import com.adealink.frame.util.getCenterLocationInWindow
|
|
|
import com.adealink.frame.util.getLocationInWindow
|
|
|
+import com.adealink.weparty.commonui.dialogfragment.BaseDialogFragment
|
|
|
import com.adealink.weparty.commonui.ext.dp
|
|
|
+import com.adealink.weparty.commonui.toast.util.showToast
|
|
|
import com.adealink.weparty.effect.EffectAnimType
|
|
|
import com.adealink.weparty.effect.EffectSaveResource
|
|
|
import com.adealink.weparty.message.constant.MESSAGE_FROM_USER_AVATAR_KEY
|
|
|
@@ -25,18 +30,23 @@ import com.adealink.weparty.message.effect.GiftEffectListener
|
|
|
import com.adealink.weparty.message.effect.SendStaticGiftEffectEntity
|
|
|
import com.adealink.weparty.message.effect.StaticGiftEffectLayout
|
|
|
import com.adealink.weparty.module.anchor.data.FromScene
|
|
|
+import com.adealink.weparty.module.gift.Gift
|
|
|
import com.adealink.weparty.module.gift.GiftModule
|
|
|
import com.adealink.weparty.module.gift.data.DEFAULT_GIFT_EFFECT_TIMEOUT_MS
|
|
|
import com.adealink.weparty.module.gift.data.DynamicEntityType
|
|
|
import com.adealink.weparty.module.gift.data.GiftDynamicEntity
|
|
|
import com.adealink.weparty.module.gift.data.GiftInfo
|
|
|
+import com.adealink.weparty.module.gift.data.LuckyGiftLotteryNotify
|
|
|
import com.adealink.weparty.module.gift.data.SendGiftNotify
|
|
|
import com.adealink.weparty.module.gift.data.getSVGAGiftDynamicEntity
|
|
|
import com.adealink.weparty.module.gift.data.getTCFetchResource
|
|
|
import com.adealink.weparty.module.gift.data.getVapFetchResource
|
|
|
import com.adealink.weparty.module.gift.effect.SendGiftNoticeLayout
|
|
|
+import com.adealink.weparty.module.gift.effect.luckygift.LuckyGiftBigRewardEffectEntity
|
|
|
+import com.adealink.weparty.module.gift.effect.luckygift.LuckyGiftRewardEffectEntity
|
|
|
import com.adealink.weparty.module.profile.ProfileModule
|
|
|
import com.adealink.weparty.module.profile.data.UserInfo
|
|
|
+import com.adealink.weparty.module.wallet.WalletModule
|
|
|
|
|
|
class GroupChatGiftComp(
|
|
|
lifecycleOwner: LifecycleOwner,
|
|
|
@@ -48,6 +58,10 @@ class GroupChatGiftComp(
|
|
|
) : ViewComponent(lifecycleOwner) {
|
|
|
private val giftViewModel by fastLazy { GiftModule.getGiftViewModel(requireActivity()) }
|
|
|
|
|
|
+ companion object {
|
|
|
+ private const val LOTTERY_RATIO_BIG_REWARD_EFFECT = 300
|
|
|
+ }
|
|
|
+
|
|
|
override fun onCreate() {
|
|
|
super.onCreate()
|
|
|
observerViewModel()
|
|
|
@@ -58,15 +72,44 @@ class GroupChatGiftComp(
|
|
|
if (sendGiftNotify.giftScene != FromScene.GROUP_IM.scene) {
|
|
|
return@observeWithoutCache
|
|
|
}
|
|
|
- val myUid = ProfileModule.getMyUid()
|
|
|
- if (sendGiftNotify.fromUid == myUid || sendGiftNotify.toUidSet.contains(myUid)) {
|
|
|
- handleSendGiftNotify(
|
|
|
- sendGiftNotify,
|
|
|
- sendGiftNotify.gitInfo,
|
|
|
- sendGiftNotify.toUidSet,
|
|
|
- sendGiftNotify.count,
|
|
|
- sendGiftNotify.notifyUserInfo ?: mapOf()
|
|
|
+ handleSendGiftNotify(
|
|
|
+ sendGiftNotify,
|
|
|
+ sendGiftNotify.gitInfo,
|
|
|
+ sendGiftNotify.toUidSet,
|
|
|
+ sendGiftNotify.count,
|
|
|
+ sendGiftNotify.notifyUserInfo ?: mapOf()
|
|
|
+ )
|
|
|
+ }
|
|
|
+ giftViewModel?.groupChatLuckyGiftRewardNotifyLD?.observeWithoutCache(viewLifecycleOwner) { notify ->
|
|
|
+ handleLuckGiftRewardNotify(notify)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun handleLuckGiftRewardNotify(notify: LuckyGiftLotteryNotify) {
|
|
|
+ if (notify.userInfo.uid == ProfileModule.getMyUid()) {
|
|
|
+ if (notify.giftInfo.isComboGift == 1) {
|
|
|
+ //幸运礼物combo弹toast提醒
|
|
|
+ showToast(
|
|
|
+ getCompatString(
|
|
|
+ com.adealink.weparty.R.string.common_lucky_gift_reward,
|
|
|
+ notify.giftInfo.name,
|
|
|
+ notify.lotteryRatio
|
|
|
+ )
|
|
|
)
|
|
|
+ } else {
|
|
|
+ Router.getRouterInstance<BaseDialogFragment>(Gift.LuckyGiftReward.PATH)?.apply {
|
|
|
+ this.arguments = Bundle().apply {
|
|
|
+ putParcelable(Gift.LuckyGiftReward.EXTRA_LUCKY_GIFT_REWARD, notify)
|
|
|
+ }
|
|
|
+ }?.show(fragmentManager)
|
|
|
+ }
|
|
|
+ WalletModule.getWalletViewModel(requireActivity())?.getMyCoinCount()
|
|
|
+ }
|
|
|
+ if (notify.showPlace == 1) {
|
|
|
+ if (notify.lotteryRatio >= LOTTERY_RATIO_BIG_REWARD_EFFECT) {
|
|
|
+ giftEffectView.add(LuckyGiftBigRewardEffectEntity("", notify))
|
|
|
+ } else {
|
|
|
+ giftEffectView.add(LuckyGiftRewardEffectEntity("", notify))
|
|
|
}
|
|
|
}
|
|
|
}
|