From 37f73e12c553812f1c41d72d19915a39cdc823fa Mon Sep 17 00:00:00 2001 From: renhaoting <370797079@qq.com> Date: Mon, 22 Dec 2025 17:34:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E7=8E=B0item=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E5=90=8E=EF=BC=8Creset=20=E9=87=8D=E7=BD=AE=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../features/withdraw/WithDrawSubActivity.kt | 2 +- .../vididin/manager/WithdrawManager.kt | 58 ++++++++++++++++--- 2 files changed, 52 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/gamedog/vididin/features/withdraw/WithDrawSubActivity.kt b/app/src/main/java/com/gamedog/vididin/features/withdraw/WithDrawSubActivity.kt index f05a728..cc7ff1b 100644 --- a/app/src/main/java/com/gamedog/vididin/features/withdraw/WithDrawSubActivity.kt +++ b/app/src/main/java/com/gamedog/vididin/features/withdraw/WithDrawSubActivity.kt @@ -306,7 +306,7 @@ class WithDrawSubActivity : AppViewsEmptyViewModelActivity() { private fun updateProgressUI() { with(binding) { val subBean = mCurItem.subItemList[mSelectingIndex] - val curProgress = subBean.currentProgress + val curProgress = subBean.currentAdProgress progressBar.setProgress(curProgress) tvProgress.text = "$curProgress%" 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 e1c9a45..01aef68 100644 --- a/app/src/main/java/com/gamedog/vididin/manager/WithdrawManager.kt +++ b/app/src/main/java/com/gamedog/vididin/manager/WithdrawManager.kt @@ -175,16 +175,16 @@ class WithdrawManager private constructor() { private fun calculateSubBeanProgress(subBean: WithdrawSubItem) { - val needEarnProgress = 100 - subBean.startProgress + val needEarnProgress = 100 - subBean.startAdProgress if (subBean.hasEarnMoneyByAd >= subBean.cashTotal) { - subBean.currentProgress = 100 + subBean.currentAdProgress = 100 // update state if (subBean.withdrawState == STATE_NEED_WATCH_AD) { subBean.withdrawState = STATE_COULD_WITHDRAW } } else { - val newProgress = subBean.startProgress + (needEarnProgress * (subBean.hasEarnMoneyByAd / subBean.cashTotal)).toInt() - subBean.currentProgress = if (newProgress >= 100) 99 else newProgress + val newProgress = subBean.startAdProgress + (needEarnProgress * (subBean.hasEarnMoneyByAd / subBean.cashTotal)).toInt() + subBean.currentAdProgress = if (newProgress >= 100) 100 else newProgress } } @@ -238,6 +238,10 @@ class WithdrawManager private constructor() { needSaveSp =true record.state = newState record.failReason = failType + + if (newState == STATE_HAS_WITHDRAWED) { + checkIfItemFinishAndReset(record.itemIndex) + } } return@forEachIndexed } @@ -246,12 +250,52 @@ class WithdrawManager private constructor() { mRecordLocker.unlock() } - if (needSaveSp) { saveRecords2Sp() } } + private fun checkIfItemFinishAndReset(itemIndex: Int) { + var needReset = false + if (itemIndex == 0) { + needReset = true + } else { + var allSubItemFinish = true + mItemList[itemIndex].subItemList.forEach { + if (it.withdrawState != STATE_HAS_WITHDRAWED) { + allSubItemFinish = false + return@forEach + } + } + + needReset = allSubItemFinish + } + + if (needReset) { + resetItem(itemIndex) + } + } + + private fun resetItem(itemIndex: Int) { + val needResetItem = mItemList[itemIndex] + needResetItem.apply { + totalProgress = 0 + startMs = 0L + hasStarted = false + + subItemList.forEach { subItem -> + subItem.apply { + currentAdProgress = startAdProgress + hasEarnMoneyByAd = 0F + withdrawState = STATE_NEED_WATCH_AD + } + } + } + + notifyItemListChanged() + } + + fun getClonedRecordList(): List { try { mRecordLocker.lock() @@ -507,8 +551,8 @@ data class WithdrawItemBean( data class WithdrawSubItem( val index: Int, val cashTotal: Float, - val startProgress: Int = 0, - var currentProgress: Int = 0, + val startAdProgress: Int = 0, + var currentAdProgress: Int = 0, var hasEarnMoneyByAd: Float = 0F, var withdrawState: Int = STATE_NEED_WATCH_AD, ) \ No newline at end of file