feat:完善游戏房、个播房红包展示
feat:完善红包冲突场景
This commit is contained in:
@@ -14,6 +14,7 @@ import com.yizhuan.erban.avroom.firstcharge.FirstChargePrizeDialog
|
||||
import com.yizhuan.erban.avroom.game.GameDelegate
|
||||
import com.yizhuan.erban.avroom.game.OnGameStatusChangeListener
|
||||
import com.yizhuan.erban.avroom.presenter.GameRoomPresenter
|
||||
import com.yizhuan.erban.avroom.redpackage.RedPackageWidget
|
||||
import com.yizhuan.erban.avroom.view.IGameRoomView
|
||||
import com.yizhuan.erban.databinding.FragmentGameRoomBinding
|
||||
import com.yizhuan.erban.ui.widget.GiftDialog.OnGiftDialogBtnClickListener
|
||||
@@ -193,4 +194,13 @@ class GameRoomFragment : BaseRoomFragment<IGameRoomView?, GameRoomPresenter?>(),
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
gameBinding.redPackageWidget.onStop()
|
||||
}
|
||||
|
||||
override fun initWidget() {
|
||||
super.initWidget()
|
||||
registerWidget(RedPackageWidget::class.java.simpleName, gameBinding.redPackageWidget)
|
||||
}
|
||||
}
|
@@ -16,6 +16,7 @@ import com.yizhuan.erban.avroom.adapter.SingleRoomPKMicroViewAdapter
|
||||
import com.yizhuan.erban.avroom.dialog.RequestUpMicDialog
|
||||
import com.yizhuan.erban.avroom.firstcharge.FirstChargePrizeDialog
|
||||
import com.yizhuan.erban.avroom.presenter.SingleRoomPresenter
|
||||
import com.yizhuan.erban.avroom.redpackage.RedPackageWidget
|
||||
import com.yizhuan.erban.avroom.singleroompk.SingleRoomPkFinishDialog
|
||||
import com.yizhuan.erban.avroom.singleroompk.SingleRoomPkForceFinishDialog
|
||||
import com.yizhuan.erban.avroom.singleroompk.SingleRoomPkReceivedDialog
|
||||
@@ -261,4 +262,14 @@ class SingleRoomFragment : BaseRoomFragment<ISingleRoomView?, SingleRoomPresente
|
||||
event.firstChargeRewardList
|
||||
).openDialog()
|
||||
}
|
||||
|
||||
override fun initWidget() {
|
||||
super.initWidget()
|
||||
registerWidget(RedPackageWidget::class.java.simpleName, gameBinding.redPackageWidget)
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
gameBinding.redPackageWidget.onStop()
|
||||
}
|
||||
}
|
@@ -1,8 +1,11 @@
|
||||
package com.yizhuan.erban.avroom.redpackage
|
||||
|
||||
import android.content.Context
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.yizhuan.erban.application.XChatApplication
|
||||
import com.yizhuan.erban.avroom.activity.AVRoomActivity
|
||||
import com.yizhuan.erban.avroom.redpackage.open.RedPackageOpenDialog2
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RedPackageAttachment
|
||||
import com.yizhuan.xchat_android_core.manager.IMNetEaseManager
|
||||
@@ -21,6 +24,14 @@ class RedPackageHandler : RoomHandler() {
|
||||
// 入口图标-数据
|
||||
val iconLiveData: MutableLiveData<RedPackageNotifyInfo?> = MutableLiveData()
|
||||
|
||||
/**
|
||||
* 红包相关操作计数;目前的红包操作为:【正在打开当前房间的红包弹窗】。
|
||||
* 展示时+1,销毁时-1,以此来判断是否正在进行红包操作)
|
||||
*/
|
||||
private var operationCount: Int = 0
|
||||
|
||||
val inOperation get() = operationCount > 0
|
||||
|
||||
override fun onStart(context: RoomContext) {
|
||||
super.onStart(context)
|
||||
registerSignaling()
|
||||
@@ -122,4 +133,31 @@ class RedPackageHandler : RoomHandler() {
|
||||
// updateIcon(null)
|
||||
requestLatestRoomRedPackage()
|
||||
}
|
||||
|
||||
fun startOperation() {
|
||||
operationCount++
|
||||
}
|
||||
|
||||
fun stopOperation() {
|
||||
operationCount--
|
||||
}
|
||||
|
||||
/**
|
||||
* 全服红包信令(之前是在BaseActivity中处理的;现在为了红包的一个需求,暂且拦截到这里处理)
|
||||
*/
|
||||
fun onAllServiceSignaling(context: Context, data: RedPackageNotifyInfo) {
|
||||
if (context is AVRoomActivity) {
|
||||
if (roomContext?.roomId == data.roomUid) {
|
||||
RedPackageOpenDialog2.newInstance(data).show(context)
|
||||
} else {
|
||||
if (!inOperation) {
|
||||
RedPackageGoRoomDialog.newInstance(data).show(context)
|
||||
}else{
|
||||
// 需求:正在房间中领取红包时,不展示其他房间的全服红包
|
||||
}
|
||||
}
|
||||
} else {
|
||||
RedPackageGoRoomDialog.newInstance(data).show(context)
|
||||
}
|
||||
}
|
||||
}
|
@@ -7,7 +7,9 @@ import android.animation.ObjectAnimator
|
||||
import android.animation.ValueAnimator
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import android.view.animation.AccelerateDecelerateInterpolator
|
||||
import androidx.core.view.isVisible
|
||||
@@ -19,6 +21,7 @@ import com.chuhai.utils.log.ILog
|
||||
import com.chuhai.utils.spannable.spannableBuilder
|
||||
import com.trello.rxlifecycle3.android.FragmentEvent
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.avroom.redpackage.RedPackageHandler
|
||||
import com.yizhuan.erban.base.BaseDialog
|
||||
import com.yizhuan.erban.databinding.RedPackageOpenDialogBinding
|
||||
import com.yizhuan.erban.ui.utils.loadAvatar
|
||||
@@ -32,6 +35,7 @@ import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
|
||||
import com.yizhuan.xchat_android_core.pay.PayModel
|
||||
import com.yizhuan.xchat_android_core.redpackage.*
|
||||
import com.yizhuan.xchat_android_core.support.config.Constants
|
||||
import com.yizhuan.xchat_android_core.support.room.RoomContext
|
||||
import com.yizhuan.xchat_android_library.annatation.ActLayoutRes
|
||||
import com.yizhuan.xchat_android_library.utils.SingleToastUtil
|
||||
import io.reactivex.Observable
|
||||
@@ -476,11 +480,21 @@ class RedPackageOpenDialog2 : BaseDialog<RedPackageOpenDialogBinding>(), ILog {
|
||||
binding.tvOpenTips.isVisible = isVisible
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
RoomContext.get()
|
||||
?.findAbility<RedPackageHandler>(RedPackageHandler::class.simpleName)
|
||||
?.startOperation()
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
btnAnimator?.cancel()
|
||||
btnAnimator = null
|
||||
stopCountDown()
|
||||
RoomContext.get()
|
||||
?.findAbility<RedPackageHandler>(RedPackageHandler::class.simpleName)
|
||||
?.stopOperation()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
|
@@ -69,6 +69,7 @@ import com.yizhuan.erban.application.XChatApplication;
|
||||
import com.yizhuan.erban.avroom.activity.AVRoomActivity;
|
||||
import com.yizhuan.erban.avroom.firstcharge.FirstChargeDialog;
|
||||
import com.yizhuan.erban.avroom.redpackage.RedPackageGoRoomDialog;
|
||||
import com.yizhuan.erban.avroom.redpackage.RedPackageHandler;
|
||||
import com.yizhuan.erban.avroom.redpackage.RedPackageOpenDialog;
|
||||
import com.yizhuan.erban.avroom.redpackage.open.RedPackageOpenDialog2;
|
||||
import com.yizhuan.erban.common.LoadingFragment;
|
||||
@@ -123,6 +124,7 @@ import com.yizhuan.xchat_android_core.pay.bean.WalletInfo;
|
||||
import com.yizhuan.xchat_android_core.redpackage.RedPackageNotifyInfo;
|
||||
import com.yizhuan.xchat_android_core.room.bean.RoomInfo;
|
||||
import com.yizhuan.xchat_android_core.room.model.AvRoomModel;
|
||||
import com.yizhuan.xchat_android_core.support.room.RoomContext;
|
||||
import com.yizhuan.xchat_android_core.treasurefairy.FairyMsgInfoBean;
|
||||
import com.yizhuan.xchat_android_core.user.UserModel;
|
||||
import com.yizhuan.xchat_android_core.utils.net.RxHelper;
|
||||
@@ -958,10 +960,19 @@ public abstract class BaseActivity extends RxAppCompatActivity
|
||||
return;
|
||||
RedPackageNotifyInfo notifyInfo = new Gson().fromJson(String.valueOf(baseProtocol.getData()), RedPackageNotifyInfo.class);
|
||||
RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
|
||||
if (roomInfo != null && roomInfo.getUid() == notifyInfo.getRoomUid() && context instanceof AVRoomActivity) {
|
||||
RedPackageOpenDialog2.Companion.newInstance(notifyInfo).show(BaseActivity.this);
|
||||
RoomContext roomContext = RoomContext.Companion.get();
|
||||
RedPackageHandler redPackageHandler = null;
|
||||
if (roomContext != null) {
|
||||
redPackageHandler = roomContext.findAbility(RedPackageHandler.class.getSimpleName());
|
||||
}
|
||||
if (redPackageHandler != null) {
|
||||
redPackageHandler.onAllServiceSignaling(this, notifyInfo);
|
||||
} else {
|
||||
RedPackageGoRoomDialog.Companion.newInstance(notifyInfo).show(this);
|
||||
if (roomInfo != null && roomInfo.getUid() == notifyInfo.getRoomUid() && context instanceof AVRoomActivity) {
|
||||
RedPackageOpenDialog2.Companion.newInstance(notifyInfo).show(BaseActivity.this);
|
||||
} else {
|
||||
RedPackageGoRoomDialog.Companion.newInstance(notifyInfo).show(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
case CUSTOM_MSG_VIP:
|
||||
|
@@ -137,7 +137,6 @@
|
||||
android:layout_marginEnd="90dp"
|
||||
android:layout_marginBottom="@dimen/dp_10" />
|
||||
|
||||
|
||||
<com.yizhuan.erban.ui.widget.rollviewpager.RollPagerView
|
||||
android:id="@+id/activity_img"
|
||||
android:layout_width="45dp"
|
||||
@@ -148,6 +147,17 @@
|
||||
android:layout_marginBottom="8dp"
|
||||
app:rollviewpager_hint_gravity="center" />
|
||||
|
||||
<com.yizhuan.erban.avroom.redpackage.RedPackageWidget
|
||||
android:id="@+id/red_package_widget"
|
||||
android:layout_width="58dp"
|
||||
android:layout_height="58dp"
|
||||
android:layout_above="@id/activity_img"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginEnd="8.5dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/input_layout"
|
||||
android:layout_width="match_parent"
|
||||
|
@@ -206,15 +206,6 @@
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
tools:contentDescription="@string/layout_fragment_single_room_06" />
|
||||
|
||||
<com.yizhuan.erban.avroom.redpackage.RedPackageWidget
|
||||
android:id="@+id/red_package_widget"
|
||||
android:layout_width="58dp"
|
||||
android:layout_height="58dp"
|
||||
android:layout_marginBottom="6dp"
|
||||
app:layout_constraintBottom_toTopOf="@id/iv_treasure_box"
|
||||
app:layout_constraintEnd_toEndOf="@id/iv_treasure_box"
|
||||
app:layout_constraintStart_toStartOf="@id/iv_treasure_box" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_treasure_box"
|
||||
android:layout_width="65dp"
|
||||
@@ -229,6 +220,17 @@
|
||||
tools:contentDescription="@string/layout_fragment_single_room_07"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<com.yizhuan.erban.avroom.redpackage.RedPackageWidget
|
||||
android:id="@+id/red_package_widget"
|
||||
android:layout_width="58dp"
|
||||
android:layout_height="58dp"
|
||||
android:layout_marginBottom="6dp"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"
|
||||
app:layout_constraintBottom_toTopOf="@id/iv_treasure_box"
|
||||
app:layout_constraintEnd_toEndOf="@id/iv_treasure_box"
|
||||
app:layout_constraintStart_toStartOf="@id/iv_treasure_box" />
|
||||
|
||||
<com.yizhuan.erban.avroom.widget.MessageView
|
||||
android:id="@+id/message_view"
|
||||
android:layout_width="0dp"
|
||||
|
@@ -9,6 +9,7 @@ import com.yizhuan.xchat_android_core.support.room.lifecycle.RoomLifecycleRegist
|
||||
/**
|
||||
* Created by Max on 2023/10/26 11:50
|
||||
* Desc:一个房间
|
||||
* @param roomId roomUid
|
||||
**/
|
||||
abstract class RoomContext(val roomId: Long) : ILog {
|
||||
|
||||
@@ -81,7 +82,7 @@ abstract class RoomContext(val roomId: Long) : ILog {
|
||||
/**
|
||||
* 查找组件
|
||||
*/
|
||||
fun <T : RoomAbility> findAbility(key: String): T? {
|
||||
fun <T : RoomAbility> findAbility(key: String?): T? {
|
||||
return abilityList[key] as? T
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user