parent
1864a20dd2
commit
096138fc89
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<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(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<WithdrawSubItem> {
|
||||
val subItemList = mutableListOf<WithdrawSubItem>()
|
||||
subItemList.add(WithdrawSubItem(0, 0.1, 100, 100, 0.1))
|
||||
return subItemList
|
||||
}
|
||||
|
||||
private fun saveInfos2Sp(itemList: MutableList<WithdrawItem>) {
|
||||
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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue