修复红包闪退
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
package com.yizhuan.erban.avroom.redpackage;
|
||||
|
||||
public class RedPackageEvent {
|
||||
}
|
@@ -4,17 +4,16 @@ import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.WindowManager
|
||||
import android.view.animation.AnimationUtils
|
||||
|
||||
import com.yizhuan.xchat_android_core.redpackage.RedPackageNotifyInfo
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.avroom.activity.AVRoomActivity
|
||||
|
||||
import com.yizhuan.erban.base.BaseDialog
|
||||
import com.yizhuan.erban.common.widget.dialog.DialogManager
|
||||
import com.yizhuan.erban.databinding.DialogRedPackageGoRoomBinding
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtils
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
|
||||
import com.yizhuan.xchat_android_core.redpackage.RedPackageNotifyInfo
|
||||
import com.yizhuan.xchat_android_core.utils.subAndReplaceDot
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
|
||||
class RedPackageGoRoomDialog : BaseDialog<DialogRedPackageGoRoomBinding>() {
|
||||
|
||||
@@ -37,6 +36,7 @@ class RedPackageGoRoomDialog : BaseDialog<DialogRedPackageGoRoomBinding>() {
|
||||
override fun onStart() {
|
||||
width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
height = WindowManager.LayoutParams.MATCH_PARENT
|
||||
|
||||
super.onStart()
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ class RedPackageGoRoomDialog : BaseDialog<DialogRedPackageGoRoomBinding>() {
|
||||
AVRoomActivity.start(context, redPackageNotifyInfo.roomUid,
|
||||
AVRoomActivity.FROM_TYPE_ALL_RED, redPackageNotifyInfo.sendUserNick, redPackageNotifyInfo)
|
||||
dismissAllowingStateLoss()
|
||||
EventBus.getDefault().post(RedPackageEvent())
|
||||
}
|
||||
// StatUtil.onEvent("gethongbao_get", "进房抢红包弹窗-进房抢")
|
||||
if (AvRoomDataManager.get().isOwnerOnMic && AvRoomDataManager.get().roomId != redPackageNotifyInfo.roomUid) {
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.yizhuan.erban.avroom.redpackage
|
||||
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Intent
|
||||
import android.graphics.Paint
|
||||
@@ -9,7 +10,6 @@ import android.view.KeyEvent
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import android.widget.TextView
|
||||
import com.jungly.gridpasswordview.GridPasswordView
|
||||
import com.yizhuan.erban.base.BaseDialog
|
||||
import com.yizhuan.erban.common.widget.dialog.DialogManager
|
||||
@@ -20,15 +20,19 @@ import com.yizhuan.erban.ui.pay.ChargeActivity
|
||||
import com.yizhuan.erban.ui.setting.ModifyPwdActivity
|
||||
import com.yizhuan.erban.ui.webview.DialogWebViewActivity
|
||||
import com.yizhuan.xchat_android_core.UriProvider
|
||||
import com.yizhuan.xchat_android_core.auth.AuthModel
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftReceiveInfo
|
||||
import com.yizhuan.xchat_android_core.initial.InitialModel
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
|
||||
import com.yizhuan.xchat_android_core.pay.PayModel
|
||||
import com.yizhuan.xchat_android_core.pay.event.UpdateWalletInfoEvent
|
||||
import com.yizhuan.xchat_android_core.public_chat_hall.event.PublicChatHallPlayGiftAnimationEvent
|
||||
import com.yizhuan.xchat_android_core.redpackage.*
|
||||
import com.yizhuan.xchat_android_core.user.UserModel
|
||||
import com.yizhuan.xchat_android_core.utils.toIntOrDef
|
||||
import com.yizhuan.xchat_android_library.utils.CommonUtils
|
||||
import com.yizhuan.xchat_android_library.utils.SingleToastUtil
|
||||
|
||||
import com.yizhuan.xchat_android_library.utils.codec.DESUtils
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
@@ -53,30 +57,39 @@ class RedPackageSendDialog : BaseDialog<DialogRedPackageSendBinding>(), GridPass
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun init() {
|
||||
|
||||
EventBus.getDefault().register(this)
|
||||
PayModel.get().currentWalletInfo?.let {
|
||||
binding.tvBalanceNum.text = it.goldNum.toString()
|
||||
binding.tvBalanceNum.text =it.diamondNum.toInt().toString()
|
||||
}
|
||||
val initInfo = InitialModel.get().cacheInitInfo
|
||||
fun changeToAll() {
|
||||
isAll = true
|
||||
binding.tvAllRed.alpha = 1f
|
||||
binding.tvRoomRed.alpha = 0.5f
|
||||
binding.indicatorAllRed.visibility = View.VISIBLE
|
||||
binding.indicatorRoomRed.visibility = View.GONE
|
||||
binding.tvGoldNumHint.text = "红包总金额不低于${initInfo.redEnvelopeConfig.serverRedEnvelopeMinAmount}灵石,且必须为100的倍数"
|
||||
binding.editRedNum.hint = "${initInfo.redEnvelopeConfig.serverRedEnvelopeMinNum}-${initInfo.redEnvelopeConfig.serverRedEnvelopeMaxNum}"
|
||||
}
|
||||
|
||||
/**
|
||||
* 厅内
|
||||
*/
|
||||
fun changeToNotAll() {
|
||||
isAll = false
|
||||
binding.tvAllRed.alpha = 0.5f
|
||||
binding.tvRoomRed.alpha = 1f
|
||||
binding.indicatorAllRed.visibility = View.GONE
|
||||
binding.indicatorRoomRed.visibility = View.VISIBLE
|
||||
binding.tvGoldNumHint.text = "红包总金额不低于${initInfo.redEnvelopeConfig.roomRedEnvelopeMinAmount}灵石,且必须为100的倍数"
|
||||
binding.tvGoldNumHint.text = "红包总金额不低于${initInfo.redEnvelopeConfig.roomRedEnvelopeMinAmount}钻石,且必须为10的倍数"
|
||||
binding.editRedNum.hint = "${initInfo.redEnvelopeConfig.roomRedEnvelopeMinNum}-${initInfo.redEnvelopeConfig.roomRedEnvelopeMaxNum}"
|
||||
}
|
||||
|
||||
/**
|
||||
* 全服
|
||||
*/
|
||||
fun changeToAll() {
|
||||
isAll = true
|
||||
binding.tvAllRed.alpha = 1f
|
||||
binding.tvRoomRed.alpha = 0.5f
|
||||
binding.indicatorAllRed.visibility = View.VISIBLE
|
||||
binding.indicatorRoomRed.visibility = View.GONE
|
||||
binding.tvGoldNumHint.text = "红包总金额不低于${initInfo.redEnvelopeConfig.serverRedEnvelopeMinAmount}钻石,且必须为100的倍数"
|
||||
binding.editRedNum.hint = "${initInfo.redEnvelopeConfig.serverRedEnvelopeMinNum}-${initInfo.redEnvelopeConfig.serverRedEnvelopeMaxNum}"
|
||||
}
|
||||
|
||||
when (initInfo.redEnvelopedPosition) {
|
||||
2 -> changeToAll()
|
||||
else -> changeToNotAll()
|
||||
@@ -101,7 +114,7 @@ class RedPackageSendDialog : BaseDialog<DialogRedPackageSendBinding>(), GridPass
|
||||
binding.tvChangeType.callOnClick()
|
||||
}
|
||||
|
||||
binding.tvCharge.setOnClickListener { ChargeActivity.start(context) }
|
||||
binding.tvCharge.setOnClickListener { if (!CommonUtils.isFastDoubleClick(800)){ ChargeActivity.start(context) } }
|
||||
binding.ivClose.setOnClickListener { dismissAllowingStateLoss() }
|
||||
binding.ivHelp.setOnClickListener { DialogWebViewActivity.start(context, UriProvider.getRedPacketRule()) }
|
||||
binding.ivSend.setOnClickListener {
|
||||
@@ -126,15 +139,24 @@ class RedPackageSendDialog : BaseDialog<DialogRedPackageSendBinding>(), GridPass
|
||||
return@setOnClickListener
|
||||
}
|
||||
val goldNum = binding.editGoldNum.text.toString().toIntOrDef()
|
||||
if (goldNum % 100 != 0) {
|
||||
SingleToastUtil.showToast("灵石数必须为100的倍数!")
|
||||
return@setOnClickListener
|
||||
|
||||
if (isAll){
|
||||
if (goldNum % 100 != 0) {
|
||||
SingleToastUtil.showToast("钻石数必须为100的倍数!")
|
||||
return@setOnClickListener
|
||||
}
|
||||
}else{
|
||||
if (goldNum % 10 != 0) {
|
||||
SingleToastUtil.showToast("钻石数必须为10的倍数!")
|
||||
return@setOnClickListener
|
||||
}
|
||||
}
|
||||
|
||||
if (goldNum < minGold || goldNum > maxGold) {
|
||||
SingleToastUtil.showToast("灵石数量不能小于${minGold}或大于${maxGold}!")
|
||||
SingleToastUtil.showToast("钻石数量不能小于${minGold}或大于${maxGold}!")
|
||||
return@setOnClickListener
|
||||
}
|
||||
if (isGift && goldNum.toFloat() / redNum < 1) {//单个礼物红包价值不低于1灵石
|
||||
if (isGift && goldNum.toFloat() / redNum < 1) {//单个礼物红包价值不低于1钻石
|
||||
SingleToastUtil.showToast("单个红包金额过低")
|
||||
return@setOnClickListener
|
||||
}
|
||||
@@ -186,13 +208,14 @@ class RedPackageSendDialog : BaseDialog<DialogRedPackageSendBinding>(), GridPass
|
||||
RedPackageModel.sendRedPackage(binding.editGoldNum.text.toString(),
|
||||
binding.editRedText.text.toString().ifEmpty { "恭喜发财,大吉大利!" },
|
||||
binding.editRedNum.text.toString(),
|
||||
AvRoomDataManager.get().mCurrentRoomInfo?.uid.toString(), getRedType(), password)
|
||||
AvRoomDataManager.get().mCurrentRoomInfo?.uid.toString(), getRedType(), DESUtils.DESAndBase64(password))
|
||||
.doOnError {
|
||||
dialogManager.dismissDialog()
|
||||
SingleToastUtil.showToast(it.message)
|
||||
passWordFragment?.password?.clearPassword()
|
||||
}
|
||||
.subscribe { _ ->
|
||||
PayModel.get().getWalletInfo(AuthModel.get().currentUid).subscribe()
|
||||
dialogManager.dismissDialog()
|
||||
SingleToastUtil.showToast("发送成功")
|
||||
// StatUtil.onEvent("room_sendhongbao_success", "发红包成功")
|
||||
@@ -204,7 +227,7 @@ class RedPackageSendDialog : BaseDialog<DialogRedPackageSendBinding>(), GridPass
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onWalletInfoUpdate(event: UpdateWalletInfoEvent?) {
|
||||
binding.tvBalanceNum.text = PayModel.get().currentWalletInfo?.getGoldNum()?.toString()
|
||||
binding.tvBalanceNum.text = PayModel.get().currentWalletInfo?.diamondNum?.toString()
|
||||
?: "0"
|
||||
}
|
||||
|
||||
@@ -228,4 +251,10 @@ class RedPackageSendDialog : BaseDialog<DialogRedPackageSendBinding>(), GridPass
|
||||
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
|
||||
}
|
||||
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun handleRedPackageDialog(event: RedPackageEvent?) {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user