winAct 的 adapter中实现 提现

This commit is contained in:
renhaoting 2025-12-25 18:42:56 +08:00
parent 08a81b1c7e
commit 900f39e3bd
6 changed files with 72 additions and 20 deletions

View File

@ -54,4 +54,8 @@ object VididinEvents {
const val EVENT_WITHDRAW_ITEM_LIST_CHANGED = 503 const val EVENT_WITHDRAW_ITEM_LIST_CHANGED = 503
// zero withdraw events
const val EVENT_ZERO_WITHDRAW_LIST_CHANGED = 200
} }

View File

@ -32,5 +32,9 @@ data class ZeroBuyItem (
data class ZeroBuyWithdrawResp (
val code: Int,
val message: String,
val content: String,
)

View File

@ -11,7 +11,10 @@ import androidx.lifecycle.repeatOnLifecycle
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.ama.core.architecture.appBase.AppViewsEmptyViewModelActivity import com.ama.core.architecture.appBase.AppViewsEmptyViewModelActivity
import com.ama.core.architecture.util.CommonItemDecoration import com.ama.core.architecture.util.CommonItemDecoration
import com.gamedog.vididin.VididinEvents
import com.gamedog.vididin.VididinEvents.EVENT_ZERO_WITHDRAW_LIST_CHANGED
import com.gamedog.vididin.beans.ZeroBuyResp import com.gamedog.vididin.beans.ZeroBuyResp
import com.gamedog.vididin.beans.resp.WithdrawRecord
import com.gamedog.vididin.features.zero.ZeroBuyViewModel import com.gamedog.vididin.features.zero.ZeroBuyViewModel
import com.gamedog.vididin.features.zero.ZeroRecordAdapter import com.gamedog.vididin.features.zero.ZeroRecordAdapter
import com.vididin.real.money.game.R import com.vididin.real.money.game.R
@ -60,7 +63,18 @@ class WinRecordsActivity : AppViewsEmptyViewModelActivity<ViewBinding>(), OnTabS
} }
override fun ViewBinding.initListeners() { override fun ViewBinding.initListeners() {
//TODO("Not yet implemented")
registerEvents({ data->
when (data?.mEventType) {
VididinEvents.EVENT_ZERO_WITHDRAW_LIST_CHANGED -> {
mAdapter.notifyDataSetChanged()
}
}
}, VididinEvents.EVENT_ZERO_WITHDRAW_LIST_CHANGED,)
requestData() requestData()
} }

View File

