WithdrawItem 更改

This commit is contained in:
renhaoting 2026-01-06 19:14:24 +08:00
parent d47129dea7
commit 0c8e6a2efe
4 changed files with 46 additions and 80 deletions

View File

@ -15,7 +15,7 @@ import com.gamedog.vididin.VidiConst
import com.gamedog.vididin.VididinEvents import com.gamedog.vididin.VididinEvents
import com.gamedog.vididin.beans.WatchAdNotifyBean import com.gamedog.vididin.beans.WatchAdNotifyBean
import com.gamedog.vididin.main.interfaces.OnTabStyleListener import com.gamedog.vididin.main.interfaces.OnTabStyleListener
import com.gamedog.vididin.manager.WithdrawItemBean import com.gamedog.vididin.manager.WithdrawItem
import com.remax.bill.ads.AdResult import com.remax.bill.ads.AdResult
import com.remax.bill.ads.ext.AdShowExt import com.remax.bill.ads.ext.AdShowExt
import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.AndroidEntryPoint
@ -83,7 +83,7 @@ class WatchAdActivity : AppViewsEmptyViewModelActivity<ViewBinding>(), OnTabStyl
notifyEventType = VididinEvents.EVENT_AD_WATCHED_FOR_WITHDRAW_BIG notifyEventType = VididinEvents.EVENT_AD_WATCHED_FOR_WITHDRAW_BIG
val extraData = mExtraJsonStr?.let { val extraData = mExtraJsonStr?.let {
AndroidUtil.json2Object<WithdrawItemBean>(mExtraJsonStr!!) AndroidUtil.json2Object<WithdrawItem>(mExtraJsonStr!!)
} }
notifyData.mData = WatchAdNotifyBean(mRewardedDollarNum, extraData) notifyData.mData = WatchAdNotifyBean(mRewardedDollarNum, extraData)
} }

View File

@ -6,7 +6,6 @@ import android.text.method.ScrollingMovementMethod
import android.view.LayoutInflater import android.view.LayoutInflater
import androidx.activity.viewModels import androidx.activity.viewModels
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.ama.core.architecture.appBase.AppViewsEmptyViewModelActivity import com.ama.core.architecture.appBase.AppViewsEmptyViewModelActivity
@ -25,7 +24,7 @@ import com.gamedog.vididin.features.withdraw.dialogs.WithdrawBindBankDialog
import com.gamedog.vididin.features.withdraw.dialogs.WithdrawFailDialog import com.gamedog.vididin.features.withdraw.dialogs.WithdrawFailDialog
import com.gamedog.vididin.features.withdraw.dialogs.WithdrawInfoConfirmDialog import com.gamedog.vididin.features.withdraw.dialogs.WithdrawInfoConfirmDialog
import com.gamedog.vididin.features.withdraw.dialogs.WithdrawSuccessDialog import com.gamedog.vididin.features.withdraw.dialogs.WithdrawSuccessDialog
import com.gamedog.vididin.manager.WithdrawItemBean import com.gamedog.vididin.manager.WithdrawItem
import com.gamedog.vididin.manager.WithdrawManager import com.gamedog.vididin.manager.WithdrawManager
import com.gamedog.vididin.manager.WithdrawManager.Companion.INIT_OK import com.gamedog.vididin.manager.WithdrawManager.Companion.INIT_OK
import com.gamedog.vididin.manager.WithdrawManager.Companion.TRANSACTION_STATE_FAIL import com.gamedog.vididin.manager.WithdrawManager.Companion.TRANSACTION_STATE_FAIL
@ -44,7 +43,7 @@ import com.viddin.videos.free.databinding.ActivityWithdrawSubBinding as ViewBind
class WithDrawSubActivity : AppViewsEmptyViewModelActivity<ViewBinding>() { class WithDrawSubActivity : AppViewsEmptyViewModelActivity<ViewBinding>() {
private val viewModel: WithdrawViewModel by viewModels() private val viewModel: WithdrawViewModel by viewModels()
private lateinit var mCurItem: WithdrawItemBean private lateinit var mCurItem: WithdrawItem
private var mSelectingIndex: Int = 0 private var mSelectingIndex: Int = 0
private var mType: Int = 0 private var mType: Int = 0
private val mAdapter: WithdrawSubAdapter by lazy { WithdrawSubAdapter( { itemIndex -> private val mAdapter: WithdrawSubAdapter by lazy { WithdrawSubAdapter( { itemIndex ->
@ -228,7 +227,7 @@ class WithDrawSubActivity : AppViewsEmptyViewModelActivity<ViewBinding>() {
registerEvents({ data-> registerEvents({ data->
when (data?.mEventType) { when (data?.mEventType) {
VididinEvents.EVENT_AD_WATCHED_FOR_WITHDRAW_BIG -> { VididinEvents.EVENT_AD_WATCHED_FOR_WITHDRAW_BIG -> {
handleAdWatched(data.mData as WatchAdNotifyBean<WithdrawItemBean>) handleAdWatched(data.mData as WatchAdNotifyBean<WithdrawItem>)
} }
VididinEvents.EVENT_WITHDRAW_SUB_ITEM_PROGRESS_UPDATED -> { VididinEvents.EVENT_WITHDRAW_SUB_ITEM_PROGRESS_UPDATED -> {
@ -282,7 +281,7 @@ class WithDrawSubActivity : AppViewsEmptyViewModelActivity<ViewBinding>() {
} }
} }
private fun handleAdWatched(adNotifyBean: WatchAdNotifyBean<WithdrawItemBean>) { private fun handleAdWatched(adNotifyBean: WatchAdNotifyBean<WithdrawItem>) {
val withdrawItemBean = adNotifyBean.extraData val withdrawItemBean = adNotifyBean.extraData
if (WithdrawManager.instance().addAdEarnForSubBean(withdrawItemBean.index, if (WithdrawManager.instance().addAdEarnForSubBean(withdrawItemBean.index,
mSelectingIndex, adNotifyBean.earnMoneyNum * VidiConst.WITHDRAW_REWARD_AD_REVENUE_PERCENT)) { mSelectingIndex, adNotifyBean.earnMoneyNum * VidiConst.WITHDRAW_REWARD_AD_REVENUE_PERCENT)) {

View File

@ -39,10 +39,10 @@ class WithdrawSubAdapter(private val selectCallback: (index: Int)->Unit) : ListA
tvDay.text = buildString { tvDay.text = buildString {
append(ResUtil.getString(R.string.day)) append(ResUtil.getString(R.string.day))
append(" ") append(" ")
append(item.index + 1) append(item.dayIndex + 1)
} }
if (item.index == mSelectedSubIndex) { if (item.dayIndex == mSelectedSubIndex) {
root.setBackgroundResource(R.drawable.bg_withdraw_sub_selected) root.setBackgroundResource(R.drawable.bg_withdraw_sub_selected)
root.alpha = 1F root.alpha = 1F
ivLefttopChecked.isVisible = true ivLefttopChecked.isVisible = true
@ -57,7 +57,7 @@ class WithdrawSubAdapter(private val selectCallback: (index: Int)->Unit) : ListA
class DiffCallback : DiffUtil.ItemCallback<WithdrawSubItem>() { class DiffCallback : DiffUtil.ItemCallback<WithdrawSubItem>() {
override fun areItemsTheSame(oldItem: WithdrawSubItem, newItem: WithdrawSubItem): Boolean { override fun areItemsTheSame(oldItem: WithdrawSubItem, newItem: WithdrawSubItem): Boolean {
return oldItem.index == newItem.index return oldItem.dayIndex == newItem.dayIndex
} }
override fun areContentsTheSame(oldItem: WithdrawSubItem, newItem: WithdrawSubItem): Boolean { override fun areContentsTheSame(oldItem: WithdrawSubItem, newItem: WithdrawSubItem): Boolean {

View File

@ -11,8 +11,6 @@ import com.gamedog.statisticreporter.StatisticUtil
import com.gamedog.vididin.VidiConst import com.gamedog.vididin.VidiConst
import com.gamedog.vididin.VididinEvents import com.gamedog.vididin.VididinEvents
import com.gamedog.vididin.beans.RECORD_CASH_MINUS_WITHDRAW_SUCCESS import com.gamedog.vididin.beans.RECORD_CASH_MINUS_WITHDRAW_SUCCESS
import com.gamedog.vididin.beans.RECORD_CASH_PLUS_WITHDRAW_FAIL
import com.gamedog.vididin.beans.RECORD_CASH_PLUS_WITHDRAW_ONGOING
import com.gamedog.vididin.beans.RecordCash import com.gamedog.vididin.beans.RecordCash
import com.gamedog.vididin.beans.req.PayInitReq import com.gamedog.vididin.beans.req.PayInitReq
import com.gamedog.vididin.beans.req.PayoutCheckReq import com.gamedog.vididin.beans.req.PayoutCheckReq
@ -32,15 +30,15 @@ import java.util.concurrent.locks.ReentrantLock
class WithdrawManager private constructor() { class WithdrawManager private constructor() {
private val backgroundScope = CoroutineScope(SupervisorJob() + Dispatchers.IO) private val mBgScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
private val mRecordLocker = ReentrantLock() private val mRecordLocker = ReentrantLock()
private val mRecordList: MutableList<WithdrawRecord> by lazy { private val mRecordList: MutableList<WithdrawRecord> by lazy {
SpUtil.instance().getList<WithdrawRecord>(SpUtil.KEY_WITHDRAW_HISTORY_LIST).toMutableList() SpUtil.instance().getList<WithdrawRecord>(SpUtil.KEY_WITHDRAW_HISTORY_LIST).toMutableList()
} }
private val mItemList: MutableList<WithdrawItemBean> by lazy { private val mWithdrawItemList: MutableList<WithdrawItem> by lazy {
val itemList = SpUtil.instance().getList<WithdrawItemBean>(SpUtil.KEY_WITHDRAW_ITEM_LIST).toMutableList() val itemList = SpUtil.instance().getList<WithdrawItem>(SpUtil.KEY_WITHDRAW_ITEM_LIST).toMutableList()
if (itemList.isEmpty()) { if (itemList.isEmpty()) {
itemList.addAll(generateItemList()) itemList.addAll(generateItemList())
saveInfos2Sp(itemList) saveInfos2Sp(itemList)
@ -116,14 +114,14 @@ class WithdrawManager private constructor() {
private fun generateItemList(): MutableList<WithdrawItemBean> { private fun generateItemList(): MutableList<WithdrawItem> {
val itemList = mutableListOf<WithdrawItemBean>() val itemList = mutableListOf<WithdrawItem>()
itemList.add(WithdrawItemBean(0, 0.1, isBigWithDraw = false)) itemList.add(WithdrawItem(0, 0.1, isBigWithDraw = false))
itemList.add(WithdrawItemBean(1, 10.0, AndroidUtil.randomInt(50, 70), generateSubItemList(10.0))) itemList.add(WithdrawItem(1, 10.0, AndroidUtil.randomInt(50, 70), generateSubItemList(10.0)))
itemList.add(WithdrawItemBean(2, 20.0, AndroidUtil.randomInt(50, 70), generateSubItemList(20.0))) itemList.add(WithdrawItem(2, 20.0, AndroidUtil.randomInt(50, 70), generateSubItemList(20.0)))
itemList.add(WithdrawItemBean(3, 50.0, AndroidUtil.randomInt(50, 70), generateSubItemList(50.0))) itemList.add(WithdrawItem(3, 50.0, AndroidUtil.randomInt(50, 70), generateSubItemList(50.0)))
itemList.add(WithdrawItemBean(4, 100.0, AndroidUtil.randomInt(50, 70), generateSubItemList(100.0))) itemList.add(WithdrawItem(4, 100.0, AndroidUtil.randomInt(50, 70), generateSubItemList(100.0)))
itemList.add(WithdrawItemBean(5, 300.0, AndroidUtil.randomInt(50, 70), generateSubItemList(300.0))) itemList.add(WithdrawItem(5, 300.0, AndroidUtil.randomInt(50, 70), generateSubItemList(300.0)))
return itemList return itemList
} }
@ -138,16 +136,16 @@ class WithdrawManager private constructor() {
return subItemList return subItemList
} }
private fun saveInfos2Sp(itemList: MutableList<WithdrawItemBean>) { private fun saveInfos2Sp(itemList: MutableList<WithdrawItem>) {
SpUtil.instance().putList(SpUtil.KEY_WITHDRAW_ITEM_LIST, itemList) SpUtil.instance().putList(SpUtil.KEY_WITHDRAW_ITEM_LIST, itemList)
} }
fun getItemList(): List<WithdrawItemBean> { fun getItemList(): List<WithdrawItem> {
return mItemList return mWithdrawItemList
} }
fun getItem(itemIndex: Int): WithdrawItemBean { fun getItem(itemIndex: Int): WithdrawItem {
return mItemList[itemIndex] return mWithdrawItemList[itemIndex]
} }
@ -176,12 +174,12 @@ class WithdrawManager private constructor() {
} }
fun addAdEarnForSubBean(itemIndex: Int, selectedSubIndex: Int, earnMoneyNum: Double) : Boolean { fun addAdEarnForSubBean(itemIndex: Int, selectedSubIndex: Int, earnMoneyNum: Double) : Boolean {
if (itemIndex >= 0 && itemIndex < mItemList.size) { if (itemIndex >= 0 && itemIndex < mWithdrawItemList.size) {
try { try {
val subBean = mItemList[itemIndex].subItemList[selectedSubIndex] val subBean = mWithdrawItemList[itemIndex].subItemList[selectedSubIndex]
subBean.hasEarnMoneyByAd += earnMoneyNum * 5 // dollar 2 bariz subBean.hasEarnMoneyByAd += earnMoneyNum * 5 // dollar 2 bariz
calculateSubBeanProgress(subBean) //传入 itembean 更新 selectedIndex为下一个 calculateSubBeanProgress(subBean) //传入 itembean 更新 selectedIndex为下一个
saveInfos2Sp(mItemList) saveInfos2Sp(mWithdrawItemList)
notifyProgressUpdated(subBean) notifyProgressUpdated(subBean)
return true return true
} catch (e: Exception) { } catch (e: Exception) {
@ -194,11 +192,11 @@ class WithdrawManager private constructor() {
private fun notifyProgressUpdated(subBean: WithdrawSubItem) { private fun notifyProgressUpdated(subBean: WithdrawSubItem) {
NotifyMan.instance().sendEvent(VididinEvents.EVENT_WITHDRAW_SUB_ITEM_PROGRESS_UPDATED, NotifyMan.instance().sendEvent(VididinEvents.EVENT_WITHDRAW_SUB_ITEM_PROGRESS_UPDATED,
NotifyMan.NotifyData(subBean.index)) NotifyMan.NotifyData(subBean.dayIndex))
} }
private fun notifySelectedSubBeanChanged(subBean: WithdrawSubItem) { private fun notifySelectedSubBeanChanged(subBean: WithdrawSubItem) {
NotifyMan.instance().sendEvent(VididinEvents.EVENT_WITHDRAW_SELECTED_SUB_ITEM_CHANGED, NotifyMan.NotifyData(subBean.index)) NotifyMan.instance().sendEvent(VididinEvents.EVENT_WITHDRAW_SELECTED_SUB_ITEM_CHANGED, NotifyMan.NotifyData(subBean.dayIndex))
} }
private fun notifyItemListChanged() { private fun notifyItemListChanged() {
@ -222,13 +220,13 @@ class WithdrawManager private constructor() {
fun updateSubBeanState(subBean: WithdrawSubItem, newState: Int) { fun updateSubBeanState(subBean: WithdrawSubItem, newState: Int) {
subBean.withdrawState = newState subBean.withdrawState = newState
saveInfos2Sp(mItemList) saveInfos2Sp(mWithdrawItemList)
} }
fun startItem(curItem: WithdrawItemBean) { fun startItem(curItem: WithdrawItem) {
if (curItem.startMs <= 0L) { if (curItem.startMs <= 0L) {
curItem.startMs = DateUtil.getCurTimeMs() - (if (curItem.totalCashNum == 50.0) 24 * 3600000 * 4 else 0) curItem.startMs = DateUtil.getCurTimeMs() - (if (curItem.totalCashNum == 50.0) 24 * 3600000 * 4 else 0)
saveInfos2Sp(mItemList) saveInfos2Sp(mWithdrawItemList)
} }
} }
@ -289,7 +287,7 @@ class WithdrawManager private constructor() {
needReset = true needReset = true
} else { } else {
var allSubItemFinish = true var allSubItemFinish = true
mItemList[itemIndex].subItemList.forEach { mWithdrawItemList[itemIndex].subItemList.forEach {
if (it.withdrawState != STATE_HAS_WITHDRAWED) { if (it.withdrawState != STATE_HAS_WITHDRAWED) {
allSubItemFinish = false allSubItemFinish = false
return@forEach return@forEach
@ -305,7 +303,7 @@ class WithdrawManager private constructor() {
} }
private fun resetItem(itemIndex: Int) { private fun resetItem(itemIndex: Int) {
val needResetItem = mItemList[itemIndex] val needResetItem = mWithdrawItemList[itemIndex]
needResetItem.apply { needResetItem.apply {
totalProgress = 0 totalProgress = 0
startMs = 0L startMs = 0L
@ -370,7 +368,9 @@ class WithdrawManager private constructor() {
mRecordLocker.lock() mRecordLocker.lock()
mRecordList.forEachIndexed { index, record -> mRecordList.forEachIndexed { index, record ->
if (record.state == TRANSACTION_STATE_ONGOING) { if (record.state == TRANSACTION_STATE_ONGOING) {
doTransactionCheck(record.recordNo, record.cashNum) mBgScope.launch {
requestCheck(record.recordNo)
}
} }
} }
} finally { } finally {
@ -379,13 +379,7 @@ class WithdrawManager private constructor() {
} }
} }
private fun doTransactionCheck(recordNo: String, cashNum: Double) { private suspend fun requestCheck(recordNo: String) {
backgroundScope.launch {
performNetworkRequest(recordNo)
}
}
private suspend fun performNetworkRequest(recordNo: String) {
val requestParam = applyInitFields(PayoutCheckReq()).apply { val requestParam = applyInitFields(PayoutCheckReq()).apply {
record_no = recordNo record_no = recordNo
} }
@ -569,39 +563,12 @@ class WithdrawManager private constructor() {
} }
private fun getStartedItemRestCashNum(itemIndex: Int): Double {
if (itemIndex in 0..mItemList.size-1) {
val curItem = mItemList[itemIndex]
if (curItem.hasStarted) {
var hasWithdrawedCash = 0.0
curItem.subItemList.forEach { subItem->
if (subItem.withdrawState == STATE_HAS_WITHDRAWED) {
hasWithdrawedCash += subItem.cashTotal
}
}
return curItem.totalCashNum - hasWithdrawedCash
}
}
return 0.0
}
/*private fun getStartedItemRestCashCount(): Double {
var allStartedItemRestCashNum = 0.0
mItemList.forEachIndexed { index, item ->
if (!(TaskManager.instance().newbieFirstWithdrawStatus().getStatusBean().hasClaimReward && index == 0)) {
allStartedItemRestCashNum += getStartedItemRestCashNum(index)
}
}
return allStartedItemRestCashNum
}*/
fun getItemProgress(itemIndex: Int): Double { fun getItemProgress(itemIndex: Int): Double {
var itemProgress = 0.0 var itemProgress = 0.0
if (itemIndex in 0..mItemList.size-1) { if (itemIndex in 0..mWithdrawItemList.size-1) {
val curItem = mItemList[itemIndex] val curItem = mWithdrawItemList[itemIndex]
val userCashTotal = AccountManager.getCash() val userCashTotal = AccountManager.getCash()
if (curItem.hasStarted) { if (curItem.hasStarted) {
return 1.0 return 1.0
@ -614,13 +581,13 @@ class WithdrawManager private constructor() {
} }
fun setItemStarted(itemIndex: Int) { fun setItemStarted(itemIndex: Int) {
if (itemIndex in 0..mItemList.size-1) { if (itemIndex in 0..mWithdrawItemList.size-1) {
val curItem = mItemList[itemIndex] val curItem = mWithdrawItemList[itemIndex]
if (!curItem.hasStarted) { if (!curItem.hasStarted) {
curItem.hasStarted = true curItem.hasStarted = true
curItem.startMs = System.currentTimeMillis() curItem.startMs = System.currentTimeMillis()
AccountManager.adjustCash(-1 * curItem.totalCashNum) AccountManager.adjustCash(-1 * curItem.totalCashNum)
saveInfos2Sp(mItemList) saveInfos2Sp(mWithdrawItemList)
notifyItemListChanged() notifyItemListChanged()
} }
} }
@ -630,7 +597,7 @@ class WithdrawManager private constructor() {
} }
data class WithdrawItemBean( data class WithdrawItem(
val index: Int, val index: Int,
val totalCashNum: Double, val totalCashNum: Double,
var totalProgress: Int = 0, var totalProgress: Int = 0,
@ -641,7 +608,7 @@ data class WithdrawItemBean(
) )
data class WithdrawSubItem( data class WithdrawSubItem(
val index: Int, val dayIndex: Int,
val cashTotal: Double, val cashTotal: Double,
val startAdProgress: Int = 0, val startAdProgress: Int = 0,
var currentAdProgress: Int = 0, var currentAdProgress: Int = 0,