feat : 飘屏调整 初次提交
This commit is contained in:
@@ -2,14 +2,18 @@ package com.chwl.app
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.view.ViewGroup
|
||||
import com.chwl.app.avroom.adapter.Mic19ViewAdapter
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.chwl.app.avroom.adapter.Mic20ViewAdapter
|
||||
import com.chwl.app.avroom.dialog.BaseRoomNotifyDialog
|
||||
import com.chwl.app.avroom.dialog.RoomNotifyLuckGiftDialog
|
||||
import com.chwl.app.base.BaseViewBindingActivity
|
||||
import com.chwl.app.bindadapter.BaseBindingAdapter
|
||||
import com.chwl.app.bindadapter.BaseBindingViewHolder
|
||||
import com.chwl.app.databinding.ActivityDemoBinding
|
||||
import com.chwl.app.databinding.ListItemMicroBinding
|
||||
import com.chwl.app.ui.widget.recyclerview.layoutmanager.BoosRoomLayoutManager
|
||||
import com.chwl.app.view.layoutmanager.PageSnapHelper
|
||||
import com.chwl.core.gift.bean.LuckyGiftMsgAllBean
|
||||
import com.chwl.library.common.util.setVis
|
||||
|
||||
class DemoActivity : BaseViewBindingActivity<ActivityDemoBinding>() {
|
||||
@@ -44,17 +48,37 @@ class DemoActivity : BaseViewBindingActivity<ActivityDemoBinding>() {
|
||||
// 1,1,1,1,
|
||||
// ))
|
||||
|
||||
val adapter = Mic19ViewAdapter(context)
|
||||
|
||||
// binding.rvList.layoutManager = BoosRoomLayoutManager()
|
||||
|
||||
val linearLayoutManager = GridLayoutManager(this,4,RecyclerView.HORIZONTAL, false)
|
||||
binding.rvList.layoutManager = linearLayoutManager
|
||||
|
||||
val pageSnapHelper = PageSnapHelper()
|
||||
pageSnapHelper.attachToRecyclerView(binding.rvList)
|
||||
|
||||
val adapter = Mic20ViewAdapter(context)
|
||||
binding.rvList.adapter = adapter
|
||||
binding.rvList.layoutManager = BoosRoomLayoutManager()
|
||||
// val item = ListItemMicroBinding.inflate(layoutInflater, binding.layout, false)
|
||||
// item.root.layoutParams = ViewGroup.LayoutParams(
|
||||
// ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
// ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
// )
|
||||
// binding.layout.addView(item.root)
|
||||
|
||||
|
||||
val item = ListItemMicroBinding.inflate(layoutInflater, binding.layout, false)
|
||||
item.root.layoutParams = ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
)
|
||||
binding.layout.addView(item.root)
|
||||
val dialog = RoomNotifyLuckGiftDialog(this).apply {
|
||||
luckyGiftMsgBean = LuckyGiftMsgAllBean(coins = 100)
|
||||
}
|
||||
dialog.showDialog()
|
||||
dialog.mCallBack = object : BaseRoomNotifyDialog.CallBack {
|
||||
override fun onHide() {
|
||||
binding.rvList.postDelayed({
|
||||
dialog.luckyGiftMsgBean = LuckyGiftMsgAllBean(coins = 200)
|
||||
dialog.showDialog()
|
||||
},1000)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -40,12 +40,16 @@ abstract class BaseRoomNotifyDialog<VB : ViewBinding>(context: Context, theme: I
|
||||
init()
|
||||
|
||||
if (useAutoDismiss()) {
|
||||
handle.postDelayed({
|
||||
dismissDialog()
|
||||
}, (getStaySecond()*1000).toLong())
|
||||
startAutoDismiss()
|
||||
}
|
||||
}
|
||||
|
||||
protected open fun startAutoDismiss() {
|
||||
handle.postDelayed({
|
||||
dismissDialog()
|
||||
}, (getStaySecond()*1000).toLong())
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
handle.removeCallbacksAndMessages(null)
|
||||
super.onDetachedFromWindow()
|
||||
|
@@ -261,6 +261,8 @@ class RoomGameListDialog :
|
||||
getString(R.string.room_switch_game_tips)
|
||||
) {
|
||||
|
||||
//todo do 游戏弹窗列表 点击事件
|
||||
|
||||
if (gameInfo.isFindLove()) {
|
||||
jumpFindLove()
|
||||
}else if (gameInfo.isLeadercc()) {
|
||||
|
@@ -14,6 +14,7 @@ import com.chwl.core.manager.AvRoomDataManager
|
||||
import com.chwl.library.common.util.setAutoSizeModel
|
||||
import com.chwl.library.common.util.setRL
|
||||
import com.chwl.library.common.util.setString
|
||||
import com.chwl.library.common.util.setVis
|
||||
import com.chwl.library.utils.ResUtil
|
||||
|
||||
/**
|
||||
@@ -31,37 +32,49 @@ class RoomNotifyLuckGiftDialog(private val context: Context) : BaseRoomNotifyDia
|
||||
|
||||
override fun init() {
|
||||
|
||||
}
|
||||
|
||||
override fun useAutoDismiss(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
private fun ready() {
|
||||
mBinding.root.setVis(true)
|
||||
|
||||
mBinding.bg.setRL()
|
||||
|
||||
ImageLoadUtils.loadImage(mBinding.avatar,luckyGiftMsgBean?.sender?.avatar?:"")
|
||||
mBinding.giftName.text = luckyGiftMsgBean?.giftNameMap?.getFirstText()
|
||||
mBinding.winNum.text = luckyGiftMsgBean?.times.toString()
|
||||
|
||||
// val coinNum = NumberUtils.format(luckyGiftMsgBean?.coins?:0)
|
||||
val coinNum = luckyGiftMsgBean?.coins?:0
|
||||
mBinding.coinNum.setString(coinNum.toString())
|
||||
mBinding.coinNum.setAutoSizeModel()
|
||||
|
||||
mBinding.clickArea.setOnClickListener {
|
||||
val activity = GlobalHandleManager.get().activity ?: return@setOnClickListener
|
||||
mDialogManager = DialogManager(activity)
|
||||
mDialogManager?.showOkCancelDialog(ResUtil.getString(R.string.changeRoomTips), true, object : OkCancelDialogListener {
|
||||
override fun onCancel() {
|
||||
mDialogManager?.dismissDialog()
|
||||
}
|
||||
|
||||
override fun onOk() {
|
||||
mDialogManager?.dismissDialog()
|
||||
luckyGiftMsgBean?.roomUid?.let {
|
||||
if (AvRoomDataManager.get().roomUid != it) {
|
||||
AVRoomActivity.start(context, it)
|
||||
}
|
||||
luckyGiftMsgBean?.roomUid?.let { roomUid ->
|
||||
if (AvRoomDataManager.get().roomUid == roomUid) return@setOnClickListener
|
||||
val activity = GlobalHandleManager.get().activity ?: return@setOnClickListener
|
||||
mDialogManager = DialogManager(activity)
|
||||
mDialogManager?.showOkCancelDialog(ResUtil.getString(R.string.changeRoomTips), true, object : OkCancelDialogListener {
|
||||
override fun onCancel() {
|
||||
mDialogManager?.dismissDialog()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
override fun onOk() {
|
||||
mDialogManager?.dismissDialog()
|
||||
AVRoomActivity.start(context, roomUid)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
startAutoDismiss()
|
||||
}
|
||||
|
||||
override fun showDialog() {
|
||||
super.showDialog()
|
||||
ready()
|
||||
}
|
||||
|
||||
}
|
@@ -6,10 +6,7 @@ import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.view.ViewStub;
|
||||
@@ -30,24 +27,20 @@ import com.chwl.app.avroom.widget.GiftV2View;
|
||||
import com.chwl.app.avroom.widget.RoomEffectView;
|
||||
import com.chwl.app.base.BaseFragment;
|
||||
import com.chwl.app.databinding.FragmentChatroomGameMainBinding;
|
||||
import com.chwl.app.databinding.LayoutRoomNotifyLuckyGiftTipBinding;
|
||||
import com.chwl.app.notify.GlobalNotifyManager;
|
||||
import com.chwl.app.ui.utils.ImageLoadKt;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtilsV2;
|
||||
import com.chwl.app.ui.widget.BonsellaJoinAttackButtonView;
|
||||
import com.chwl.app.ui.widget.GiftDialog;
|
||||
import com.chwl.app.ui.widget.UserInfoDialog;
|
||||
import com.chwl.app.utils.GiftAnimUtil;
|
||||
import com.chwl.app.utils.RegexUtil;
|
||||
import com.chwl.app.utils.RoomBoomManager;
|
||||
import com.chwl.app.utils.RoomNotifyDialogManager;
|
||||
import com.chwl.app.utils.WeakPool;
|
||||
import com.chwl.core.auth.AuthModel;
|
||||
import com.chwl.core.gift.bean.CpMsgBean;
|
||||
import com.chwl.core.gift.bean.GiftMultiReceiverInfo;
|
||||
import com.chwl.core.gift.bean.GiftReceiveInfo;
|
||||
import com.chwl.core.gift.bean.LuckyBagGifts;
|
||||
import com.chwl.core.gift.bean.LuckyGiftMsgAllBean;
|
||||
import com.chwl.core.gift.bean.LuckyGiftMsgSelfBean;
|
||||
import com.chwl.core.gift.bean.MsgSuperLuckyGift;
|
||||
import com.chwl.core.gift.bean.MultiGiftReceiveInfo;
|
||||
import com.chwl.core.gift.bean.RoomBgChangeBean;
|
||||
@@ -64,6 +57,7 @@ import com.chwl.core.magic.bean.MultiMagicReceivedInfo;
|
||||
import com.chwl.core.manager.AvRoomDataManager;
|
||||
import com.chwl.core.manager.IMNetEaseManager;
|
||||
import com.chwl.core.manager.RoomEvent;
|
||||
import com.chwl.core.noble.bean.AllServiceGiftProtocol;
|
||||
import com.chwl.core.praise.PraiseModel;
|
||||
import com.chwl.core.room.bean.RoomInfo;
|
||||
import com.chwl.core.room.queuing_mic.event.HasAnimationEffect;
|
||||
@@ -72,7 +66,6 @@ import com.chwl.core.user.UserModel;
|
||||
import com.chwl.core.user.bean.UserInfo;
|
||||
import com.chwl.core.utils.ComboUtil;
|
||||
import com.chwl.core.utils.CoreLogger;
|
||||
import com.chwl.core.utils.LogUtils;
|
||||
import com.chwl.library.common.util.OtherExtKt;
|
||||
import com.chwl.library.utils.JavaUtil;
|
||||
import com.chwl.library.utils.ListUtils;
|
||||
@@ -278,6 +271,8 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
break;
|
||||
case RoomEvent.RECEIVE_NORMALE_GIFT_ALL_SERVICE:// 全服普通
|
||||
onReceiveGiftMsgAllService(roomEvent.getGiftReceiveInfo());
|
||||
case RoomEvent.RECEIVE_NORMALE_GIFT_ALL_SERVICE_NOTIFY:// 全服飘屏
|
||||
onReceiveGiftMsgAllServiceNotify(roomEvent.getAnyData());
|
||||
break;
|
||||
case RoomEvent.RECEIVE_MUTLT_NORMALEI_GIFT://普通多人
|
||||
onReceiveMultiGiftMsg(roomEvent.getGiftMultiReceiverInfo());
|
||||
@@ -535,8 +530,6 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
|
||||
luckyGiftTipPool.clear();
|
||||
handler.removeCallbacksAndMessages(null);
|
||||
RoomNotifyDialogManager.INSTANCE.clear();
|
||||
RoomBoomManager.INSTANCE.clear();
|
||||
|
||||
@@ -630,6 +623,15 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
// gameMainBinding.giftComboLayout.onRoomCustomMsg(GiftToolbox.transformToGiftMultiReceiverInfo(giftReceiveInfo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 全服礼物-飘屏
|
||||
*/
|
||||
private void onReceiveGiftMsgAllServiceNotify(Object anyData) {
|
||||
if (anyData != null && anyData instanceof AllServiceGiftProtocol.DataBean) {
|
||||
GlobalNotifyManager.INSTANCE.onReceiveGiftMsgAllServiceNotify(anyData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void onReceiveMagicMsg(MagicReceivedInfo magicReceivedInfo) {
|
||||
if (magicReceivedInfo == null || !isResumed()) return;
|
||||
@@ -762,79 +764,24 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
MsgSuperLuckyGift msgSuperLuckyGift = roomEvent.getMsgSuperLuckyGift();
|
||||
if (msgSuperLuckyGift != null) {
|
||||
if (msgSuperLuckyGift.luckyGiftMsgAllBean != null) {
|
||||
showLuckyGiftDlg(msgSuperLuckyGift.luckyGiftMsgAllBean);
|
||||
RoomNotifyDialogManager.INSTANCE.addDialog(new RoomNotifyDialogBean(
|
||||
CustomAttachment.CUSTOM_MSG_SUPER_LUCKY_GIFT_TEMPLATE,
|
||||
CustomAttachment.CUSTOM_MSG_SUPER_LUCKY_GIFT_ROOM,
|
||||
msgSuperLuckyGift.luckyGiftMsgAllBean
|
||||
));
|
||||
}
|
||||
|
||||
if (msgSuperLuckyGift.luckyGiftMsgSelfBean != null) {
|
||||
showLuckyGiftDlgNotify(msgSuperLuckyGift.luckyGiftMsgSelfBean);
|
||||
|
||||
if (msgSuperLuckyGift.luckyGiftMsgSelfBean.getUid() != AuthModel.get().getCurrentUid()) return;
|
||||
if (msgSuperLuckyGift.luckyGiftMsgSelfBean.getRoomId() != AvRoomDataManager.get().getRoomId()) return;
|
||||
if (msgSuperLuckyGift.luckyGiftMsgSelfBean.getRoomUid() != AvRoomDataManager.get().getRoomUid()) return;
|
||||
RoomNotifyDialogManager.INSTANCE.showLuckyGiftDlgNotify(gameMainBinding.flLuckyGiftNotifyLayout,msgSuperLuckyGift.luckyGiftMsgSelfBean);
|
||||
gameMainBinding.coinTips.showView(String.valueOf(msgSuperLuckyGift.luckyGiftMsgSelfBean.getCoins()),true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Handler handler = new Handler(Looper.getMainLooper());
|
||||
private WeakPool<View> luckyGiftTipPool = new WeakPool<>(3);
|
||||
|
||||
private void showLuckyGiftDlgNotify(LuckyGiftMsgSelfBean luckyGiftMsgBean) {
|
||||
if (luckyGiftMsgBean == null) return;
|
||||
if (luckyGiftMsgBean.getUid() != AuthModel.get().getCurrentUid()) return;
|
||||
if (luckyGiftMsgBean.getRoomId() != AvRoomDataManager.get().getRoomId()) return;
|
||||
if (luckyGiftMsgBean.getRoomUid() != AvRoomDataManager.get().getRoomUid()) return;
|
||||
|
||||
LogUtils.i(" showLuckyGiftDlgNotify = start");
|
||||
|
||||
View root = luckyGiftTipPool.acquire(() -> {
|
||||
return LayoutInflater.from(gameMainBinding.flLuckyGiftNotifyLayout.getContext()).inflate(R.layout.layout_room_notify_lucky_gift_tip, gameMainBinding.flLuckyGiftNotifyLayout, false);
|
||||
});
|
||||
LayoutRoomNotifyLuckyGiftTipBinding binding = LayoutRoomNotifyLuckyGiftTipBinding.bind(root);
|
||||
binding.coinNum.setText(String.valueOf(luckyGiftMsgBean.getCoins()));
|
||||
OtherExtKt.setAutoSizeModel(binding.coinNum);
|
||||
binding.winNum.setText(java.lang.String.valueOf(luckyGiftMsgBean.getTimes()));
|
||||
if (luckyGiftMsgBean.getLevel() > 1) {
|
||||
binding.rootView.setBackgroundResource(R.drawable.bg_lucky_gift_tip_2);
|
||||
}
|
||||
root.setAlpha(0f);
|
||||
root.setScaleX(0f);
|
||||
root.setScaleY(0f);
|
||||
gameMainBinding.flLuckyGiftNotifyLayout.addView(root);
|
||||
GiftAnimUtil.showAnimation(root);
|
||||
// GiftAnimUtil.expandAnimation(root);
|
||||
|
||||
handler.postDelayed(() -> {
|
||||
try {
|
||||
root.animate()
|
||||
.alpha(0f)
|
||||
.setDuration(500)
|
||||
.withEndAction(() -> {
|
||||
gameMainBinding.flLuckyGiftNotifyLayout.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
root.clearAnimation();
|
||||
gameMainBinding.flLuckyGiftNotifyLayout.removeView(root);
|
||||
luckyGiftTipPool.release(root);
|
||||
}
|
||||
});
|
||||
})
|
||||
.start();
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}, 2300);
|
||||
|
||||
gameMainBinding.coinTips.showView(String.valueOf(luckyGiftMsgBean.getCoins()),true);
|
||||
}
|
||||
|
||||
private void showLuckyGiftDlg(LuckyGiftMsgAllBean data) {
|
||||
//todo do 校验数据是否异常
|
||||
RoomNotifyDialogManager.INSTANCE.addDialog(new RoomNotifyDialogBean(
|
||||
CustomAttachment.CUSTOM_MSG_SUPER_LUCKY_GIFT_TEMPLATE,
|
||||
CustomAttachment.CUSTOM_MSG_SUPER_LUCKY_GIFT_ROOM,
|
||||
data
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* cp 礼物
|
||||
*/
|
||||
|
@@ -64,6 +64,8 @@ public class VDHLayout extends FrameLayout {
|
||||
.alpha(0F)
|
||||
.withEndAction(() -> {
|
||||
releasedChild.setVisibility(GONE);
|
||||
releasedChild.setAlpha(1f);
|
||||
releasedChild.setTranslationX(0);
|
||||
if(listener != null){
|
||||
listener.onViewGone();
|
||||
}
|
||||
|
@@ -21,10 +21,10 @@ import com.trello.rxlifecycle3.components.support.RxDialogFragment
|
||||
import kotlinx.coroutines.launch
|
||||
import java.lang.reflect.ParameterizedType
|
||||
|
||||
abstract class BaseDialogFragment<T : ViewBinding> : RxDialogFragment() {
|
||||
abstract class BaseDialogFragment<VB : ViewBinding> : RxDialogFragment() {
|
||||
|
||||
val isViewLoaded: Boolean get() = _binding != null
|
||||
protected var _binding: T? = null
|
||||
protected var _binding: VB? = null
|
||||
private var onDismissListener: (() -> Unit)? = null
|
||||
val binding get() = _binding!!
|
||||
open var width = ScreenUtil.getDialogWidth()
|
||||
@@ -52,7 +52,7 @@ abstract class BaseDialogFragment<T : ViewBinding> : RxDialogFragment() {
|
||||
val type = javaClass.genericSuperclass as ParameterizedType
|
||||
val aClass = type.actualTypeArguments[0] as Class<*>
|
||||
val method = aClass.getDeclaredMethod("inflate", LayoutInflater::class.java)
|
||||
_binding = method.invoke(null, layoutInflater) as T
|
||||
_binding = method.invoke(null, layoutInflater) as VB
|
||||
return binding?.root
|
||||
}
|
||||
|
||||
|
@@ -6,7 +6,6 @@ import android.view.ViewGroup
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chwl.app.R
|
||||
import com.chwl.library.common.util.ViewBindingUtil
|
||||
import java.lang.reflect.ParameterizedType
|
||||
|
||||
open class BaseBindingAdapter<VB : ViewBinding?, T>() : BaseQuickAdapter<T, BaseBindingViewHolder<VB>>(R.layout.item_empty_list) {
|
||||
@@ -33,5 +32,9 @@ open class BaseBindingAdapter<VB : ViewBinding?, T>() : BaseQuickAdapter<T, Base
|
||||
|
||||
}
|
||||
|
||||
override fun convert(helper: BaseBindingViewHolder<VB>, item: T) {}
|
||||
override fun convert(helper: BaseBindingViewHolder<VB>, item: T) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -165,17 +165,17 @@ object GlobalNotifyManager : Observer<BroadcastMessage>, ILog {
|
||||
}
|
||||
}
|
||||
// 礼物
|
||||
CustomAttachment.CUSTOM_MSG_HEADER_TYPE_GIFT -> {
|
||||
if (protocol.second == CustomAttachment.CUSTOM_MSG_ALL_SERVICE_GIFT) {
|
||||
val data = Gson().fromJson<AllServiceGiftProtocol.DataBean>(
|
||||
protocol.data.toString(),
|
||||
AllServiceGiftProtocol.DataBean::class.java
|
||||
)
|
||||
if (UserModel.get().isSamePartition(data.partitionId)) {
|
||||
queue.addLast(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
// CustomAttachment.CUSTOM_MSG_HEADER_TYPE_GIFT -> {
|
||||
// if (protocol.second == CustomAttachment.CUSTOM_MSG_ALL_SERVICE_GIFT) {
|
||||
// val data = Gson().fromJson<AllServiceGiftProtocol.DataBean>(
|
||||
// protocol.data.toString(),
|
||||
// AllServiceGiftProtocol.DataBean::class.java
|
||||
// )
|
||||
// if (UserModel.get().isSamePartition(data.partitionId)) {
|
||||
// queue.addLast(data)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// 寻爱之旅
|
||||
CustomAttachment.CUSTOM_MSG_BOX -> {
|
||||
if (protocol.second == CustomAttachment.CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA) {
|
||||
@@ -207,6 +207,17 @@ object GlobalNotifyManager : Observer<BroadcastMessage>, ILog {
|
||||
}
|
||||
}
|
||||
|
||||
public fun onReceiveGiftMsgAllServiceNotify(anyData:Any?) {
|
||||
if (!AvRoomDataManager.get().hasAvRoomAct) return
|
||||
if (anyData != null) {
|
||||
if (anyData is AllServiceGiftProtocol.DataBean) {
|
||||
if (UserModel.get().isSamePartition(anyData.partitionId)) {
|
||||
queue.addLast(anyData)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleFindLive(protocol: BaseProtocol<*>) {
|
||||
val data = Gson().fromJson<RoomBoxPrizeInfo>(
|
||||
protocol.data.toString(),
|
||||
|
248
app/src/main/java/com/chwl/app/notify/GlobalNotifyManagerNew.kt
Normal file
248
app/src/main/java/com/chwl/app/notify/GlobalNotifyManagerNew.kt
Normal file
@@ -0,0 +1,248 @@
|
||||
package com.chwl.app.notify
|
||||
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.chwl.app.NimMiddleActivity
|
||||
import com.chwl.app.avroom.activity.AVRoomActivity
|
||||
import com.chwl.app.avroom.anotherroompk.RoomPKCreateActivity
|
||||
import com.chwl.app.avroom.singleroompk.SingleRoomPKCreateActivity
|
||||
import com.chwl.app.base.TitleBar
|
||||
import com.chwl.app.other.activity.SplashActivity
|
||||
import com.chwl.app.support.float.FloatWindowEngine
|
||||
import com.chwl.app.support.float.SimpleFloatQueue
|
||||
import com.chwl.app.support.float.SimpleFloatWindow
|
||||
import com.chwl.app.treasure_box.activity.BoxRankingActivity
|
||||
import com.chwl.app.treasure_box.activity.TreasureBoxActivity
|
||||
import com.chwl.app.treasure_box.activity.TreasureBoxHonourActivity
|
||||
import com.chwl.app.ui.login.AddUserInfoActivity
|
||||
import com.chwl.app.ui.login.LoginCodeActivity
|
||||
import com.chwl.app.ui.login.LoginPhoneActivity
|
||||
import com.chwl.app.ui.setting.ResetPasswordActivity
|
||||
import com.chwl.app.ui.widget.LevelUpDialog
|
||||
import com.chwl.core.auth.AuthModel
|
||||
import com.chwl.core.gift.bean.LuckyBagNoticeInfo
|
||||
import com.chwl.core.im.custom.bean.CustomAttachment
|
||||
import com.chwl.core.im.custom.bean.RoomBoxPrizeAttachment
|
||||
import com.chwl.core.im.custom.bean.RoomBoxPrizeInfo
|
||||
import com.chwl.core.im.custom.bean.RoomReceivedLuckyGiftAttachment
|
||||
import com.chwl.core.im.custom.bean.RoomTemplateNotifyMsgBean
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
import com.chwl.core.manager.IMNetEaseManager
|
||||
import com.chwl.core.noble.bean.AllServiceGiftProtocol
|
||||
import com.chwl.core.user.UserModel
|
||||
import com.chwl.library.common.util.doLog
|
||||
import com.chwl.library.utils.ListUtils
|
||||
import com.example.lib_utils.log.ILog
|
||||
import com.google.gson.Gson
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil
|
||||
import com.netease.nimlib.sdk.NIMChatRoomSDK
|
||||
import com.netease.nimlib.sdk.Observer
|
||||
import com.netease.nimlib.sdk.chatroom.ChatRoomMessageBuilder
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage
|
||||
import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum
|
||||
import kotlinx.coroutines.cancel
|
||||
|
||||
/**
|
||||
* Created by Max on 2024/3/20 19:30
|
||||
* Desc:
|
||||
**/
|
||||
object GlobalNotifyManagerNew : Observer<List<ChatRoomMessage>>, ILog {
|
||||
|
||||
private fun readResolve(): Any = GlobalNotifyManagerNew
|
||||
|
||||
private val blackActivityList = listOf(
|
||||
SplashActivity::class.java,
|
||||
LoginPhoneActivity::class.java,
|
||||
LoginCodeActivity::class.java,
|
||||
ResetPasswordActivity::class.java,
|
||||
AddUserInfoActivity::class.java,
|
||||
NimMiddleActivity::class.java,
|
||||
// 房间页面单独处理
|
||||
AVRoomActivity::class.java,
|
||||
// 房间内玩法(该Activity用了透明主题且顶部区域还能看到房间页面,那就在房间页面展示飘屏即可)
|
||||
TreasureBoxActivity::class.java,
|
||||
BoxRankingActivity::class.java,
|
||||
TreasureBoxHonourActivity::class.java,
|
||||
RoomPKCreateActivity::class.java,
|
||||
SingleRoomPKCreateActivity::class.java,
|
||||
// 房间内私聊(该Activity用了透明主题且顶部区域还能看到房间页面,那就在房间页面展示飘屏即可)
|
||||
// NimRoomP2PMessageActivity::class.java,
|
||||
// RoomMsgActivity::class.java,
|
||||
// 房间内webDialog(该Activity用了透明主题且顶部区域还能看到房间页面,那就在房间页面展示飘屏即可)
|
||||
// RoomBannerWebDialogActivity::class.java,
|
||||
// 升级弹窗
|
||||
LevelUpDialog::class.java
|
||||
)
|
||||
|
||||
val queue = SimpleFloatQueue()
|
||||
|
||||
init {
|
||||
start()
|
||||
}
|
||||
|
||||
fun start() {
|
||||
NIMChatRoomSDK.getChatRoomServiceObserve().observeReceiveMessage(this, true)
|
||||
}
|
||||
|
||||
fun stop() {
|
||||
NIMChatRoomSDK.getChatRoomServiceObserve().observeReceiveMessage(this, false)
|
||||
}
|
||||
|
||||
fun bindActivity(activity: FragmentActivity) {
|
||||
if (!filter(activity)) {
|
||||
logD("bindActivity() 被过滤掉")
|
||||
return
|
||||
}
|
||||
activity.lifecycleScope.launchWhenStarted {
|
||||
bindActivityImpl(activity)
|
||||
this.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
private fun filter(activity: FragmentActivity): Boolean {
|
||||
if (blackActivityList.firstOrNull { it == activity::class.java } != null) {
|
||||
return false
|
||||
}
|
||||
if (!AuthModel.get().isLogin) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private fun bindActivityImpl(activity: FragmentActivity) {
|
||||
val widget = SimpleFloatWindow(activity)
|
||||
widget.maxVisibleCount = 1
|
||||
widget.bindActivity(activity)
|
||||
widget.adapter = NotifyAdapter()
|
||||
var statusHeight = TitleBar.getStatusBarHeight()
|
||||
if (statusHeight <= 0) {
|
||||
statusHeight = ScreenUtil.getStatusBarHeight(activity)
|
||||
}
|
||||
widget.getView().setPadding(0, statusHeight, 0, 0)
|
||||
val engine = FloatWindowEngine(widget, queue)
|
||||
engine.bindLifecycle(activity.lifecycle)
|
||||
engine.start()
|
||||
}
|
||||
|
||||
override fun onEvent(chatRoomMessages: List<ChatRoomMessage>?) {
|
||||
if (ListUtils.isListEmpty(chatRoomMessages)) return
|
||||
if (!AvRoomDataManager.get().hasAvRoomAct) return
|
||||
chatRoomMessages?.forEach { msg->
|
||||
if (msg.msgType == MsgTypeEnum.custom) {
|
||||
val attachment = msg.attachment ?: return
|
||||
val customAttachment = attachment as CustomAttachment
|
||||
val first = customAttachment.first
|
||||
val second = customAttachment.second
|
||||
when (first) {
|
||||
|
||||
// 通用飘屏
|
||||
CustomAttachment.CUSTOM_MSG_TEMPLATE_NOTIFY -> {
|
||||
if (second == CustomAttachment.CUSTOM_MSG_TEMPLATE_NOTIFY_ALL) {
|
||||
val data = Gson().fromJson<RoomTemplateNotifyMsgBean>(
|
||||
customAttachment.data.toString(),
|
||||
RoomTemplateNotifyMsgBean::class.java
|
||||
)
|
||||
if (UserModel.get().isSamePartition(data.partitionId ?: 0)) {
|
||||
queue.addLast(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 礼物
|
||||
CustomAttachment.CUSTOM_MSG_HEADER_TYPE_GIFT -> {
|
||||
if (second == CustomAttachment.CUSTOM_MSG_ALL_SERVICE_GIFT) {
|
||||
" 全服礼物-32 notify ".doLog()
|
||||
val data = Gson().fromJson<AllServiceGiftProtocol.DataBean>(
|
||||
customAttachment.data.toString(),
|
||||
AllServiceGiftProtocol.DataBean::class.java
|
||||
)
|
||||
if (UserModel.get().isSamePartition(data.partitionId)) {
|
||||
queue.addLast(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
// 寻爱之旅
|
||||
CustomAttachment.CUSTOM_MSG_BOX -> {
|
||||
if (second == CustomAttachment.CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA) {
|
||||
handleFindLive(customAttachment)
|
||||
}
|
||||
}
|
||||
// 福袋礼物
|
||||
CustomAttachment.CUSTOM_MSG_LUCKY_GIFT -> {
|
||||
if (second == CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_ALL) {
|
||||
val data = Gson().fromJson<LuckyBagNoticeInfo>(
|
||||
customAttachment.data.toString(),
|
||||
LuckyBagNoticeInfo::class.java
|
||||
)
|
||||
|
||||
if (UserModel.get().isSamePartition(data.partitionId)) {
|
||||
// 添加飘屏
|
||||
queue.addLast(data)
|
||||
// 添加公屏
|
||||
val attachmentNew = RoomReceivedLuckyGiftAttachment(CustomAttachment.CUSTOM_MSG_LUCKY_GIFT_SERVER_NOTIFY)
|
||||
attachmentNew.luckyBagNoticeInfo = data
|
||||
val message = ChatRoomMessageBuilder.createChatRoomCustomMessage(
|
||||
AvRoomDataManager.get().roomId.toString(),
|
||||
attachment
|
||||
)
|
||||
IMNetEaseManager.get().addMessages(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private fun handleFindLive(customAttachment: CustomAttachment) {
|
||||
val data = Gson().fromJson<RoomBoxPrizeInfo>(
|
||||
customAttachment.data.toString(),
|
||||
RoomBoxPrizeInfo::class.java
|
||||
)
|
||||
if (!UserModel.get().isSamePartition(data.partitionId)) {
|
||||
return
|
||||
}
|
||||
val roomBoxPrizeAttachment = RoomBoxPrizeAttachment(
|
||||
CustomAttachment.CUSTOM_MSG_BOX,
|
||||
CustomAttachment.CUSTOM_MSG_SUB_BOX_ALL_ROOM_NOTIFY_BY_SVGA
|
||||
)
|
||||
roomBoxPrizeAttachment.uid = data.uid
|
||||
roomBoxPrizeAttachment.prizeName = data.prizeName
|
||||
roomBoxPrizeAttachment.nick = data.nick
|
||||
roomBoxPrizeAttachment.boxTypeStr = data.boxTypeStr
|
||||
roomBoxPrizeAttachment.roomUid = data.roomUid
|
||||
roomBoxPrizeAttachment.prizeNum = data.prizeNum
|
||||
roomBoxPrizeAttachment.userLevelLimit = data.userLevelLimit
|
||||
val roomId = AvRoomDataManager.get().roomId
|
||||
var message: ChatRoomMessage? = null
|
||||
if (roomId > 0) {
|
||||
message = ChatRoomMessageBuilder.createChatRoomCustomMessage(
|
||||
roomId.toString(),
|
||||
roomBoxPrizeAttachment
|
||||
)
|
||||
}
|
||||
if (AvRoomDataManager.get().isOpenPureMode) {
|
||||
// 純凈模式打開後,僅能看跟自己相關的砸蛋消息
|
||||
if (message != null && roomBoxPrizeAttachment.uid == AuthModel.get().currentUid) {
|
||||
IMNetEaseManager.get().addMessages(message)
|
||||
}
|
||||
} else {
|
||||
if (message != null) {
|
||||
IMNetEaseManager.get().addMessages(message)
|
||||
}
|
||||
queue.addLast(roomBoxPrizeAttachment)
|
||||
}
|
||||
}
|
||||
|
||||
fun clearQueue() {
|
||||
queue.clear()
|
||||
}
|
||||
}
|
@@ -7,15 +7,14 @@ import com.bumptech.glide.load.engine.GlideException
|
||||
import com.bumptech.glide.request.RequestListener
|
||||
import com.bumptech.glide.request.target.Target
|
||||
import com.chwl.app.application.GlobalHandleManager
|
||||
import com.chwl.app.avroom.dialog.BaseRoomNotifyDialog
|
||||
import com.chwl.app.avroom.dialog.RoomBoomRewardDialog
|
||||
import com.chwl.app.avroom.dialog.RoomNotifyBoomDialog
|
||||
import com.chwl.app.avroom.widget.GalleryLayoutManager.LayoutParams
|
||||
import com.chwl.core.gift.bean.BoomInfo
|
||||
import com.chwl.core.gift.bean.BoomMsgAnimBean
|
||||
import com.chwl.core.gift.bean.BoomMsgAwardList
|
||||
import com.chwl.core.gift.bean.BoomMsgDialogBean
|
||||
import com.chwl.core.gift.bean.BoomMsgExpPushBean
|
||||
import com.chwl.core.gift.bean.RoomNotifyDialogBean
|
||||
import com.chwl.core.im.custom.bean.BoomMsgAttachment
|
||||
import com.chwl.core.im.custom.bean.CustomAttachment.BOOM_FIRST
|
||||
import com.chwl.core.im.custom.bean.CustomAttachment.BOOM_SECOND_DIALOG
|
||||
@@ -31,14 +30,10 @@ import com.tencent.qgame.animplayer.AnimView
|
||||
import com.tencent.qgame.animplayer.inter.IAnimListener
|
||||
import java.io.File
|
||||
import java.util.LinkedList
|
||||
//toFix 后续可优化,在队列新建弹窗时 加入复用池,减去重复创建消耗
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
object RoomBoomManager {
|
||||
|
||||
private var dialog: BaseRoomNotifyDialog<*>? = null
|
||||
|
||||
private val queue = LinkedList<BoomMsgDialogBean>()
|
||||
|
||||
private val AnimQueue = LinkedList<BoomMsgAnimBean>()
|
||||
private val awardQueue = LinkedList<BoomMsgAwardList>()
|
||||
private var mAnimLayout: FrameLayout? = null
|
||||
@@ -50,35 +45,9 @@ object RoomBoomManager {
|
||||
fun addDialog(data: BoomMsgDialogBean) {
|
||||
if (!AvRoomDataManager.get().hasAvRoomAct) return
|
||||
LogUtils.dd(" RoomBoomManager addDialog() ")
|
||||
queue.add(data)
|
||||
showNextDialog()
|
||||
RoomNotifyDialogManager.addDialog(RoomNotifyDialogBean(BOOM_FIRST, BOOM_SECOND_DIALOG,data))
|
||||
}
|
||||
|
||||
private fun showNextDialog() {
|
||||
if (dialog?.isShowing == true) {
|
||||
return
|
||||
}
|
||||
|
||||
if (queue.isNotEmpty()) {
|
||||
val data = queue.removeAt(0)
|
||||
dialog = createDialog(data)
|
||||
dialog?.mCallBack = object : BaseRoomNotifyDialog.CallBack {
|
||||
override fun onHide() {
|
||||
showNextDialog()
|
||||
}
|
||||
}
|
||||
dialog?.showDialog()
|
||||
}
|
||||
}
|
||||
|
||||
private fun createDialog(bean: BoomMsgDialogBean): BaseRoomNotifyDialog<*>? {
|
||||
var dialog: BaseRoomNotifyDialog<*>? = null
|
||||
val activity = GlobalHandleManager.get().activity ?: return null
|
||||
dialog = RoomNotifyBoomDialog(activity).apply {
|
||||
data = bean
|
||||
}
|
||||
return dialog
|
||||
}
|
||||
|
||||
|
||||
fun addAnim(data: BoomMsgAnimBean) {
|
||||
@@ -321,9 +290,6 @@ object RoomBoomManager {
|
||||
}
|
||||
|
||||
fun clear() {
|
||||
dialog?.clearDialog()
|
||||
dialog = null
|
||||
queue.clear()
|
||||
|
||||
mAnimLayout = null
|
||||
AnimQueue.clear()
|
||||
|
@@ -1,15 +1,25 @@
|
||||
package com.chwl.app.utils
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.application.GlobalHandleManager
|
||||
import com.chwl.app.avroom.dialog.BaseRoomNotifyDialog
|
||||
import com.chwl.app.avroom.dialog.RoomNotifyBoomDialog
|
||||
import com.chwl.app.avroom.dialog.RoomNotifyCpBindDialog
|
||||
import com.chwl.app.avroom.dialog.RoomNotifyCpGiftDialog
|
||||
import com.chwl.app.avroom.dialog.RoomNotifyLevelUpDialog
|
||||
import com.chwl.app.avroom.dialog.RoomNotifyLuckGiftDialog
|
||||
import com.chwl.app.databinding.LayoutRoomNotifyLuckyGiftTipBinding
|
||||
import com.chwl.core.gift.bean.BoomMsgDialogBean
|
||||
import com.chwl.core.gift.bean.CpMsgBean
|
||||
import com.chwl.core.gift.bean.LuckyGiftMsgAllBean
|
||||
import com.chwl.core.gift.bean.LuckyGiftMsgSelfBean
|
||||
import com.chwl.core.gift.bean.RoomNotifyDialogBean
|
||||
import com.chwl.core.im.custom.bean.CustomAttachment
|
||||
import com.chwl.library.common.util.doLog
|
||||
import com.chwl.library.common.util.setAutoSizeModel
|
||||
import java.util.LinkedList
|
||||
|
||||
/**
|
||||
@@ -19,6 +29,9 @@ object RoomNotifyDialogManager {
|
||||
private val queue = LinkedList<RoomNotifyDialogBean>()
|
||||
private var dialog : BaseRoomNotifyDialog<*>?=null
|
||||
|
||||
private val dialogBuffer = HashMap<Int, BaseRoomNotifyDialog<*>>()
|
||||
private val luckyGiftTipPool = WeakPool<View>(3)
|
||||
|
||||
|
||||
fun addDialog(data : RoomNotifyDialogBean) {
|
||||
queue.add(data)
|
||||
@@ -49,9 +62,16 @@ object RoomNotifyDialogManager {
|
||||
if (bean.first == CustomAttachment.CUSTOM_MSG_SUPER_LUCKY_GIFT_TEMPLATE) {
|
||||
if (bean.second == CustomAttachment.CUSTOM_MSG_SUPER_LUCKY_GIFT_ROOM || bean.second == CustomAttachment.CUSTOM_MSG_SUPER_LUCKY_GIFT_ALL){
|
||||
if (bean.data is LuckyGiftMsgAllBean){
|
||||
dialog = RoomNotifyLuckGiftDialog(activity)
|
||||
dialog.luckyGiftMsgBean = bean.data as LuckyGiftMsgAllBean
|
||||
return dialog
|
||||
if (dialogBuffer.containsKey(bean.first)) {
|
||||
"使用 幸运礼物弹窗缓存".doLog()
|
||||
return dialogBuffer.get(bean.first)
|
||||
} else {
|
||||
"未使用 幸运礼物弹窗缓存".doLog()
|
||||
dialog = RoomNotifyLuckGiftDialog(activity)
|
||||
dialog.luckyGiftMsgBean = bean.data as LuckyGiftMsgAllBean
|
||||
dialogBuffer[bean.first] = dialog
|
||||
return dialog
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(bean.first == CustomAttachment.CP_FIRST){
|
||||
@@ -71,11 +91,55 @@ object RoomNotifyDialogManager {
|
||||
}
|
||||
}
|
||||
|
||||
}else if (bean.first == CustomAttachment.BOOM_FIRST) {
|
||||
if (bean.data is BoomMsgDialogBean) {
|
||||
dialog = RoomNotifyBoomDialog(activity).apply {
|
||||
this.data = bean.data as BoomMsgDialogBean
|
||||
}
|
||||
}
|
||||
}
|
||||
return dialog
|
||||
}
|
||||
|
||||
|
||||
fun showLuckyGiftDlgNotify(
|
||||
notifyLayout: FrameLayout,
|
||||
luckyGiftMsgBean: LuckyGiftMsgSelfBean
|
||||
) {
|
||||
"幸运礼物 球提示 ".doLog()
|
||||
val root: View = luckyGiftTipPool.acquire {
|
||||
"幸运礼物 球提示 未使用缓存".doLog()
|
||||
LayoutInflater.from(notifyLayout.context).inflate(R.layout.layout_room_notify_lucky_gift_tip, notifyLayout, false)
|
||||
}
|
||||
val binding: LayoutRoomNotifyLuckyGiftTipBinding = LayoutRoomNotifyLuckyGiftTipBinding.bind(root)
|
||||
binding.coinNum.text = luckyGiftMsgBean.coins.toString()
|
||||
binding.coinNum.setAutoSizeModel()
|
||||
binding.winNum.text = luckyGiftMsgBean.times.toString()
|
||||
if (luckyGiftMsgBean.level > 1) {
|
||||
binding.rootView.setBackgroundResource(R.drawable.bg_lucky_gift_tip_2)
|
||||
}
|
||||
root.alpha = 0f
|
||||
root.scaleX = 0f
|
||||
root.scaleY = 0f
|
||||
notifyLayout.addView(root)
|
||||
GiftAnimUtil.showAnimation(root)
|
||||
notifyLayout.postDelayed({
|
||||
root.animate()
|
||||
.alpha(0f)
|
||||
.setDuration(500)
|
||||
.withEndAction {
|
||||
notifyLayout.post(Runnable {
|
||||
root.clearAnimation()
|
||||
notifyLayout.removeView(root)
|
||||
luckyGiftTipPool.release(root)
|
||||
})
|
||||
}
|
||||
.start()
|
||||
}, 2300)
|
||||
}
|
||||
|
||||
fun clear() {
|
||||
luckyGiftTipPool?.clear()
|
||||
dialog?.clearDialog()
|
||||
dialog = null
|
||||
queue.clear()
|
||||
|
@@ -17,6 +17,7 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.DataSource
|
||||
import com.bumptech.glide.load.engine.GlideException
|
||||
import com.bumptech.glide.request.RequestListener
|
||||
@@ -133,6 +134,7 @@ class EffectView : FrameLayout {
|
||||
"EffectView loadEffect() effectType = $effectType".doLog(mNeedLog)
|
||||
mEffectType = effectType
|
||||
this@EffectView.post{
|
||||
if (!this@EffectView.isAttachedToWindow) return@post
|
||||
this@EffectView.removeAllViews()
|
||||
when (effectType) {
|
||||
EffectType.IMG -> {
|
||||
@@ -150,47 +152,72 @@ class EffectView : FrameLayout {
|
||||
|
||||
private fun loadImg(resource: File) {
|
||||
"EffectView loadImg() ".doLog(mNeedLog)
|
||||
this@EffectView.post {
|
||||
try {
|
||||
try {
|
||||
val imageView = ImageView(context)
|
||||
this@EffectView.addView(imageView)
|
||||
imageView.setViewWH(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
false
|
||||
)
|
||||
imageView.scaleType = ImageView.ScaleType.FIT_XY
|
||||
|
||||
val fis = FileInputStream(resource)
|
||||
val bitmap = BitmapFactory.decodeStream(fis)
|
||||
|
||||
val imageView = ImageView(context)
|
||||
this@EffectView.addView(imageView)
|
||||
imageView.setViewWH(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
false
|
||||
)
|
||||
imageView.scaleType = ImageView.ScaleType.FIT_XY
|
||||
|
||||
if (hasAnimImg) {
|
||||
val split: List<Drawable> = split(bitmap)
|
||||
|
||||
if (split.isVerify()) {
|
||||
val animationDrawable = AnimationDrawable()
|
||||
for (i in split.indices) {
|
||||
animationDrawable.addFrame(split[i], 200)
|
||||
}
|
||||
imageView.setImageDrawable(animationDrawable)
|
||||
animationDrawable.isOneShot = false
|
||||
animationDrawable.start()
|
||||
} else {
|
||||
imageView.setImageBitmap(bitmap)
|
||||
Glide.with(this)
|
||||
.asBitmap()
|
||||
.dontAnimate()
|
||||
.dontTransform()
|
||||
.load(mResourceUrl)
|
||||
.listener(object : RequestListener<Bitmap?> {
|
||||
override fun onLoadFailed(
|
||||
e: GlideException?,
|
||||
model: Any?,
|
||||
target: Target<Bitmap?>?,
|
||||
isFirstResource: Boolean
|
||||
): Boolean {
|
||||
playCallBack(false)
|
||||
"EffectView loadImg() false".doLog(mNeedLog)
|
||||
return true
|
||||
}
|
||||
|
||||
"EffectView loadImg() start".doLog(mNeedLog)
|
||||
playCallBack(true)
|
||||
} else {
|
||||
imageView.setImageBitmap(bitmap)
|
||||
}
|
||||
|
||||
} catch (e: Exception) {
|
||||
playCallBack(false)
|
||||
"EffectView loadImg() false".doLog(mNeedLog)
|
||||
}
|
||||
override fun onResourceReady(
|
||||
resource: Bitmap?,
|
||||
model: Any?,
|
||||
target: Target<Bitmap?>?,
|
||||
dataSource: DataSource?,
|
||||
isFirstResource: Boolean
|
||||
): Boolean {
|
||||
imageView?.post {
|
||||
if (!imageView.isAttachedToWindow) return@post
|
||||
resource?.let {
|
||||
if (hasAnimImg) {
|
||||
val split: List<Drawable> = split(it)
|
||||
if (split.isVerify()) {
|
||||
val animationDrawable = AnimationDrawable()
|
||||
for (i in split.indices) {
|
||||
animationDrawable.addFrame(split[i], 200)
|
||||
}
|
||||
imageView.setImageDrawable(animationDrawable)
|
||||
animationDrawable.isOneShot = false
|
||||
animationDrawable.start()
|
||||
} else {
|
||||
imageView.setImageBitmap(it)
|
||||
}
|
||||
"EffectView loadImg() start".doLog(mNeedLog)
|
||||
playCallBack(true)
|
||||
} else {
|
||||
"EffectView loadImg() start".doLog(mNeedLog)
|
||||
playCallBack(true)
|
||||
imageView.setImageBitmap(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}).submit()
|
||||
|
||||
} catch (e: Exception) {
|
||||
playCallBack(false)
|
||||
"EffectView loadImg() false".doLog(mNeedLog)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -359,6 +386,7 @@ class EffectView : FrameLayout {
|
||||
object : SVGAParser.ParseCompletion {
|
||||
override fun onComplete(videoItem: SVGAVideoEntity) {
|
||||
svgaView.post {
|
||||
if (!svgaView.isAttachedToWindow) return@post
|
||||
svgaView.setImageDrawable(SVGADrawable(videoItem))
|
||||
svgaView.startAnimation()
|
||||
playCallBack(true)
|
||||
@@ -555,6 +583,7 @@ class EffectView : FrameLayout {
|
||||
private fun playSvga(svgaView:SVGAView,videoItem: SVGAVideoEntity,dynamicEntity: SVGADynamicEntity) {
|
||||
val drawable = SVGADrawable(videoItem, dynamicEntity)
|
||||
svgaView.post {
|
||||
if (!svgaView.isAttachedToWindow) return@post
|
||||
svgaView.setImageDrawable(drawable)
|
||||
svgaView.stepToFrame(0, true)
|
||||
playCallBack(true)
|
||||
|
@@ -98,7 +98,7 @@
|
||||
android:textStyle="bold"
|
||||
android:textSize="36sp"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/sentUserAvatar"
|
||||
app:layout_constraintStart_toEndOf="@+id/bagImg"
|
||||
app:layout_constraintStart_toEndOf="@+id/giftImg"
|
||||
app:layout_constraintTop_toTopOf="@id/sentUserAvatar"
|
||||
tools:text="x1111111" />
|
||||
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.chwl.core.gift;
|
||||
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_ALL_SERVICE_GIFT;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_TYPE_SEND_ALL_MIC_LUCKY_GIFT;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_TYPE_SEND_ALL_SERVICE_GIFT;
|
||||
import static com.chwl.core.im.custom.bean.CustomAttachment.CUSTOM_MSG_SUB_TYPE_SEND_LUCKY_GIFT;
|
||||
@@ -38,6 +39,7 @@ import com.chwl.core.gift.exception.GiftOutOfDateException;
|
||||
import com.chwl.core.gift.toolbox.GiftToolbox;
|
||||
import com.chwl.core.im.custom.bean.CustomAttachment;
|
||||
import com.chwl.core.im.custom.bean.GiftAllServiceAttachment;
|
||||
import com.chwl.core.im.custom.bean.GiftAllServiceNotifyAttachment;
|
||||
import com.chwl.core.im.custom.bean.GiftAttachment;
|
||||
import com.chwl.core.im.custom.bean.GiftBatchAttachment;
|
||||
import com.chwl.core.im.custom.bean.MultiGiftAttachment;
|
||||
@@ -57,6 +59,7 @@ import com.chwl.core.utils.net.BalanceNotEnoughExeption;
|
||||
import com.chwl.core.utils.net.RadishNotEnoughException;
|
||||
import com.chwl.core.utils.net.RxHelper;
|
||||
import com.chwl.core.utils.net.VipLevelNotEnoughException;
|
||||
import com.chwl.library.common.util.OtherExtKt;
|
||||
import com.chwl.library.common.util.SPUtils;
|
||||
import com.chwl.library.net.rxnet.RxNet;
|
||||
import com.chwl.library.utils.ListUtils;
|
||||
@@ -276,6 +279,7 @@ public class GiftModel extends BaseModel implements IGiftModel {
|
||||
LogUtil.i("onReceiveChatRoomMessages", "count--->" + chatRoomMessageList.size());
|
||||
if (msg.getMsgType() == MsgTypeEnum.custom) {
|
||||
CustomAttachment attachment = (CustomAttachment) msg.getAttachment();
|
||||
OtherExtKt.doLog("接收消息 GiftModel.onReceiveChatRoomMessages 3 - Second = "+attachment.getSecond());
|
||||
if (attachment.getFirst() == CustomAttachment.CUSTOM_MSG_HEADER_TYPE_GIFT
|
||||
|| attachment.getFirst() == CustomAttachment.CUSTOM_MSG_HEADER_TYPE_MULTI_GIFT)
|
||||
addGiftMessage(attachment);
|
||||
@@ -299,6 +303,9 @@ public class GiftModel extends BaseModel implements IGiftModel {
|
||||
private void parseChatRoomAttachment(CustomAttachment attachment) {
|
||||
//单人 3 普通单人-31 福袋单人-33
|
||||
if (attachment.getFirst() == CustomAttachment.CUSTOM_MSG_HEADER_TYPE_GIFT) {
|
||||
|
||||
OtherExtKt.doLog("接收消息 GiftModel.parseChatRoomAttachment 3 - Second = "+attachment.getSecond());
|
||||
|
||||
if (attachment.getSecond() == CustomAttachment.CUSTOM_MSG_SUB_TYPE_SEND_GIFT) {
|
||||
GiftAttachment giftAttachment = (GiftAttachment) attachment;
|
||||
IMNetEaseManager.get().getChatRoomEventObservable().onNext(new RoomEvent()
|
||||
@@ -323,6 +330,12 @@ public class GiftModel extends BaseModel implements IGiftModel {
|
||||
.setEvent(RoomEvent.RECEIVE_NORMALE_GIFT_ALL_SERVICE)
|
||||
.setGiftReceiveInfo(giftAllServiceAttachment.getGiftReceiveInfo()));
|
||||
// 全服送礼推送 没有附带礼物值
|
||||
}else if (attachment.getSecond() == CUSTOM_MSG_ALL_SERVICE_GIFT) {
|
||||
//全服礼物 飘屏
|
||||
GiftAllServiceNotifyAttachment giftAllServiceNotifyAttachment = (GiftAllServiceNotifyAttachment) attachment;
|
||||
IMNetEaseManager.get().getChatRoomEventObservable().onNext(new RoomEvent()
|
||||
.setEvent(RoomEvent.RECEIVE_NORMALE_GIFT_ALL_SERVICE_NOTIFY)
|
||||
.setAnyData(giftAllServiceNotifyAttachment.dataBean));
|
||||
}
|
||||
|
||||
} else if (attachment.getFirst() == CustomAttachment.CUSTOM_MSG_HEADER_TYPE_MULTI_GIFT) {//多人12
|
||||
|
@@ -76,12 +76,15 @@ public class CustomAttachParser implements MsgAttachmentParser {
|
||||
break;
|
||||
case CustomAttachment.CUSTOM_MSG_HEADER_TYPE_GIFT:
|
||||
OtherExtKt.doLog("礼物IM消息 收到 first = 3 second = "+second );
|
||||
OtherExtKt.doLog("接收消息 CustomAttachParser 3 - Second = "+second);
|
||||
if (second == CustomAttachment.CUSTOM_MSG_SUB_TYPE_SEND_GIFT) {
|
||||
attachment = new GiftAttachment(first, second);
|
||||
} else if (second == CustomAttachment.CUSTOM_MSG_SUB_TYPE_SEND_LUCKY_GIFT) {
|
||||
attachment = new MultiLuckyGiftAttachment(first, second);
|
||||
}else if (second == CustomAttachment.CUSTOM_MSG_SUB_TYPE_SEND_ALL_SERVICE_GIFT) {
|
||||
attachment = new GiftAllServiceAttachment(first, second);
|
||||
}else if (second == CustomAttachment.CUSTOM_MSG_ALL_SERVICE_GIFT) {
|
||||
attachment = new GiftAllServiceNotifyAttachment(first, second);
|
||||
}
|
||||
break;
|
||||
case CustomAttachment.CUSTOM_MSG_HEADER_TYPE_MULTI_GIFT:
|
||||
|
@@ -0,0 +1,32 @@
|
||||
package com.chwl.core.im.custom.bean
|
||||
|
||||
import com.alibaba.fastjson.JSONObject
|
||||
import com.chwl.core.noble.bean.AllServiceGiftProtocol
|
||||
import com.google.gson.Gson
|
||||
|
||||
// 3 - 32 CUSTOM_MSG_ALL_SERVICE_GIFT , 是全服礼物 飘屏
|
||||
class GiftAllServiceNotifyAttachment (first: Int, second: Int) : CustomAttachment(first, second) {
|
||||
@JvmField
|
||||
var dataBean : AllServiceGiftProtocol.DataBean?=null
|
||||
|
||||
override fun parseData(data: JSONObject?) {
|
||||
super.parseData(data)
|
||||
if (data != null) {
|
||||
try {
|
||||
dataBean = Gson().fromJson<AllServiceGiftProtocol.DataBean>(
|
||||
data.toJSONString(),
|
||||
AllServiceGiftProtocol.DataBean::class.java
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun packData(): JSONObject {
|
||||
val data = JSONObject()
|
||||
return data
|
||||
}
|
||||
|
||||
}
|
@@ -43,7 +43,6 @@ import com.chwl.core.im.custom.bean.CpMsgAttachment;
|
||||
import com.chwl.core.im.custom.bean.CustomAttachment;
|
||||
import com.chwl.core.im.custom.bean.DatingAttachment;
|
||||
import com.chwl.core.im.custom.bean.DatingPublishAttachment;
|
||||
import com.chwl.core.im.custom.bean.GiftAllServiceAttachment;
|
||||
import com.chwl.core.im.custom.bean.GiftAttachment;
|
||||
import com.chwl.core.im.custom.bean.GiftBatchAttachment;
|
||||
import com.chwl.core.im.custom.bean.InAppSharingFamilyAttachment;
|
||||
@@ -824,13 +823,13 @@ public final class IMNetEaseManager {
|
||||
face = true;
|
||||
break;
|
||||
case CUSTOM_MSG_HEADER_TYPE_GIFT:
|
||||
OtherExtKt.doLog("接收消息 IMNetEaseManager 3 - Second = "+customAttachment.getSecond());
|
||||
if (customAttachment.getSecond() == CustomAttachment.CUSTOM_MSG_SUB_TYPE_SEND_GIFT) {
|
||||
GiftAttachment giftAttachment = (GiftAttachment) attachment;
|
||||
GiftReceiveInfo giftReceiveInfo = giftAttachment.getGiftReceiveInfo();
|
||||
GiftInfo giftInfo = giftReceiveInfo.getGift();
|
||||
// 兼容舊版發過來的giftAttachment沒有發送giftInfo的問題
|
||||
giftInfo = giftInfo == null ?
|
||||
GiftModel.get().findGiftInfoById(giftReceiveInfo.getGiftId()) : giftInfo;
|
||||
giftInfo = giftInfo == null ? GiftModel.get().findGiftInfoById(giftReceiveInfo.getGiftId()) : giftInfo;
|
||||
giftReceiveInfo.setGift(giftInfo);
|
||||
GiftModel.get().addNewGift(giftInfo);
|
||||
messages.add(msg);
|
||||
@@ -838,22 +837,12 @@ public final class IMNetEaseManager {
|
||||
if (!giftReceiveInfo.isRoomAlbum() && giftInfo.getGiftType() != GiftType.GIFT_TYPE_SUPER_LUCKY) {
|
||||
addMessages(msg);
|
||||
}
|
||||
}if (customAttachment.getSecond() == CUSTOM_MSG_SUB_TYPE_SEND_ALL_SERVICE_GIFT) {
|
||||
OtherExtKt.doLog(" 接收消息 全服礼物 35 - start");
|
||||
GiftAllServiceAttachment giftAllServiceAttachment = (GiftAllServiceAttachment) attachment;
|
||||
GiftReceiveInfo giftReceiveInfo = giftAllServiceAttachment.getGiftReceiveInfo();
|
||||
GiftInfo giftInfo = giftReceiveInfo.getGift();
|
||||
// 兼容舊版發過來的giftAttachment沒有發送giftInfo的問題
|
||||
giftInfo = giftInfo == null ?
|
||||
GiftModel.get().findGiftInfoById(giftReceiveInfo.getGiftId()) : giftInfo;
|
||||
giftReceiveInfo.setGift(giftInfo);
|
||||
GiftModel.get().addNewGift(giftInfo);
|
||||
}if (customAttachment.getSecond() == CUSTOM_MSG_SUB_TYPE_SEND_ALL_SERVICE_GIFT) { // 35-全服礼物
|
||||
messages.add(msg);
|
||||
gift = true;
|
||||
}if (customAttachment.getSecond() == CUSTOM_MSG_ALL_SERVICE_GIFT) { //32-全服礼物飘屏
|
||||
messages.add(msg);
|
||||
gift = true;
|
||||
// if (!giftReceiveInfo.isRoomAlbum() && giftInfo.getGiftType() != GiftType.GIFT_TYPE_SUPER_LUCKY) {
|
||||
// addMessages(msg);
|
||||
// }
|
||||
OtherExtKt.doLog(" 接收消息 全服礼物 35 - end");
|
||||
} else if (customAttachment.getSecond() == CustomAttachment.CUSTOM_MSG_SUB_TYPE_SEND_LUCKY_GIFT) {
|
||||
messages.add(msg);
|
||||
gift = true;
|
||||
|
@@ -293,6 +293,7 @@ public class RoomEvent {
|
||||
* 收到全服礼物
|
||||
*/
|
||||
public static final int RECEIVE_NORMALE_GIFT_ALL_SERVICE = 118;
|
||||
public static final int RECEIVE_NORMALE_GIFT_ALL_SERVICE_NOTIFY = 120; //全服飘屏
|
||||
|
||||
private int event = NONE;
|
||||
private int micPosition = Integer.MIN_VALUE;
|
||||
|
@@ -264,5 +264,18 @@ fun Long.delayStart( callBack: () -> Unit = {}) : Job{
|
||||
}
|
||||
}
|
||||
|
||||
fun View?.postSafe(run:()->Unit) {
|
||||
this?.post {
|
||||
if (this?.isAttachedToWindow == true) {
|
||||
run()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun View?.postSafe(time:Long,run:()->Unit) {
|
||||
this?.postDelayed({
|
||||
if (this?.isAttachedToWindow == true) {
|
||||
run()
|
||||
}
|
||||
},time)
|
||||
}
|
36
mode.json
36
mode.json
@@ -1,2 +1,34 @@
|
||||
zh-rTW-xxhdpi
|
||||
|
||||
{
|
||||
"data": {
|
||||
"bgLevel": 1,
|
||||
"fullScreen": false,
|
||||
"giftGolds": 60,
|
||||
"giftId": 1979,
|
||||
"giftName": "端午小粽",
|
||||
"giftNum": 1,
|
||||
"giftUrl": "http://beta.img.pekolive.com/Fl4idNRgnahpCmrz0MhV4oNXrPp1?imageslim",
|
||||
"homeShow": true,
|
||||
"i18nGiftNameMap": {
|
||||
"ar": "端午小粽",
|
||||
"en": "端午小粽",
|
||||
"zh": "端午",
|
||||
"tr": "端午小粽"
|
||||
},
|
||||
"levelNum": 1,
|
||||
"notifyStaySecond": 3,
|
||||
"partitionId": 2,
|
||||
"recvUserAvatar": "https://image.pekolive.com/bfed3b08-1ebe-42dc-b9a4-619cb2da0e43.gif",
|
||||
"recvUserNick": "Molistar",
|
||||
"recvUserUid": 3224,
|
||||
"roomErbanNo": 6228657,
|
||||
"roomTitle": "Molistar的房間",
|
||||
"roomUid": 3224,
|
||||
"sendMsg": false,
|
||||
"sendUserAvatar": "https://image.pekolive.com/bfed3b08-1ebe-42dc-b9a4-619cb2da0e43.gif",
|
||||
"sendUserNick": "Molistar",
|
||||
"sendUserUid": 3224,
|
||||
"skipRoom": false
|
||||
},
|
||||
"first": 3,
|
||||
"second": 32
|
||||
}
|
Reference in New Issue
Block a user