bug修复 - 0元购没有钻石但还是可以参团
This commit is contained in:
parent
c4b54f5e2e
commit
45c808618e
|
|
@ -68,8 +68,13 @@ class ZeroBuyActivity : AppViewsEmptyViewModelActivity<ViewBinding>() {
|
||||||
|
|
||||||
|
|
||||||
with(recyclerView) {
|
with(recyclerView) {
|
||||||
mAdapter = ZeroItemAdapter({ itemId->
|
mAdapter = ZeroItemAdapter({ itemId, diamondCost->
|
||||||
requestParticipateActivity(itemId)
|
|
||||||
|
if (AccountManager.adjustDiamond(diamondCost)) {
|
||||||
|
requestParticipateActivity(itemId)
|
||||||
|
} else {
|
||||||
|
AndroidUtil.showToast(R.string.dont_enought_diamond)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
adapter = mAdapter
|
adapter = mAdapter
|
||||||
layoutManager = GridLayoutManager(this@ZeroBuyActivity, 2)
|
layoutManager = GridLayoutManager(this@ZeroBuyActivity, 2)
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,9 @@ import com.ama.core.architecture.util.SpUtil
|
||||||
import com.ama.core.architecture.util.setOnClickBatch
|
import com.ama.core.architecture.util.setOnClickBatch
|
||||||
import com.vididin.real.money.game.R
|
import com.vididin.real.money.game.R
|
||||||
import com.gamedog.vididin.beans.ZeroBuyItem
|
import com.gamedog.vididin.beans.ZeroBuyItem
|
||||||
import com.gamedog.vididin.core.login.login.AccountManager
|
|
||||||
import com.vididin.real.money.game.databinding.LayoutItemZerobuyBinding as ViewBinding
|
import com.vididin.real.money.game.databinding.LayoutItemZerobuyBinding as ViewBinding
|
||||||
|
|
||||||
class ZeroItemAdapter(private val joinCallback: (itemId: Int)->Unit) : ListAdapter<ZeroBuyItem, ZeroItemAdapter.ViewHolder>(DiffCallback()) {
|
class ZeroItemAdapter(private val joinCallback: (itemId: Int, diamondCost: Int)->Unit) : ListAdapter<ZeroBuyItem, ZeroItemAdapter.ViewHolder>(DiffCallback()) {
|
||||||
|
|
||||||
private val mBgResList = listOf<Int>(R.mipmap.zero_bg_item_sub1, R.mipmap.zero_bg_item_sub2, R.mipmap.zero_bg_item_sub3, R.mipmap.zero_bg_item_sub4)
|
private val mBgResList = listOf<Int>(R.mipmap.zero_bg_item_sub1, R.mipmap.zero_bg_item_sub2, R.mipmap.zero_bg_item_sub3, R.mipmap.zero_bg_item_sub4)
|
||||||
|
|
||||||
|
|
@ -77,7 +76,7 @@ class ZeroItemAdapter(private val joinCallback: (itemId: Int)->Unit) : ListAdapt
|
||||||
setOnClickBatch(flBottomBut) {
|
setOnClickBatch(flBottomBut) {
|
||||||
when (this) {
|
when (this) {
|
||||||
flBottomBut-> {
|
flBottomBut-> {
|
||||||
joinCallback(item.id)
|
joinCallback(item.id, item.cost)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -142,6 +142,18 @@ object AccountManager {
|
||||||
return !mAccount?.bankInfo?.bankAccount.isNullOrEmpty()
|
return !mAccount?.bankInfo?.bankAccount.isNullOrEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun adjustDiamond(diamondCost: Int): Boolean {
|
||||||
|
mAccount?.let {
|
||||||
|
if (it.diamondCount > diamondCost) {
|
||||||
|
it.diamondCount -= diamondCost
|
||||||
|
saveAccountInfo()
|
||||||
|
NotifyMan.instance().sendEvent(VididinEvents.Event_Account_Diamond_Changed, null)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -160,5 +160,6 @@
|
||||||
<string name="gold_not_ready_hint">As recompensas ainda não estão prontas.</string>
|
<string name="gold_not_ready_hint">As recompensas ainda não estão prontas.</string>
|
||||||
<string name="day_simple">d</string>
|
<string name="day_simple">d</string>
|
||||||
<string name="hour_simple">h</string>
|
<string name="hour_simple">h</string>
|
||||||
|
<string name="dont_enought_diamond">Diamantes insuficientes</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
Loading…
Reference in New Issue