钻石事件 ui更新
This commit is contained in:
parent
595dfa7a9c
commit
97344d2604
|
|
@ -33,6 +33,8 @@ object VidiConst {
|
|||
const val ZEROBUY_SECRET: String = "1f04c57a"
|
||||
const val ZEROBUY_APPID: String = "com.vididin.real.money.game"
|
||||
|
||||
const val DIAMOND_NUM_FOR_ONE_AD = 5
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ object VididinEvents {
|
|||
const val Event_Account_Gold_Changed = 601
|
||||
const val Event_Account_Cash_Changed = 602
|
||||
const val Event_Account_Bank_Info_Changed = 603
|
||||
const val Event_Account_Diamond_Changed = 604
|
||||
|
||||
|
||||
const val Event_HOME_WATCH_Time_TICK = 700
|
||||
|
|
@ -29,6 +30,7 @@ object VididinEvents {
|
|||
const val Event_AD_TASK_TYPE_Withdraw = 803
|
||||
const val Event_AD_TASK_TYPE_Complement = 804
|
||||
const val Event_AD_TASK_TYPE_BOX_TASK = 805
|
||||
const val Event_AD_TASK_EARN_DIAMOND = 806
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ data class Account(
|
|||
var goldCount: Long = 0L,
|
||||
@Volatile
|
||||
var cashCount: Float = 0F,
|
||||
@Volatile
|
||||
var diamondCount: Int = 0,
|
||||
var bankInfo: BankInfo? = null,
|
||||
val zeroBuyServerSecret: String = "",
|
||||
)
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import com.ama.core.architecture.util.AndroidUtil
|
|||
import com.ama.core.architecture.util.CommonItemDecoration
|
||||
import com.ama.core.architecture.util.SpUtil
|
||||
import com.ama.core.architecture.util.setOnClickBatch
|
||||
import com.gamedog.vididin.VididinEvents
|
||||
import com.vididin.real.money.game.R
|
||||
import com.gamedog.vididin.beans.ZeroBuyItem
|
||||
import com.gamedog.vididin.beans.ZeroBuyResp
|
||||
|
|
@ -34,22 +35,28 @@ class ZeroBuyActivity : AppViewsEmptyViewModelActivity<ViewBinding>() {
|
|||
|
||||
|
||||
|
||||
|
||||
override fun inflateViewBinding(inflater: LayoutInflater) = ViewBinding.inflate(inflater)
|
||||
|
||||
override fun ViewBinding.initViews() {
|
||||
binding.run {
|
||||
setOnClickBatch(tvZeroGoldNum, tvZeroLotteryList) {
|
||||
setOnClickBatch(tvZeroGoldNum, tvZeroLotteryList, llDiamondAd) {
|
||||
when (this) {
|
||||
tvZeroGoldNum -> {
|
||||
|
||||
}
|
||||
|
||||
tvZeroLotteryList -> {
|
||||
gotoLotteryRecords()
|
||||
}
|
||||
|
||||
llDiamondAd -> {
|
||||
gotoEarnDiamond()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tvZeroGoldNum.text = AccountManager.getGold().toString()
|
||||
updateUIDiamondNum()
|
||||
|
||||
titlebar.setTitleText(R.string.zero_buy)
|
||||
titlebar.addRightIcon(R.mipmap.icon_question_mark, {
|
||||
|
|
@ -70,6 +77,8 @@ class ZeroBuyActivity : AppViewsEmptyViewModelActivity<ViewBinding>() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
override fun ViewBinding.initWindowInsets() {
|
||||
setImmerseRootView(contentRoot)
|
||||
}
|
||||
|
|
@ -79,10 +88,21 @@ class ZeroBuyActivity : AppViewsEmptyViewModelActivity<ViewBinding>() {
|
|||
}
|
||||
|
||||
override fun ViewBinding.initListeners() {
|
||||
//TODO("Not yet implemented")
|
||||
registerEvents({ data->
|
||||
when (data?.mEventType) {
|
||||
VididinEvents.Event_Account_Diamond_Changed -> {
|
||||
updateUIDiamondNum()
|
||||
}
|
||||
}
|
||||
}, VididinEvents.Event_Account_Diamond_Changed)
|
||||
|
||||
requestData()
|
||||
}
|
||||
|
||||
private fun updateUIDiamondNum() {
|
||||
binding.tvZeroGoldNum.text = AccountManager.getAccount()?.diamondCount.toString()
|
||||
}
|
||||
|
||||
override fun ViewBinding.initObservers() {
|
||||
//TODO("Not yet implemented")
|
||||
}
|
||||
|
|
@ -91,6 +111,10 @@ class ZeroBuyActivity : AppViewsEmptyViewModelActivity<ViewBinding>() {
|
|||
Router.WinRecord.startActivity(this)
|
||||
}
|
||||
|
||||
private fun gotoEarnDiamond() {
|
||||
Router.WatchAd.startActivity(this, VididinEvents.Event_AD_TASK_EARN_DIAMOND, null)
|
||||
}
|
||||
|
||||
//----------------------- start -----------------------------
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,19 @@ object AccountManager {
|
|||
|
||||
private val mutex = Mutex()
|
||||
|
||||
init {
|
||||
NotifyMan.instance().register(object: NotifyMan.ICallback(true) {
|
||||
override fun onEvent(data: NotifyMan.NotifyData<*>?) {
|
||||
when (data?.mEventType) {
|
||||
VididinEvents.Event_AD_TASK_EARN_DIAMOND -> {
|
||||
addDiamond(VidiConst.DIAMOND_NUM_FOR_ONE_AD)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}, VididinEvents.Event_AD_TASK_EARN_DIAMOND)
|
||||
}
|
||||
|
||||
private val mAccount: Account? by lazy {
|
||||
var account = SpUtil.instance().getObject<Account>(SpUtil.KEY_ACCOUNT)
|
||||
if (account == null) {
|
||||
|
|
@ -51,6 +64,13 @@ object AccountManager {
|
|||
NotifyMan.instance().sendEvent(VididinEvents.Event_Account_Gold_Changed, null)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
private fun addDiamond(diamondNum: Int) {
|
||||
mAccount?.diamondCount += diamondNum
|
||||
saveAccountInfo()
|
||||
NotifyMan.instance().sendEvent(VididinEvents.Event_Account_Diamond_Changed, null)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun addCash(newCash: Float) {
|
||||
mAccount?.cashCount += newCash
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ android:layout_height="wrap_content" >
|
|||
android:layout_marginBottom="5dp"
|
||||
android:minWidth="100dp"
|
||||
android:gravity="center"
|
||||
android:drawableLeft="@mipmap/task_gold"
|
||||
android:drawableLeft="@mipmap/zero_diamoend_b"
|
||||
android:drawablePadding="5dp"
|
||||
android:background="@drawable/bg_zero_gold_num"
|
||||
/>
|
||||
|
|
|
|||
Loading…
Reference in New Issue