发送红包切后台输入密码闪退问题

This commit is contained in:
oujunhui
2020-07-25 15:01:39 +08:00
parent 131288f825
commit 667aa42115

View File

@@ -1,6 +1,5 @@
package com.yizhuan.erban.avroom.redpackage
import android.annotation.SuppressLint
import android.content.Intent
import android.graphics.Paint
@@ -10,8 +9,8 @@ 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.xchat_android_core.redpackage.RedPackageModel
import com.yizhuan.erban.base.BaseDialog
import com.yizhuan.erban.common.widget.dialog.DialogManager
import com.yizhuan.erban.databinding.DialogRedPackageSendBinding
@@ -21,20 +20,15 @@ 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.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.redpackage.ALL_DIAMOND
import com.yizhuan.xchat_android_core.redpackage.ALL_GIFT
import com.yizhuan.xchat_android_core.redpackage.ROOM_DIAMOND
import com.yizhuan.xchat_android_core.redpackage.ROOM_GIFT
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
@@ -59,39 +53,30 @@ class RedPackageSendDialog : BaseDialog<DialogRedPackageSendBinding>(), GridPass
@SuppressLint("SetTextI18n")
override fun init() {
EventBus.getDefault().register(this)
PayModel.get().currentWalletInfo?.let {
binding.tvBalanceNum.text =it.diamondNum.toInt().toString()
binding.tvBalanceNum.text = it.goldNum.toString()
}
val initInfo = InitialModel.get().cacheInitInfo
/**
* 厅内
*/
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}钻石且必须为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.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.editRedNum.hint = "${initInfo.redEnvelopeConfig.roomRedEnvelopeMinNum}-${initInfo.redEnvelopeConfig.roomRedEnvelopeMaxNum}"
}
when (initInfo.redEnvelopedPosition) {
2 -> changeToAll()
else -> changeToNotAll()
@@ -116,7 +101,7 @@ class RedPackageSendDialog : BaseDialog<DialogRedPackageSendBinding>(), GridPass
binding.tvChangeType.callOnClick()
}
binding.tvCharge.setOnClickListener { if (!CommonUtils.isFastDoubleClick(800)){ ChargeActivity.start(context) } }
binding.tvCharge.setOnClickListener { ChargeActivity.start(context) }
binding.ivClose.setOnClickListener { dismissAllowingStateLoss() }
binding.ivHelp.setOnClickListener { DialogWebViewActivity.start(context, UriProvider.getRedPacketRule()) }
binding.ivSend.setOnClickListener {
@@ -141,24 +126,15 @@ class RedPackageSendDialog : BaseDialog<DialogRedPackageSendBinding>(), GridPass
return@setOnClickListener
}
val goldNum = binding.editGoldNum.text.toString().toIntOrDef()
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}!")
if (goldNum % 100 != 0) {
SingleToastUtil.showToast("灵石数必须为100的倍数!")
return@setOnClickListener
}
if (isGift && goldNum.toFloat() / redNum < 1) {//单个礼物红包价值不低于1钻石
if (goldNum < minGold || goldNum > maxGold) {
SingleToastUtil.showToast("灵石数量不能小于${minGold}或大于${maxGold}!")
return@setOnClickListener
}
if (isGift && goldNum.toFloat() / redNum < 1) {//单个礼物红包价值不低于1灵石
SingleToastUtil.showToast("单个红包金额过低")
return@setOnClickListener
}
@@ -210,14 +186,13 @@ 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(), DESUtils.DESAndBase64(password))
AvRoomDataManager.get().mCurrentRoomInfo?.uid.toString(), getRedType(), 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", "发红包成功")
@@ -253,9 +228,4 @@ class RedPackageSendDialog : BaseDialog<DialogRedPackageSendBinding>(), GridPass
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
}
override fun onPause() {
super.onPause()
dismissAllowingStateLoss()
}
}