参与成功后再 扣减钻石
This commit is contained in:
parent
a3b0386c9d
commit
aefd72680b
|
|
@ -70,7 +70,7 @@ class ZeroBuyActivity : AppViewsEmptyViewModelActivity<ViewBinding>() {
|
||||||
with(recyclerView) {
|
with(recyclerView) {
|
||||||
mAdapter = ZeroItemAdapter({ itemId, diamondCost->
|
mAdapter = ZeroItemAdapter({ itemId, diamondCost->
|
||||||
|
|
||||||
if (AccountManager.adjustDiamond(diamondCost)) {
|
if (AccountManager.getDiamond() >= diamondCost) {
|
||||||
requestParticipateActivity(itemId)
|
requestParticipateActivity(itemId)
|
||||||
} else {
|
} else {
|
||||||
AndroidUtil.showToast(R.string.dont_enought_diamond)
|
AndroidUtil.showToast(R.string.dont_enought_diamond)
|
||||||
|
|
@ -156,8 +156,14 @@ class ZeroBuyActivity : AppViewsEmptyViewModelActivity<ViewBinding>() {
|
||||||
viewModel.ZeroBuyJoinResult.collect { result ->
|
viewModel.ZeroBuyJoinResult.collect { result ->
|
||||||
when (result) {
|
when (result) {
|
||||||
is Result.Loading -> { }
|
is Result.Loading -> { }
|
||||||
is Result.Success -> updateItemUI(result.data)
|
is Result.Success -> {
|
||||||
is Result.Error -> { }
|
result.data?.let {
|
||||||
|
AccountManager.adjustDiamond(-1 * it.cost)
|
||||||
|
}
|
||||||
|
|
||||||
|
updateItemUI(result.data)
|
||||||
|
}
|
||||||
|
is Result.Error -> { AndroidUtil.showToast(R.string.has_join_failed_zerobuy) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ class ZeroRecordAdapter() : ListAdapter<ZeroBuyItem, ZeroRecordAdapter.ViewHolde
|
||||||
|
|
||||||
private fun isWinItem(item: ZeroBuyItem): Boolean {
|
private fun isWinItem(item: ZeroBuyItem): Boolean {
|
||||||
val winerIds = item.winners
|
val winerIds = item.winners
|
||||||
return winerIds?.contains(AccountManager.getAccount()?.userId) ?: false
|
return winerIds?.contains(AccountManager.getAccount().userId) ?: false
|
||||||
}
|
}
|
||||||
|
|
||||||
inner class ViewHolder(private val binding: ViewBinding) : RecyclerView.ViewHolder(binding.root) {
|
inner class ViewHolder(private val binding: ViewBinding) : RecyclerView.ViewHolder(binding.root) {
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ object AccountManager {
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun adjustCash(adjustNum: Float, recordBean: RecordCash?): Boolean {
|
fun adjustCash(adjustNum: Float, recordBean: RecordCash?): Boolean {
|
||||||
if (adjustNum < 0L && Math.abs(adjustNum) > getGold()) {
|
if (adjustNum < 0L && Math.abs(adjustNum) > getCash()) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
mAccount.cashCount += adjustNum
|
mAccount.cashCount += adjustNum
|
||||||
|
|
@ -92,7 +92,7 @@ object AccountManager {
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun adjustDiamond(adjustNum: Int): Boolean {
|
fun adjustDiamond(adjustNum: Int): Boolean {
|
||||||
if (adjustNum < 0L && Math.abs(adjustNum) > getGold()) {
|
if (adjustNum < 0L && Math.abs(adjustNum) > getDiamond()) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
mAccount.diamondCount += adjustNum
|
mAccount.diamondCount += adjustNum
|
||||||
|
|
|
||||||
|
|
@ -120,6 +120,7 @@
|
||||||
<string name="record_cash_title_hint">Total sacado até o momento:</string>
|
<string name="record_cash_title_hint">Total sacado até o momento:</string>
|
||||||
<string name="participar_ed">Já participou</string>
|
<string name="participar_ed">Já participou</string>
|
||||||
<string name="remain_time">Reembolso em</string>
|
<string name="remain_time">Reembolso em</string>
|
||||||
|
<string name="has_join_failed_zerobuy">participate this activity failed.</string>
|
||||||
<string name="has_joined_zerobuy">You have participated this activity.</string>
|
<string name="has_joined_zerobuy">You have participated this activity.</string>
|
||||||
<string name="no_data_hint">There\'s no any record</string>
|
<string name="no_data_hint">There\'s no any record</string>
|
||||||
<string name="get">Get</string>
|
<string name="get">Get</string>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue