From 096138fc89e0e4bfa01092b4fef9981791c2a92f Mon Sep 17 00:00:00 2001 From: renhaoting <370797079@qq.com> Date: Mon, 19 Jan 2026 15:43:43 +0800 Subject: [PATCH] =?UTF-8?q?0.1=20=E6=AD=A3=E5=9C=A8=E6=8F=90=E7=8E=B0?= =?UTF-8?q?=E9=82=A3=E4=B9=88=20dim=20button=20=E3=80=90=E6=8F=90=E7=8E=B0?= =?UTF-8?q?=E3=80=91=E5=A4=9A=E6=AC=A1=E7=82=B9=E5=87=BB=E6=8F=90=E7=8E=B0?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E5=A6=82=E6=9E=9C=E6=8F=90=E7=8E=B0=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E4=BC=9A=E5=87=BA=E7=8E=B0=E4=B8=A4=E4=B8=AA=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../withdraw/widget/WithDrawItemView.kt | 11 ++++- .../vididin/manager/WithdrawManager.kt | 43 ++++++++++++++++++- 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/gamedog/vididin/features/withdraw/widget/WithDrawItemView.kt b/app/src/main/java/com/gamedog/vididin/features/withdraw/widget/WithDrawItemView.kt index c6bba7e..818ad58 100644 --- a/app/src/main/java/com/gamedog/vididin/features/withdraw/widget/WithDrawItemView.kt +++ b/app/src/main/java/com/gamedog/vididin/features/withdraw/widget/WithDrawItemView.kt @@ -6,6 +6,7 @@ import android.view.LayoutInflater import android.widget.LinearLayout import com.ama.core.architecture.util.ResUtil 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.databinding.WithdrawItemViewBinding as ViewBinding @@ -47,13 +48,19 @@ class WithDrawItemView @JvmOverloads constructor( fun updateProgressAndButUI() { var itemProgress = WithdrawManager.instance().getItemProgress(mItemIndex) * 100 - //var itemState = WithdrawManager.instance().getItemState(mItemIndex) with(mBinding) { progressBar.setProgress(itemProgress.toInt()) 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.alpha = if (canClickable) 1F else 0.5F } diff --git a/app/src/main/java/com/gamedog/vididin/manager/WithdrawManager.kt b/app/src/main/java/com/gamedog/vididin/manager/WithdrawManager.kt index 1352514..f11b9b3 100644 --- a/app/src/main/java/com/gamedog/vididin/manager/WithdrawManager.kt +++ b/app/src/main/java/com/gamedog/vididin/manager/WithdrawManager.kt @@ -87,6 +87,7 @@ class WithdrawManager private constructor() { const val STATE_COULD_WITHDRAW: Int = 1 const val STATE_WITHDRAWING: Int = 2 const val STATE_HAS_WITHDRAWED: Int = 3 + const val STATE_WITHDRAW_SUCCESS: Int = 4 // 提现交易状态 提现状态 0: 未启动 1:提现中,2:提现成功,3:提现失败 const val TRANSACTION_STATE_UNSTART : Int = 0 @@ -115,7 +116,7 @@ class WithdrawManager private constructor() { private fun generateItemList(): MutableList { val itemList = mutableListOf() - 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(2, 10.0, AndroidUtil.randomInt(50, 70), generateSubItemList(10.0))) itemList.add(WithdrawItem(3, 20.0, AndroidUtil.randomInt(50, 70), generateSubItemList(20.0))) @@ -136,6 +137,12 @@ class WithdrawManager private constructor() { return subItemList } + private fun generateSmallItemList(): List { + val subItemList = mutableListOf() + subItemList.add(WithdrawSubItem(0, 0.1, 100, 100, 0.1)) + return subItemList + } + private fun saveInfos2Sp(itemList: MutableList) { SpUtil.instance().putList(SpUtil.KEY_WITHDRAW_ITEM_LIST, itemList) } @@ -216,6 +223,7 @@ class WithdrawManager private constructor() { } fun saveNewWithdrawRecord(newRecord: RecordCash) { + RecordsManager.instance().saveNewWithdrawRecord(newRecord) } @@ -464,6 +472,32 @@ class WithdrawManager private constructor() { 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) { if (itemIndex in 0..mWithdrawItemList.size-1) { val curItem = mWithdrawItemList[itemIndex] @@ -492,7 +526,10 @@ class WithdrawManager private constructor() { withdrawItemSubIndex = withdrawSubItemId withdrawItemLoopIndex = payItemLoopIndex } + saveNewWithdrawRecord(withdrawRecord) + updateItemState(withdrawItemId, withdrawSubItemId, STATE_WITHDRAWING) + notifyItemListChanged() val initReqParam = applyInitFields( PayInitReq()) val initReqResult = NetworkUtil.callApi { @@ -638,9 +675,11 @@ class WithdrawManager private constructor() { withdrawRecord.hasShowResultDialog = false RecordsManager.instance().updateCashRecord(withdrawRecord) + updateItemState(withdrawRecord.withdrawItemIndex, withdrawRecord.withdrawItemSubIndex, STATE_WITHDRAW_SUCCESS) // 2. 事件通知以便更新UI notifyWithdrawResult(withdrawRecord) + notifyItemListChanged() // 3. Statistics StatisticUtil.reportEvents(StatisticUtil.KEY_Withdrawal_Reason, mapOf( @@ -658,6 +697,7 @@ class WithdrawManager private constructor() { // 1. 更新record 并保存 withdrawRecord.withdrawState = TRANSACTION_STATE_SUCCESS RecordsManager.instance().updateCashRecord(withdrawRecord) + updateItemState(withdrawRecord.withdrawItemIndex, withdrawRecord.withdrawItemSubIndex, STATE_HAS_WITHDRAWED) // 2. 更新取现 条目状态 if (withdrawRecord.withdrawItemIndex >= 0) { @@ -666,6 +706,7 @@ class WithdrawManager private constructor() { // 3. event 通知 notifyWithdrawResult(withdrawRecord) + notifyItemListChanged() // 4. Statistic StatisticUtil.reportEvents(StatisticUtil.KEY_Withdrawal_Reason,