diff --git a/app/src/main/java/com/gamedog/vididin/features/zero/ZeroBuyActivity.kt b/app/src/main/java/com/gamedog/vididin/features/zero/ZeroBuyActivity.kt index cc74773..04ecab8 100644 --- a/app/src/main/java/com/gamedog/vididin/features/zero/ZeroBuyActivity.kt +++ b/app/src/main/java/com/gamedog/vididin/features/zero/ZeroBuyActivity.kt @@ -70,7 +70,7 @@ class ZeroBuyActivity : AppViewsEmptyViewModelActivity() { with(recyclerView) { mAdapter = ZeroItemAdapter({ itemId, diamondCost-> - if (AccountManager.adjustDiamond(diamondCost)) { + if (AccountManager.getDiamond() >= diamondCost) { requestParticipateActivity(itemId) } else { AndroidUtil.showToast(R.string.dont_enought_diamond) @@ -156,8 +156,14 @@ class ZeroBuyActivity : AppViewsEmptyViewModelActivity() { viewModel.ZeroBuyJoinResult.collect { result -> when (result) { is Result.Loading -> { } - is Result.Success -> updateItemUI(result.data) - is Result.Error -> { } + is Result.Success -> { + result.data?.let { + AccountManager.adjustDiamond(-1 * it.cost) + } + + updateItemUI(result.data) + } + is Result.Error -> { AndroidUtil.showToast(R.string.has_join_failed_zerobuy) } } } } diff --git a/app/src/main/java/com/gamedog/vididin/features/zero/ZeroRecordAdapter.kt b/app/src/main/java/com/gamedog/vididin/features/zero/ZeroRecordAdapter.kt index e8d3cc1..c2e5562 100644 --- a/app/src/main/java/com/gamedog/vididin/features/zero/ZeroRecordAdapter.kt +++ b/app/src/main/java/com/gamedog/vididin/features/zero/ZeroRecordAdapter.kt @@ -32,7 +32,7 @@ class ZeroRecordAdapter() : ListAdapter getGold()) { + if (adjustNum < 0L && Math.abs(adjustNum) > getCash()) { return false } mAccount.cashCount += adjustNum @@ -92,7 +92,7 @@ object AccountManager { @Synchronized fun adjustDiamond(adjustNum: Int): Boolean { - if (adjustNum < 0L && Math.abs(adjustNum) > getGold()) { + if (adjustNum < 0L && Math.abs(adjustNum) > getDiamond()) { return false } mAccount.diamondCount += adjustNum diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 48e07c7..3345845 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -120,6 +120,7 @@ Total sacado até o momento: Já participou Reembolso em + participate this activity failed. You have participated this activity. There\'s no any record Get