@ -5,10 +5,13 @@ import com.ama.core.architecture.util.AndroidUtil
import com.ama.core.architecture.util.DeviceUtil import com.ama.core.architecture.util.DeviceUtil
import com.ama.core.architecture.util.MD5Util import com.ama.core.architecture.util.MD5Util
import com.ama.core.architecture.util.SpUtil import com.ama.core.architecture.util.SpUtil
import com.ama.core.architecture.util.eventbus.NotifyMan
import com.gamedog.vididin.VidiConst import com.gamedog.vididin.VidiConst
import com.gamedog.vididin.VidiConst.ZEROBUY_SECRET import com.gamedog.vididin.VidiConst.ZEROBUY_SECRET
import com.gamedog.vididin.VididinEvents
import com.gamedog.vididin.beans.ZeroBuyItem import com.gamedog.vididin.beans.ZeroBuyItem
import com.gamedog.vididin.beans.ZeroBuyResp import com.gamedog.vididin.beans.ZeroBuyResp
import com.gamedog.vididin.beans.ZeroBuyWithdrawResp
import com.gamedog.vididin.core.login.login.AccountManager import com.gamedog.vididin.core.login.login.AccountManager
import com.gamedog.vididin.features.withdraw.dialogs.WithdrawBindBankDialog import com.gamedog.vididin.features.withdraw.dialogs.WithdrawBindBankDialog
import com.gamedog.vididin.features.withdraw.dialogs.WithdrawInfoConfirmDialog import com.gamedog.vididin.features.withdraw.dialogs.WithdrawInfoConfirmDialog
@ -24,6 +27,7 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import kotlin.Int import kotlin.Int
@ -41,21 +45,18 @@ class ZeroManager private constructor() {
} }
} }
private val backgroundScope = CoroutineScope(SupervisorJob() + Dispatchers.IO) private val mBgScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
private val mWinZeroList: MutableList<WinZeroWithdrawInfoItem> by lazy { private val mWinZeroList: MutableList<WinZeroWithdrawInfoItem> by lazy {
SpUtil.instance().getList<WinZeroWithdrawInfoItem>(SpUtil.KEY_ZEROBUY_WIN_ITEMS).toMutableList() SpUtil.instance().getList<WinZeroWithdrawInfoItem>(SpUtil.KEY_ZEROBUY_WIN_ITEMS).toMutableList()
} }
private fun saveWinWithdrawInfos() { private fun saveWinWithdrawInfos() {
SpUtil.instance().putList(SpUtil.KEY_ZEROBUY_WIN_ITEMS, mWinZeroList) SpUtil.instance().putList(SpUtil.KEY_ZEROBUY_WIN_ITEMS, mWinZeroList)
notifyChangeUpdate()
} }
fun getWinItemList() : List<WinZeroWithdrawInfoItem> { private fun notifyChangeUpdate() {
return mWinZeroList NotifyMan.instance().sendEvent(VididinEvents.EVENT_ZERO_WITHDRAW_LIST_CHANGED, null)
}
fun addOrUpdateWinItem() {
} }
@ -128,7 +129,7 @@ class ZeroManager private constructor() {
private fun requestWithdrawZeroReward(zeroWithdrawItem: WinZeroWithdrawInfoItem) { private fun requestWithdrawZeroReward(zeroWithdrawItem: WinZeroWithdrawInfoItem) {
backgroundScope.launch { mBgScope.launch {
// header // header
val operationVal = VidiConst.ZERO_WITHDRAW_OPERATION val operationVal = VidiConst.ZERO_WITHDRAW_OPERATION
val curTimeSec = System.currentTimeMillis()/1000 val curTimeSec = System.currentTimeMillis()/1000
@ -160,18 +161,21 @@ class ZeroManager private constructor() {
val result = NetworkUtil.post("${VidiConst.URL_ZERO_BUY}/any", requestHeaders, requestParams, joinZeroBuyItemIds) val result = NetworkUtil.post("${VidiConst.URL_ZERO_BUY}/any", requestHeaders, requestParams, joinZeroBuyItemIds)
when (result) { when (result) {
is Result.Success -> { is Result.Success -> {
val respObj = AndroidUtil.json2Object<ZeroBuyResp>(result.data.string()) val respObj = AndroidUtil.json2Object<ZeroBuyWithdrawResp>(result.data.string())
respObj?.contentObj?.let { respObj?.let {
if (respObj.code == 0 && respObj.Content.isNotEmpty()) { if (it.code == 0 && it.content.isNotEmpty()) {
zeroWithdrawItem.orderId = respObj.Content zeroWithdrawItem.orderId = respObj.content
zeroWithdrawItem.withdrawState = TRANSACTION_STATE_ONGOING zeroWithdrawItem.withdrawState = TRANSACTION_STATE_ONGOING
saveWinWithdrawInfos() saveWinWithdrawInfos()
AndroidUtil.showToast(R.string.zero_withdraw_ongoing)
return@launch return@launch
} else { } else {
zeroWithdrawItem.withdrawState = TRANSACTION_STATE_FAIL zeroWithdrawItem.withdrawState = TRANSACTION_STATE_FAIL
zeroWithdrawItem.failReason = respObj.code zeroWithdrawItem.failReason = respObj.code
saveWinWithdrawInfos() saveWinWithdrawInfos()
AndroidUtil.showToast(R.string.zero_withdraw_failed)
} }
} }
} }
@ -190,7 +194,7 @@ class ZeroManager private constructor() {
if (couldStartWithdraw(item)) { if (couldStartWithdraw(item)) {
val onConfirmed: (cashNum: Float)->Unit = { val onConfirmed: (cashNum: Float)->Unit = {
requestWithdrawZeroReward(zeroWithdrawInfoItem)
} }
if (AccountManager.isBankAccountExist()) { if (AccountManager.isBankAccountExist()) {

View File

@ -212,6 +212,8 @@
<string name="zero_win_state_withdrarw_ongoing">Processing</string> <string name="zero_win_state_withdrarw_ongoing">Processing</string>
<string name="zero_win_state_failed">Failed</string> <string name="zero_win_state_failed">Failed</string>
<string name="zero_win_state_withdrarw_success">Paid</string> <string name="zero_win_state_withdrarw_success">Paid</string>
<string name="zero_withdraw_failed">Claim reward failed</string>
<string name="zero_withdraw_ongoing">The withdraw request has submitted successfully</string>
</resources> </resources>

View File

@ -35,18 +35,42 @@ class AndroidUtil private constructor() {
} }
fun showTopToast(strRes: Int) { fun showTopToast(strRes: Int) {
Toast.makeText(BaseApp.appContext(), strRes, Toast.LENGTH_SHORT).apply { if (Looper.getMainLooper() != Looper.myLooper()) {
setGravity(Gravity.TOP, 0, 0) val handler = Handler(Looper.getMainLooper())
show() handler.post {
Toast.makeText(BaseApp.appContext(), strRes, Toast.LENGTH_SHORT).apply {
setGravity(Gravity.TOP, 0, 0)
show()
}
}
} else {
Toast.makeText(BaseApp.appContext(), strRes, Toast.LENGTH_SHORT).apply {
setGravity(Gravity.TOP, 0, 0)
show()
}
} }
} }
fun showToast(strRes: Int) { fun showToast(strRes: Int) {
Toast.makeText(BaseApp.appContext(), strRes, Toast.LENGTH_SHORT).show() if (Looper.getMainLooper() != Looper.myLooper()) {
val handler = Handler(Looper.getMainLooper())
handler.post {
Toast.makeText(BaseApp.appContext(), strRes, Toast.LENGTH_SHORT).show()
}
} else {
Toast.makeText(BaseApp.appContext(), strRes, Toast.LENGTH_SHORT).show()
}
} }
fun showToast(str: String) { fun showToast(str: String) {
Toast.makeText(BaseApp.appContext(), str, Toast.LENGTH_SHORT).show() if (Looper.getMainLooper() != Looper.myLooper()) {
val handler = Handler(Looper.getMainLooper())
handler.post {
Toast.makeText(BaseApp.appContext(), str, Toast.LENGTH_SHORT).show()
}
} else {
Toast.makeText(BaseApp.appContext(), str, Toast.LENGTH_SHORT).show()
}
} }
fun openUrl(url: String) { fun openUrl(url: String) {