开启取现item任务后,事件通知及处理
This commit is contained in:
parent
38b8a8d23c
commit
1aea476277
|
|
@ -48,6 +48,7 @@ object VididinEvents {
|
|||
const val EVENT_WITHDRAW_SUB_ITEM_PROGRESS_UPDATED = 500
|
||||
const val EVENT_WITHDRAW_SELECTED_SUB_ITEM_CHANGED = 501
|
||||
const val EVENT_WITHDRAW_CHECK_RESULT_UPDATED = 502
|
||||
const val EVENT_WITHDRAW_ITEM_LIST_CHANGED = 503
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -122,7 +122,10 @@ class WithDrawActivity : AppViewsEmptyViewModelActivity<ViewBinding>() {
|
|||
if (!hasBindBank) {
|
||||
WithdrawBindBankDialog(this@WithDrawActivity, { cashNum -> requestInit(cashNum) }).setWithDrawCashNum(cashNum).show()
|
||||
} else {
|
||||
WithdrawInfoConfirmDialog(this@WithDrawActivity, { cashNum -> requestInit(cashNum) }).setWithDrawCashNum(cashNum).show()
|
||||
WithdrawInfoConfirmDialog(this@WithDrawActivity, {
|
||||
cashNum -> requestInit(cashNum)
|
||||
WithdrawManager.instance().setItemStarted(0)
|
||||
}).setWithDrawCashNum(cashNum).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -136,6 +139,12 @@ class WithDrawActivity : AppViewsEmptyViewModelActivity<ViewBinding>() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun udpateItemListUI() {
|
||||
mItemViewList.forEach {
|
||||
it.updateProgressAndButUI()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun ViewBinding.initListeners() {
|
||||
registerEvents({ data->
|
||||
|
|
@ -161,11 +170,16 @@ class WithDrawActivity : AppViewsEmptyViewModelActivity<ViewBinding>() {
|
|||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
VididinEvents.EVENT_WITHDRAW_ITEM_LIST_CHANGED -> {
|
||||
udpateItemListUI()
|
||||
}
|
||||
}
|
||||
|
||||
}, VididinEvents.Event_Account_Cash_Changed,
|
||||
VididinEvents.EVENT_AD_WATCHED_FOR_WITHDRAW_SMALL,
|
||||
VididinEvents.EVENT_WITHDRAW_CHECK_RESULT_UPDATED,)
|
||||
VididinEvents.EVENT_WITHDRAW_CHECK_RESULT_UPDATED,
|
||||
VididinEvents.EVENT_WITHDRAW_ITEM_LIST_CHANGED)
|
||||
|
||||
readTransactionsAndShowResult()
|
||||
|
||||
|
|
@ -287,6 +301,7 @@ class WithDrawActivity : AppViewsEmptyViewModelActivity<ViewBinding>() {
|
|||
|
||||
private fun gotoWithdrawSubActivity(selectedIndex: Int) {
|
||||
Router.WithdrawSub.startActivity(this, selectedIndex)
|
||||
WithdrawManager.instance().setItemStarted(selectedIndex)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -169,6 +169,11 @@ class WithdrawManager private constructor() {
|
|||
NotifyMan.instance().sendEvent(VididinEvents.EVENT_WITHDRAW_SELECTED_SUB_ITEM_CHANGED, NotifyMan.NotifyData(subBean.index))
|
||||
}
|
||||
|
||||
private fun notifyItemListChanged() {
|
||||
NotifyMan.instance().sendEvent(VididinEvents.EVENT_WITHDRAW_ITEM_LIST_CHANGED, null)
|
||||
}
|
||||
|
||||
|
||||
private fun calculateSubBeanProgress(subBean: WithdrawSubItem) {
|
||||
val needEarnProgress = 100 - subBean.startProgress
|
||||
if (subBean.hasEarnMoneyByAd >= subBean.cashTotal) {
|
||||
|
|
@ -472,6 +477,19 @@ class WithdrawManager private constructor() {
|
|||
return itemProgress
|
||||
}
|
||||
|
||||
fun setItemStarted(itemIndex: Int) {
|
||||
if (itemIndex in 0..mItemList.size-1) {
|
||||
val curItem = mItemList[itemIndex]
|
||||
if (!curItem.hasStarted) {
|
||||
curItem.hasStarted = true
|
||||
curItem.startMs = System.currentTimeMillis()
|
||||
|
||||
saveInfos2Sp(mItemList)
|
||||
notifyItemListChanged()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue