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
// 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 com.ama.core.architecture.appBase.AppViewsEmptyViewModelActivity
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.resp.WithdrawRecord
import com.gamedog.vididin.features.zero.ZeroBuyViewModel
import com.gamedog.vididin.features.zero.ZeroRecordAdapter
import com.vididin.real.money.game.R
@ -60,7 +63,18 @@ class WinRecordsActivity : AppViewsEmptyViewModelActivity<ViewBinding>(), OnTabS
}
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()
}

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.MD5Util
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.ZEROBUY_SECRET
import com.gamedog.vididin.VididinEvents
import com.gamedog.vididin.beans.ZeroBuyItem
import com.gamedog.vididin.beans.ZeroBuyResp
import com.gamedog.vididin.beans.ZeroBuyWithdrawResp
import com.gamedog.vididin.core.login.login.AccountManager
import com.gamedog.vididin.features.withdraw.dialogs.WithdrawBindBankDialog
import com.gamedog.vididin.features.withdraw.dialogs.WithdrawInfoConfirmDialog
@ -24,6 +27,7 @@ import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
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 {
SpUtil.instance().getList<WinZeroWithdrawInfoItem>(SpUtil.KEY_ZEROBUY_WIN_ITEMS).toMutableList()
}
private fun saveWinWithdrawInfos() {
SpUtil.instance().putList(SpUtil.KEY_ZEROBUY_WIN_ITEMS, mWinZeroList)
notifyChangeUpdate()
}
fun getWinItemList() : List<WinZeroWithdrawInfoItem> {
return mWinZeroList
}
fun addOrUpdateWinItem() {
private fun notifyChangeUpdate() {
NotifyMan.instance().sendEvent(VididinEvents.EVENT_ZERO_WITHDRAW_LIST_CHANGED, null)
}
@ -128,7 +129,7 @@ class ZeroManager private constructor() {
private fun requestWithdrawZeroReward(zeroWithdrawItem: WinZeroWithdrawInfoItem) {
backgroundScope.launch {
mBgScope.launch {
// header
val operationVal = VidiConst.ZERO_WITHDRAW_OPERATION
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)
when (result) {
is Result.Success -> {
val respObj = AndroidUtil.json2Object<ZeroBuyResp>(result.data.string())
val respObj = AndroidUtil.json2Object<ZeroBuyWithdrawResp>(result.data.string())
respObj?.contentObj?.let {
if (respObj.code == 0 && respObj.Content.isNotEmpty()) {
zeroWithdrawItem.orderId = respObj.Content
respObj?.let {
if (it.code == 0 && it.content.isNotEmpty()) {
zeroWithdrawItem.orderId = respObj.content
zeroWithdrawItem.withdrawState = TRANSACTION_STATE_ONGOING
saveWinWithdrawInfos()
AndroidUtil.showToast(R.string.zero_withdraw_ongoing)
return@launch
} else {
zeroWithdrawItem.withdrawState = TRANSACTION_STATE_FAIL
zeroWithdrawItem.failReason = respObj.code
saveWinWithdrawInfos()
AndroidUtil.showToast(R.string.zero_withdraw_failed)
}
}
}
@ -190,7 +194,7 @@ class ZeroManager private constructor() {
if (couldStartWithdraw(item)) {
val onConfirmed: (cashNum: Float)->Unit = {
requestWithdrawZeroReward(zeroWithdrawInfoItem)
}
if (AccountManager.isBankAccountExist()) {

View File

@ -212,6 +212,8 @@
<string name="zero_win_state_withdrarw_ongoing">Processing</string>
<string name="zero_win_state_failed">Failed</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>

View File

@ -35,18 +35,42 @@ class AndroidUtil private constructor() {
}
fun showTopToast(strRes: Int) {
Toast.makeText(BaseApp.appContext(), strRes, Toast.LENGTH_SHORT).apply {
setGravity(Gravity.TOP, 0, 0)
show()
if (Looper.getMainLooper() != Looper.myLooper()) {
val handler = Handler(Looper.getMainLooper())
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) {
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) {
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) {