0.1 正在提现那么 dim button

【提现】多次点击提现按钮如果提现失败会出现两个失败弹窗
This commit is contained in:
renhaoting 2026-01-19 15:43:43 +08:00
parent 1864a20dd2
commit 096138fc89
2 changed files with 51 additions and 3 deletions

View File

@ -6,6 +6,7 @@ import android.view.LayoutInflater
import android.widget.LinearLayout import android.widget.LinearLayout
import com.ama.core.architecture.util.ResUtil import com.ama.core.architecture.util.ResUtil
import com.gamedog.vididin.manager.WithdrawManager import com.gamedog.vididin.manager.WithdrawManager
import com.gamedog.vididin.manager.WithdrawManager.Companion.STATE_WITHDRAWING
import com.viddin.videos.free.R import com.viddin.videos.free.R
import com.viddin.videos.free.databinding.WithdrawItemViewBinding as ViewBinding import com.viddin.videos.free.databinding.WithdrawItemViewBinding as ViewBinding
@ -47,13 +48,19 @@ class WithDrawItemView @JvmOverloads constructor(
fun updateProgressAndButUI() { fun updateProgressAndButUI() {
var itemProgress = WithdrawManager.instance().getItemProgress(mItemIndex) * 100 var itemProgress = WithdrawManager.instance().getItemProgress(mItemIndex) * 100
//var itemState = WithdrawManager.instance().getItemState(mItemIndex)
with(mBinding) { with(mBinding) {
progressBar.setProgress(itemProgress.toInt()) progressBar.setProgress(itemProgress.toInt())
tvProgress.text = String.format("%.2f", itemProgress) + ResUtil.getString(R.string.percent) tvProgress.text = String.format("%.2f", itemProgress) + ResUtil.getString(R.string.percent)
var canClickable: Boolean = itemProgress >= 100F var is01Withdrawing = false
if (mItemIndex == 0) {
is01Withdrawing = WithdrawManager.instance().getItemState(mItemIndex, 0) == STATE_WITHDRAWING
}
// update ui
val canClickable: Boolean = itemProgress >= 100F && !is01Withdrawing
tvSacar.isClickable = canClickable tvSacar.isClickable = canClickable
tvSacar.alpha = if (canClickable) 1F else 0.5F tvSacar.alpha = if (canClickable) 1F else 0.5F
} }

View File

@ -87,6 +87,7 @@ class WithdrawManager private constructor() {
const val STATE_COULD_WITHDRAW: Int = 1 const val STATE_COULD_WITHDRAW: Int = 1
const val STATE_WITHDRAWING: Int = 2 const val STATE_WITHDRAWING: Int = 2
const val STATE_HAS_WITHDRAWED: Int = 3 const val STATE_HAS_WITHDRAWED: Int = 3
const val STATE_WITHDRAW_SUCCESS: Int = 4
// 提现交易状态 提现状态 0: 未启动 1:提现中,2:提现成功,3:提现失败 // 提现交易状态 提现状态 0: 未启动 1:提现中,2:提现成功,3:提现失败
const val TRANSACTION_STATE_UNSTART : Int = 0 const val TRANSACTION_STATE_UNSTART : Int = 0
@ -115,7 +116,7 @@ class WithdrawManager private constructor() {
private fun generateItemList(): MutableList<WithdrawItem> { private fun generateItemList(): MutableList<WithdrawItem> {
val itemList = mutableListOf<WithdrawItem>() val itemList = mutableListOf<WithdrawItem>()
itemList.add(WithdrawItem(0, 0.1, isBigWithDraw = false)) itemList.add(WithdrawItem(0, 0.1, 100, generateSmallItemList(), isBigWithDraw = false))
itemList.add(WithdrawItem(1, 1.0, AndroidUtil.randomInt(50, 70), generateSubItemList(1.0))) itemList.add(WithdrawItem(1, 1.0, AndroidUtil.randomInt(50, 70), generateSubItemList(1.0)))
itemList.add(WithdrawItem(2, 10.0, AndroidUtil.randomInt(50, 70), generateSubItemList(10.0))) itemList.add(WithdrawItem(2, 10.0, AndroidUtil.randomInt(50, 70), generateSubItemList(10.0)))
itemList.add(WithdrawItem(3, 20.0, AndroidUtil.randomInt(50, 70), generateSubItemList(20.0))) itemList.add(WithdrawItem(3, 20.0, AndroidUtil.randomInt(50, 70), generateSubItemList(20.0)))
@ -136,6 +137,12 @@ class WithdrawManager private constructor() {
return subItemList return subItemList
} }
private fun generateSmallItemList(): List<WithdrawSubItem> {
val subItemList = mutableListOf<WithdrawSubItem>()
subItemList.add(WithdrawSubItem(0, 0.1, 100, 100, 0.1))
return subItemList
}
private fun saveInfos2Sp(itemList: MutableList<WithdrawItem>) { private fun saveInfos2Sp(itemList: MutableList<WithdrawItem>) {
SpUtil.instance().putList(SpUtil.KEY_WITHDRAW_ITEM_LIST, itemList) SpUtil.instance().putList(SpUtil.KEY_WITHDRAW_ITEM_LIST, itemList)
} }
@ -216,6 +223,7 @@ class WithdrawManager private constructor() {
} }
fun saveNewWithdrawRecord(newRecord: RecordCash) { fun saveNewWithdrawRecord(newRecord: RecordCash) {
RecordsManager.instance().saveNewWithdrawRecord(newRecord) RecordsManager.instance().saveNewWithdrawRecord(newRecord)
} }
@ -464,6 +472,32 @@ class WithdrawManager private constructor() {
return itemProgress return itemProgress
} }
fun getItemState(itemIndex: Int, subItemIndex: Int): Int {
if (itemIndex in 0..mWithdrawItemList.size-1) {
val curItem = mWithdrawItemList[itemIndex]
if (subItemIndex in 0..curItem.subItemList.size - 1) {
return curItem.subItemList[subItemIndex].withdrawState
}
}
return STATE_NEED_WATCH_AD
}
private fun updateItemState(
itemIndex: Int,
subItemIndex: Int,
newState: Int
) {
if (itemIndex in 0..mWithdrawItemList.size-1) {
val curItem = mWithdrawItemList[itemIndex]
if (subItemIndex in 0..curItem.subItemList.size - 1) {
curItem.subItemList[subItemIndex].withdrawState = newState
saveInfos2Sp(mWithdrawItemList)
}
}
}
fun setItemStarted(itemIndex: Int) { fun setItemStarted(itemIndex: Int) {
if (itemIndex in 0..mWithdrawItemList.size-1) { if (itemIndex in 0..mWithdrawItemList.size-1) {
val curItem = mWithdrawItemList[itemIndex] val curItem = mWithdrawItemList[itemIndex]
@ -492,7 +526,10 @@ class WithdrawManager private constructor() {
withdrawItemSubIndex = withdrawSubItemId withdrawItemSubIndex = withdrawSubItemId
withdrawItemLoopIndex = payItemLoopIndex withdrawItemLoopIndex = payItemLoopIndex
} }
saveNewWithdrawRecord(withdrawRecord) saveNewWithdrawRecord(withdrawRecord)
updateItemState(withdrawItemId, withdrawSubItemId, STATE_WITHDRAWING)
notifyItemListChanged()
val initReqParam = applyInitFields( PayInitReq()) val initReqParam = applyInitFields( PayInitReq())
val initReqResult = NetworkUtil.callApi { val initReqResult = NetworkUtil.callApi {
@ -638,9 +675,11 @@ class WithdrawManager private constructor() {
withdrawRecord.hasShowResultDialog = false withdrawRecord.hasShowResultDialog = false
RecordsManager.instance().updateCashRecord(withdrawRecord) RecordsManager.instance().updateCashRecord(withdrawRecord)
updateItemState(withdrawRecord.withdrawItemIndex, withdrawRecord.withdrawItemSubIndex, STATE_WITHDRAW_SUCCESS)
// 2. 事件通知以便更新UI // 2. 事件通知以便更新UI
notifyWithdrawResult(withdrawRecord) notifyWithdrawResult(withdrawRecord)
notifyItemListChanged()
// 3. Statistics // 3. Statistics
StatisticUtil.reportEvents(StatisticUtil.KEY_Withdrawal_Reason, mapOf( StatisticUtil.reportEvents(StatisticUtil.KEY_Withdrawal_Reason, mapOf(
@ -658,6 +697,7 @@ class WithdrawManager private constructor() {
// 1. 更新record 并保存 // 1. 更新record 并保存
withdrawRecord.withdrawState = TRANSACTION_STATE_SUCCESS withdrawRecord.withdrawState = TRANSACTION_STATE_SUCCESS
RecordsManager.instance().updateCashRecord(withdrawRecord) RecordsManager.instance().updateCashRecord(withdrawRecord)
updateItemState(withdrawRecord.withdrawItemIndex, withdrawRecord.withdrawItemSubIndex, STATE_HAS_WITHDRAWED)
// 2. 更新取现 条目状态 // 2. 更新取现 条目状态
if (withdrawRecord.withdrawItemIndex >= 0) { if (withdrawRecord.withdrawItemIndex >= 0) {
@ -666,6 +706,7 @@ class WithdrawManager private constructor() {
// 3. event 通知 // 3. event 通知
notifyWithdrawResult(withdrawRecord) notifyWithdrawResult(withdrawRecord)
notifyItemListChanged()
// 4. Statistic // 4. Statistic
StatisticUtil.reportEvents(StatisticUtil.KEY_Withdrawal_Reason, StatisticUtil.reportEvents(StatisticUtil.KEY_Withdrawal_Reason,