提现item完成后,reset 重置逻辑
This commit is contained in:
parent
1aea476277
commit
37f73e12c5
|
|
@ -306,7 +306,7 @@ class WithDrawSubActivity : AppViewsEmptyViewModelActivity<ViewBinding>() {
|
|||
private fun updateProgressUI() {
|
||||
with(binding) {
|
||||
val subBean = mCurItem.subItemList[mSelectingIndex]
|
||||
val curProgress = subBean.currentProgress
|
||||
val curProgress = subBean.currentAdProgress
|
||||
progressBar.setProgress(curProgress)
|
||||
tvProgress.text = "$curProgress%"
|
||||
|
||||
|
|
|
|||
|
|
@ -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<WithdrawRecord> {
|
||||
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,
|
||||
)
|
||||
Loading…
Reference in New Issue