feat: 更改类名 ,处理代码区分

This commit is contained in:
max
2024-09-12 19:20:13 +08:00
parent 06c974a6ed
commit e4d44155dc
12 changed files with 61 additions and 86 deletions

View File

@@ -18,7 +18,7 @@ import com.chwl.app.R
import com.chwl.app.avroom.widget.VDHLayout
import com.chwl.app.ui.widget.dialog.BaseDialog
abstract class AllServiceBaseDialog<VB : ViewBinding>(context: Context, theme: Int = 0) : BaseDialog(context, theme) {
abstract class BaseRoomNotifyeBaseDialog<VB : ViewBinding>(context: Context, theme: Int = 0) : BaseDialog(context, theme) {
protected val handle = Handler(Looper.getMainLooper())
protected lateinit var mBinding: VB

View File

@@ -6,31 +6,22 @@ import com.chwl.app.R
import com.chwl.app.avroom.activity.AVRoomActivity
import com.chwl.app.common.widget.dialog.DialogManager
import com.chwl.app.common.widget.dialog.DialogManager.OkCancelDialogListener
import com.chwl.app.databinding.AllServiceLuckGiftDlgBinding
import com.chwl.app.databinding.RoomNotifyLuckGiftDlgBinding
import com.chwl.app.ui.utils.ImageLoadUtils
import com.chwl.app.utils.NumberUtils
import com.chwl.core.gift.bean.LuckyGiftMsgAllBean
import com.chwl.core.gift.bean.MsgSuperLuckyGift
import com.chwl.core.manager.AvRoomDataManager
import com.chwl.core.praise.PraiseModel
import com.chwl.core.room.bean.RoomInfo
import com.chwl.core.room.model.AvRoomModel
import com.chwl.library.language.LanguageHelper
import com.chwl.library.net.rxnet.callback.CallBack
import com.chwl.library.utils.ResUtil
import com.example.lib_utils.UiUtils
import com.tencent.cos.xml.crypto.JSONUtils
/**
* @Author Vance
* 幸运礼物的飘屏全服但是展示的时候限制只有房间才展示
*/
class AllServiceLuckGiftDialog(
private val context: Context
) : AllServiceBaseDialog<AllServiceLuckGiftDlgBinding>(context) {
class BaseRoomNotifyeLuckGiftDialog(private val context: Context) : BaseRoomNotifyeBaseDialog<RoomNotifyLuckGiftDlgBinding>(context) {
override fun createBinding(inflater: LayoutInflater): AllServiceLuckGiftDlgBinding {
return AllServiceLuckGiftDlgBinding.inflate(inflater)
override fun createBinding(inflater: LayoutInflater): RoomNotifyLuckGiftDlgBinding {
return RoomNotifyLuckGiftDlgBinding.inflate(inflater)
}
private var mDialogManager: DialogManager? = null

View File

@@ -10,17 +10,13 @@ import android.graphics.Color
import android.graphics.drawable.Drawable
import android.graphics.drawable.GradientDrawable
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.text.TextUtils
import android.view.KeyEvent
import android.view.LayoutInflater
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.view.ViewStub
import android.widget.EditText
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.RelativeLayout
import android.widget.TextView
@@ -44,7 +40,6 @@ import com.chwl.app.avroom.activity.RoomInviteActivity
import com.chwl.app.avroom.activity.RoomTitleEditActivity
import com.chwl.app.avroom.adapter.OnMicroItemClickListener
import com.chwl.app.avroom.adapter.RoomMessageIndicatorAdapter
import com.chwl.app.avroom.dialog.AllServiceLuckGiftDialog
import com.chwl.app.avroom.dialog.AttentionHintDialog
import com.chwl.app.avroom.dialog.DatingVipRuleDialog
import com.chwl.app.avroom.dialog.RoomGameListDialog
@@ -58,7 +53,6 @@ import com.chwl.app.avroom.widget.MessageView
import com.chwl.app.avroom.widget.MicroView
import com.chwl.app.base.BaseMvpActivity
import com.chwl.app.base.BaseMvpFragment
import com.chwl.app.databinding.LayoutLuckyGiftTipBinding
import com.chwl.app.event.OpenRoomIntroEvent
import com.chwl.app.friend.view.SelectFriendActivity
import com.chwl.app.home.adapter.RoomActAdapter
@@ -79,8 +73,6 @@ import com.chwl.app.ui.widget.rollviewpager.RollPagerView
import com.chwl.app.ui.widget.rollviewpager.Util
import com.chwl.app.ui.widget.rollviewpager.hintview.ColorPointHintView
import com.chwl.app.utils.KeyBoardUtils
import com.chwl.app.utils.NumberUtils
import com.chwl.app.utils.WeakPool
import com.chwl.core.Constants
import com.chwl.core.UriProvider
import com.chwl.core.auth.AuthModel
@@ -99,7 +91,6 @@ import com.chwl.core.manager.AvRoomDataManager
import com.chwl.core.manager.IMNetEaseManager
import com.chwl.core.manager.RoomEvent
import com.chwl.core.mentoring_relationship.event.MentoringStopCountingEvent
import com.chwl.core.pay.PayModel
import com.chwl.core.room.anotherroompk.ShowGiftDialogEvent
import com.chwl.core.room.anotherroompk.ShowUserInfoDialogEvent
import com.chwl.core.room.bean.RightBottomIconConfig
@@ -129,7 +120,6 @@ import com.chwl.library.rxbus.RxBus
import com.chwl.library.utils.JavaUtil
import com.chwl.library.utils.ListUtils
import com.chwl.library.utils.ResUtil
import com.chwl.library.utils.ScreenUtils
import com.chwl.library.utils.SingleToastUtil
import com.chwl.library.utils.UIUtils
import com.google.gson.Gson

View File

@@ -8,7 +8,6 @@ import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
@@ -22,11 +21,9 @@ import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import com.chwl.app.BuildConfig;
import com.chwl.app.avroom.activity.RoomTitleEditActivity;
import com.chwl.app.avroom.dialog.AllServiceLuckGiftDialog;
import com.chwl.app.avroom.helper.RoomViewModel;
import com.chwl.app.databinding.LayoutLuckyGiftTipBinding;
import com.chwl.app.avroom.dialog.BaseRoomNotifyeLuckGiftDialog;
import com.chwl.app.databinding.LayoutRoomNotifyLuckyGiftTipBinding;
import com.chwl.app.utils.GiftAnimUtil;
import com.chwl.app.utils.NumberUtils;
import com.chwl.app.utils.WeakPool;
@@ -34,10 +31,9 @@ import com.chwl.core.auth.AuthModel;
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.Sender;
import com.chwl.core.utils.ComboUtil;
import com.chwl.app.ui.utils.ImageLoadUtilsV2;
import com.chwl.app.ui.widget.GiftComboButtonView;
import com.chwl.app.ui.widget.BonsellaJoinAttackButtonView;
import com.chwl.app.ui.widget.GiftDialog;
import com.chwl.app.ui.widget.UserInfoDialog;
import com.chwl.core.gift.event.GiftComboEvent;
@@ -683,7 +679,7 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
});
gameMainBinding.giftComboBtn.setOnGiftComboEndListener(new GiftComboButtonView.OnGiftComboEndListener() {
gameMainBinding.giftComboBtn.setOnGiftComboEndListener(new BonsellaJoinAttackButtonView.OnGiftComboEndListener() {
@Override
public void onGiftComboEnd() {
gameMainBinding.giftComboBtn.showView(false);
@@ -724,9 +720,9 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
LogUtils.i(" showLuckyGiftDlgNotify = start");
View root = luckyGiftTipPool.acquire(() -> {
return LayoutInflater.from(gameMainBinding.flLuckyGiftNotifyLayout.getContext()).inflate(R.layout.layout_lucky_gift_tip, gameMainBinding.flLuckyGiftNotifyLayout, false);
return LayoutInflater.from(gameMainBinding.flLuckyGiftNotifyLayout.getContext()).inflate(R.layout.layout_room_notify_lucky_gift_tip, gameMainBinding.flLuckyGiftNotifyLayout, false);
});
LayoutLuckyGiftTipBinding binding = LayoutLuckyGiftTipBinding.bind(root);
LayoutRoomNotifyLuckyGiftTipBinding binding = LayoutRoomNotifyLuckyGiftTipBinding.bind(root);
binding.coinNum.setText(NumberUtils.format(luckyGiftMsgBean.getCoins()));
binding.winNum.setText(java.lang.String.valueOf(luckyGiftMsgBean.getTimes()));
if (luckyGiftMsgBean.getLevel() > 1) {
@@ -761,7 +757,7 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
}, 2300);
}
AllServiceLuckGiftDialog allServiceLuckGiftDialog;
BaseRoomNotifyeLuckGiftDialog allServiceLuckGiftDialog;
private void showLuckyGiftDlg(LuckyGiftMsgAllBean luckyGiftMsgAllBean){
LogUtils.d(" LuckyGiftDlg -- showLuckyGiftDlg() ");
mLuckyGiftList.add(luckyGiftMsgAllBean);
@@ -773,9 +769,9 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
}
private void showLuckyGiftDialog(LuckyGiftMsgAllBean luckyGiftMsgAllBean){
LogUtils.d(" LuckyGiftDlg -- showLuckyGiftDialog() ");
allServiceLuckGiftDialog = new AllServiceLuckGiftDialog(requireContext());
allServiceLuckGiftDialog = new BaseRoomNotifyeLuckGiftDialog(requireContext());
allServiceLuckGiftDialog.setLuckyGiftMsgBean(luckyGiftMsgAllBean);
allServiceLuckGiftDialog.setMCallBack(new AllServiceLuckGiftDialog.CallBack() {
allServiceLuckGiftDialog.setMCallBack(new BaseRoomNotifyeLuckGiftDialog.CallBack() {
@Override
public void onHide() {
LogUtils.d(" LuckyGiftDlg -- showLuckyGiftDialog() ->onHide");

View File

@@ -12,12 +12,10 @@ import android.view.LayoutInflater
import android.view.View
import android.widget.FrameLayout
import androidx.core.view.isGone
import androidx.core.view.isVisible
import com.chwl.app.databinding.ViewGiftComboButtonBinding
import com.chwl.app.databinding.ViewBonsellaJoinAttackButtonBinding
import com.chwl.core.utils.ComboUtil
import com.opensource.svgaplayer.SVGACallback
class GiftComboButtonView @JvmOverloads constructor(
class BonsellaJoinAttackButtonView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null
) : FrameLayout(context, attrs) {
@@ -32,7 +30,7 @@ class GiftComboButtonView @JvmOverloads constructor(
}
}
private val mBinding = ViewGiftComboButtonBinding.inflate(LayoutInflater.from(context), this)
private val mBinding = ViewBonsellaJoinAttackButtonBinding.inflate(LayoutInflater.from(context), this)
private val vibrator by lazy {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {

View File

@@ -21,37 +21,37 @@ import androidx.core.view.isVisible
import com.chwl.app.R
import com.chwl.app.ui.utils.ImageLoadUtils
import com.chwl.app.ui.utils.SoftPool
import com.chwl.core.gift.bean.GiftComboInfo
import com.chwl.core.gift.bean.BonsellaJoinAttack
import com.chwl.core.gift.bean.GiftMultiReceiverInfo
import com.chwl.core.utils.LogUtils
import com.chwl.library.utils.ResUtil
import com.example.lib_utils.UiUtils
import java.util.LinkedList
class GiftComboLayout @JvmOverloads constructor(
class BonsellaJoinAttackLayout @JvmOverloads constructor(
context: Context?,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0,
defStyleRes: Int = 0
) : LinearLayout(context, attrs, defStyleAttr, defStyleRes){
private val showingList = LinkedList<GiftComboInfo>()
private val waitingList = LinkedList<GiftComboInfo>()
private val comboMap = linkedMapOf<GiftComboInfo, View>()
private val showingList = LinkedList<BonsellaJoinAttack>()
private val waitingList = LinkedList<BonsellaJoinAttack>()
private val comboMap = linkedMapOf<BonsellaJoinAttack, View>()
private val cacheView = SoftPool<View>(2)
private val inflater = LayoutInflater.from(context)
private val handle = Handler(Looper.getMainLooper()) {
if (it.what == 1) {
viewOut(it.obj as? GiftComboInfo, false)
viewOut(it.obj as? BonsellaJoinAttack, false)
}
true
}
init {
if(isInEditMode){
inflater.inflate(R.layout.item_gift_combo_view, this, true)
inflater.inflate(R.layout.item_gift_combo_view, this, true)
inflater.inflate(R.layout.item_bonsella_join_attack_view, this, true)
inflater.inflate(R.layout.item_bonsella_join_attack_view, this, true)
}
orientation = VERTICAL
}
@@ -61,7 +61,7 @@ class GiftComboLayout @JvmOverloads constructor(
*/
private fun getComboChildView(): View {
val view = cacheView.acquire {
inflater.inflate(R.layout.item_gift_combo_view, this, false)
inflater.inflate(R.layout.item_bonsella_join_attack_view, this, false)
}.apply {
createViewHolder(this)
isVisible = true
@@ -72,38 +72,38 @@ class GiftComboLayout @JvmOverloads constructor(
/**
* add data
*/
fun add(giftComboInfo: GiftComboInfo?) {
fun add(bonsellaJoinAttack: BonsellaJoinAttack?) {
//没有绑定之前不能添加
if (!isAttachedToWindow) {
return
}
if (giftComboInfo == null) {
if (bonsellaJoinAttack == null) {
return
}
var addToWaiting = true
for (comboInfo in showingList) {
if(comboInfo.sentUserid == giftComboInfo.sentUserid && comboInfo.giftId == giftComboInfo.giftId){
comboInfo.giftNumber = giftComboInfo.giftNumber
comboInfo.comboCount = giftComboInfo.comboCount
comboInfo.receiverNumber = giftComboInfo.receiverNumber
if(comboInfo.sentUserid == bonsellaJoinAttack.sentUserid && comboInfo.giftId == bonsellaJoinAttack.giftId){
comboInfo.giftNumber = bonsellaJoinAttack.giftNumber
comboInfo.comboCount = bonsellaJoinAttack.comboCount
comboInfo.receiverNumber = bonsellaJoinAttack.receiverNumber
updateNum(comboInfo)
addToWaiting = false
}
}
for (comboInfo in waitingList) {
if(comboInfo.sentUserid == giftComboInfo.sentUserid && comboInfo.giftId == giftComboInfo.giftId){
comboInfo.giftNumber = giftComboInfo.giftNumber
comboInfo.comboCount = giftComboInfo.comboCount
comboInfo.receiverNumber = giftComboInfo.receiverNumber
if(comboInfo.sentUserid == bonsellaJoinAttack.sentUserid && comboInfo.giftId == bonsellaJoinAttack.giftId){
comboInfo.giftNumber = bonsellaJoinAttack.giftNumber
comboInfo.comboCount = bonsellaJoinAttack.comboCount
comboInfo.receiverNumber = bonsellaJoinAttack.receiverNumber
addToWaiting = false
}
}
if(addToWaiting){
waitingList.add(giftComboInfo)
waitingList.add(bonsellaJoinAttack)
}
showNext()
@@ -112,12 +112,12 @@ class GiftComboLayout @JvmOverloads constructor(
/**
* 更新数量
*/
private fun updateNum(giftComboInfo: GiftComboInfo) {
val view = comboMap[giftComboInfo] ?: return
private fun updateNum(bonsellaJoinAttack: BonsellaJoinAttack) {
val view = comboMap[bonsellaJoinAttack] ?: return
val viewHolder = getViewHolder(view)
viewHolder?.refreshNum(giftComboInfo, true)
handle.removeMessages(1, giftComboInfo)
handle.sendMessageDelayed(Message.obtain(handle, 1, giftComboInfo), COMBO_STAY_TIME * 1000L)
viewHolder?.refreshNum(bonsellaJoinAttack, true)
handle.removeMessages(1, bonsellaJoinAttack)
handle.sendMessageDelayed(Message.obtain(handle, 1, bonsellaJoinAttack), COMBO_STAY_TIME * 1000L)
}
@@ -154,15 +154,15 @@ class GiftComboLayout @JvmOverloads constructor(
/**
* 移除动画
*/
private fun viewOut(giftComboInfo: GiftComboInfo?, isDirectRemove: Boolean) {
giftComboInfo ?: return
val comboView = comboMap.remove(giftComboInfo) ?: return
private fun viewOut(bonsellaJoinAttack: BonsellaJoinAttack?, isDirectRemove: Boolean) {
bonsellaJoinAttack ?: return
val comboView = comboMap.remove(bonsellaJoinAttack) ?: return
val runnable = {
val viewHolder = getViewHolder(comboView)
viewHolder?.clear()
if(!isDirectRemove){
showingList.remove(giftComboInfo)
showingList.remove(bonsellaJoinAttack)
}
removeView(comboView)
cacheView.release(comboView)
@@ -213,7 +213,7 @@ class GiftComboLayout @JvmOverloads constructor(
LogUtils.d(" GiftComboLayout onRoomCustomMsg " )
if (giftInfo==null) return
if (giftInfo.comboCount == 0) return
val comboInfo = GiftComboInfo().apply {
val comboInfo = BonsellaJoinAttack().apply {
giftId = giftInfo.giftId
sentUserid = giftInfo.uid
sentUserName = giftInfo.nick
@@ -255,34 +255,34 @@ class GiftComboLayout @JvmOverloads constructor(
}
@SuppressLint("SetTextI18n")
fun showUi(giftComboInfo: GiftComboInfo) {
fun showUi(bonsellaJoinAttack: BonsellaJoinAttack) {
if (UiUtils.isRtl(context)){
ivLayoutBg.scaleX = -1f
}
refreshNum(giftComboInfo)
tvNick.text = giftComboInfo.sentUserName
if (giftComboInfo.receiverNumber == 1) {
tvReceiverNick.text = giftComboInfo.receiverUserName
refreshNum(bonsellaJoinAttack)
tvNick.text = bonsellaJoinAttack.sentUserName
if (bonsellaJoinAttack.receiverNumber == 1) {
tvReceiverNick.text = bonsellaJoinAttack.receiverUserName
} else {
if (giftComboInfo.isMulti) {
if (bonsellaJoinAttack.isMulti) {
tvReceiverNick.text = ResUtil.getString(R.string.Multiplayer)
} else {
tvReceiverNick.text = ResUtil.getString(R.string.All_mic)
}
}
// tvNumber.text = "x${giftComboInfo.giftNumber * giftComboInfo.receiverNumber * giftComboInfo.comboCount}"
ImageLoadUtils.loadImage(ivGift, giftComboInfo.giftImgUrl)
ImageLoadUtils.loadImage(ivAvatar, giftComboInfo.sentAvatar)
ivAvatar.tag = giftComboInfo
ImageLoadUtils.loadImage(ivGift, bonsellaJoinAttack.giftImgUrl)
ImageLoadUtils.loadImage(ivAvatar, bonsellaJoinAttack.sentAvatar)
ivAvatar.tag = bonsellaJoinAttack
}
/**
* 用于刷新数量
*/
@SuppressLint("SetTextI18n")
fun refreshNum(giftComboInfo: GiftComboInfo, isAnim: Boolean = false) {
val num = giftComboInfo.giftNumber * giftComboInfo.receiverNumber * giftComboInfo.comboCount
fun refreshNum(bonsellaJoinAttack: BonsellaJoinAttack, isAnim: Boolean = false) {
val num = bonsellaJoinAttack.giftNumber * bonsellaJoinAttack.receiverNumber * bonsellaJoinAttack.comboCount
if(num == 0){
tvNumber.isVisible = false
return

View File

@@ -169,13 +169,13 @@
android:layout_height="match_parent" />
<com.chwl.app.ui.widget.GiftComboLayout
<com.chwl.app.ui.widget.BonsellaJoinAttackLayout
android:id="@+id/giftComboLayout"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<com.chwl.app.ui.widget.GiftComboButtonView
<com.chwl.app.ui.widget.BonsellaJoinAttackButtonView
android:id="@+id/giftComboBtn"
android:visibility="invisible"
tools:visibility="visible"

View File

@@ -1,6 +1,6 @@
package com.chwl.core.gift.bean;
public class GiftComboInfo {
public class BonsellaJoinAttack {
public long sentUserid;
public String sentUserName;
public String sentAvatar;