广告完成后 事件通知逻辑优化
This commit is contained in:
parent
9066b775a8
commit
ae45b72717
|
|
@ -10,7 +10,7 @@ object VididinEvents {
|
|||
|
||||
const val Event_HOME_WATCH_Time_TICK = 700
|
||||
const val Event_Finish_One_Video = 701
|
||||
const val Event_Finish_One_Ad = 702
|
||||
const val EVENT_FINISHED_ONE_AD = 702
|
||||
const val Event_Finish_One_Sign = 703
|
||||
const val Event_Finish_One_Zerobuy = 704
|
||||
|
||||
|
|
@ -31,7 +31,8 @@ object VididinEvents {
|
|||
const val Event_AD_TASK_TYPE_Complement = 804
|
||||
const val EVENT_AD_WATCHED_FOR_BOX_TASK = 805
|
||||
const val EVENT_AD_WATCHED_FOR_ZEROBUY_EARN_DIAMOND = 806
|
||||
const val EVENT_AD_WATCHED_FOR_WITHDRAW = 807
|
||||
const val EVENT_AD_WATCHED_FOR_WITHDRAW_SMALL = 807
|
||||
const val EVENT_AD_WATCHED_FOR_WITHDRAW_BIG = 808
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
package com.gamedog.vididin.beans
|
||||
|
||||
|
||||
|
||||
|
||||
data class WatchAdNotifyBean<T>(
|
||||
var earnMoneyNum: Float = 0F,
|
||||
var extraData: T,
|
||||
)
|
||||
|
||||
|
|
@ -14,7 +14,9 @@ import com.ama.core.architecture.util.AndroidUtil
|
|||
import com.ama.core.architecture.util.eventbus.NotifyMan
|
||||
import com.gamedog.vididin.VidiConst
|
||||
import com.gamedog.vididin.VididinEvents
|
||||
import com.gamedog.vididin.beans.WatchAdNotifyBean
|
||||
import com.gamedog.vididin.main.interfaces.OnTabStyleListener
|
||||
import com.gamedog.vididin.manager.WithdrawItemBean
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlin.getValue
|
||||
import com.vididin.real.money.game.databinding.ActivityWatchAdBinding as ViewBinding
|
||||
|
|
@ -30,8 +32,8 @@ class WatchAdActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnT
|
|||
|
||||
|
||||
private lateinit var mCountDownTimer: CountDownTimer
|
||||
private var mTaskType: Int = 0
|
||||
private var mTaskData: String? = null
|
||||
private var mWatchType: Int = 0
|
||||
private var mExtraJsonStr: String? = null
|
||||
|
||||
override fun ViewBinding.initViews() {
|
||||
with(binding) {
|
||||
|
|
@ -58,12 +60,62 @@ class WatchAdActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnT
|
|||
|
||||
|
||||
private fun notifyAdWatchFinish() {
|
||||
NotifyMan.instance().sendEvent(getNotifyEventType(mTaskType),
|
||||
if (mTaskData.isNullOrEmpty()) null else AndroidUtil.json2Object<NotifyMan.NotifyData<Any>>(mTaskData!!))
|
||||
var notifyEventType = 0
|
||||
var notifyData: NotifyMan.NotifyData<Any> = NotifyMan.NotifyData()
|
||||
var earnMoneyNum = 0.1F
|
||||
var shouldNotifyOneAdWatched = true
|
||||
|
||||
if (mTaskType != VidiConst.WATCH_AD_FOR_DAILY_EARN_GOLD
|
||||
&& mTaskType != VidiConst.WATCH_AD_FOR_ZERO_EARN_DIAMOND) {
|
||||
NotifyMan.instance().sendEvent(VididinEvents.Event_Finish_One_Ad, NotifyMan.NotifyData(1))
|
||||
|
||||
when (mWatchType) {
|
||||
VidiConst.WATCH_AD_FOR_WITHDRAW_SMALL -> {
|
||||
shouldNotifyOneAdWatched = true
|
||||
notifyEventType = VididinEvents.EVENT_AD_WATCHED_FOR_WITHDRAW_SMALL
|
||||
|
||||
val extraData = mExtraJsonStr?.let {
|
||||
AndroidUtil.json2Object<Float>(mExtraJsonStr!!)
|
||||
}
|
||||
notifyData.mData = WatchAdNotifyBean(earnMoneyNum, extraData)
|
||||
}
|
||||
|
||||
VidiConst.WATCH_AD_FOR_WITHDRAW_BIG -> {
|
||||
shouldNotifyOneAdWatched = true
|
||||
notifyEventType = VididinEvents.EVENT_AD_WATCHED_FOR_WITHDRAW_BIG
|
||||
|
||||
val extraData = mExtraJsonStr?.let {
|
||||
AndroidUtil.json2Object<WithdrawItemBean>(mExtraJsonStr!!)
|
||||
}
|
||||
notifyData.mData = WatchAdNotifyBean(earnMoneyNum, extraData)
|
||||
}
|
||||
|
||||
VidiConst.WATCH_AD_FOR_BOX_TASK -> {
|
||||
shouldNotifyOneAdWatched = true
|
||||
notifyEventType = VididinEvents.EVENT_AD_WATCHED_FOR_BOX_TASK
|
||||
}
|
||||
|
||||
VidiConst.WATCH_AD_FOR_ZERO_EARN_DIAMOND -> {
|
||||
shouldNotifyOneAdWatched = false
|
||||
notifyEventType = VididinEvents.EVENT_AD_WATCHED_FOR_ZEROBUY_EARN_DIAMOND
|
||||
}
|
||||
|
||||
VidiConst.WATCH_AD_FOR_DAILY_WATCH_AD -> {
|
||||
shouldNotifyOneAdWatched = true
|
||||
notifyEventType = VididinEvents.EVENT_AD_WATCHED_FOR_DAILY_WATCH_AD
|
||||
}
|
||||
|
||||
VidiConst.WATCH_AD_FOR_DAILY_EARN_GOLD -> {
|
||||
shouldNotifyOneAdWatched = false
|
||||
notifyEventType = VididinEvents.EVENT_AD_WATCHED_FOR_EARN_GOLD
|
||||
}
|
||||
|
||||
VidiConst.WATCH_AD_FOR_CONVERT_GOLD_2_CASH -> {
|
||||
shouldNotifyOneAdWatched = true
|
||||
notifyEventType = VididinEvents.EVENT_AD_WATCHED_FOR_CONVERT_GOLD_2_CASH
|
||||
}
|
||||
}
|
||||
|
||||
NotifyMan.instance().sendEvent(notifyEventType, notifyData)
|
||||
if (shouldNotifyOneAdWatched) {
|
||||
NotifyMan.instance().sendEvent(VididinEvents.EVENT_FINISHED_ONE_AD, NotifyMan.NotifyData(1))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -84,45 +136,10 @@ class WatchAdActivity : AppViewsActivity<ViewBinding, UiState, ViewModel>(), OnT
|
|||
|
||||
override fun readIntent(intent: Intent) {
|
||||
super.readIntent(intent)
|
||||
mTaskType = intent.getIntExtra(KEY_TASK_TYPE, 0)
|
||||
mTaskData = intent.getStringExtra(KEY_TASK_DATA)
|
||||
mWatchType = intent.getIntExtra(KEY_TASK_TYPE, 0)
|
||||
mExtraJsonStr = intent.getStringExtra(KEY_TASK_DATA)
|
||||
}
|
||||
|
||||
private fun getNotifyEventType(taskType: Int) : Int {
|
||||
when (taskType) {
|
||||
VidiConst.WATCH_AD_FOR_WITHDRAW_SMALL -> {
|
||||
return VididinEvents.EVENT_AD_WATCHED_FOR_WITHDRAW
|
||||
}
|
||||
|
||||
VidiConst.WATCH_AD_FOR_BOX_TASK -> {
|
||||
return VididinEvents.EVENT_AD_WATCHED_FOR_BOX_TASK
|
||||
}
|
||||
|
||||
VidiConst.WATCH_AD_FOR_ZERO_EARN_DIAMOND -> {
|
||||
return VididinEvents.EVENT_AD_WATCHED_FOR_ZEROBUY_EARN_DIAMOND
|
||||
}
|
||||
|
||||
VidiConst.WATCH_AD_FOR_DAILY_WATCH_AD -> {
|
||||
return VididinEvents.EVENT_AD_WATCHED_FOR_DAILY_WATCH_AD
|
||||
}
|
||||
|
||||
VidiConst.WATCH_AD_FOR_DAILY_EARN_GOLD -> {
|
||||
return VididinEvents.EVENT_AD_WATCHED_FOR_EARN_GOLD
|
||||
}
|
||||
|
||||
VidiConst.WATCH_AD_FOR_CONVERT_GOLD_2_CASH -> {
|
||||
return VididinEvents.EVENT_AD_WATCHED_FOR_CONVERT_GOLD_2_CASH
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import com.ama.core.architecture.util.setOnClickBatch
|
|||
import com.gamedog.vididin.VidiConst
|
||||
import com.vididin.real.money.game.R
|
||||
import com.gamedog.vididin.VididinEvents
|
||||
import com.gamedog.vididin.beans.WatchAdNotifyBean
|
||||
import com.gamedog.vididin.beans.resp.PayoutCheck
|
||||
import com.gamedog.vididin.beans.resp.PayoutReply
|
||||
import com.gamedog.vididin.beans.resp.WithdrawRecord
|
||||
|
|
@ -130,13 +131,13 @@ class WithDrawActivity : AppViewsEmptyViewModelActivity<ViewBinding>() {
|
|||
updateUICashTotal()
|
||||
}
|
||||
|
||||
VididinEvents.EVENT_AD_WATCHED_FOR_WITHDRAW -> {
|
||||
var withdrawNum: Float = (data.mData as Double).toFloat()
|
||||
requestInit(withdrawNum)
|
||||
VididinEvents.EVENT_AD_WATCHED_FOR_WITHDRAW_SMALL -> {
|
||||
val notifyData: WatchAdNotifyBean<Float> = data.mData as WatchAdNotifyBean<Float>
|
||||
requestInit(notifyData.extraData)
|
||||
}
|
||||
}
|
||||
|
||||
}, VididinEvents.Event_Account_Cash_Changed, VididinEvents.EVENT_AD_WATCHED_FOR_WITHDRAW)
|
||||
}, VididinEvents.Event_Account_Cash_Changed, VididinEvents.EVENT_AD_WATCHED_FOR_WITHDRAW_SMALL)
|
||||
|
||||
|
||||
checkTransactionState()
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ class WithDrawSubActivity : AppViewsEmptyViewModelActivity<ViewBinding>() {
|
|||
}
|
||||
|
||||
private fun gotoWatchAd() {
|
||||
val extraData = NotifyMan.NotifyData<Float>(WithdrawManager.EACH_SUB_ITEM_CASH_NUM)
|
||||
val extraData = NotifyMan.NotifyData<WithdrawItemBean>(mCurItem)
|
||||
Router.WatchAd.startActivity(this, VidiConst.WATCH_AD_FOR_WITHDRAW_BIG, AndroidUtil.object2Json(extraData))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,8 +47,7 @@ class WithdrawWatchAdDialog(context: Activity, private var mWithdrawCashNum: Flo
|
|||
|
||||
|
||||
private fun gotoWatchVideo() {
|
||||
val extraData = NotifyMan.NotifyData<Float>(mWithdrawCashNum)
|
||||
Router.WatchAd.startActivity(mActivity, VidiConst.WATCH_AD_FOR_WITHDRAW_SMALL, AndroidUtil.object2Json(extraData))
|
||||
Router.WatchAd.startActivity(mActivity, VidiConst.WATCH_AD_FOR_WITHDRAW_SMALL, AndroidUtil.object2Json(mWithdrawCashNum))
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class BoxTaskHelper: BaseTaskHelper<TaskStateBoxRoot, BoxTaskRoot>() {
|
|||
init {
|
||||
registerEvents( { eventData->
|
||||
when (eventData?.mEventType) {
|
||||
VididinEvents.Event_Finish_One_Ad -> {
|
||||
VididinEvents.EVENT_FINISHED_ONE_AD -> {
|
||||
handleEvents(BOX_SUB_TASK_TYPE_AD)
|
||||
}
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ class BoxTaskHelper: BaseTaskHelper<TaskStateBoxRoot, BoxTaskRoot>() {
|
|||
}
|
||||
}
|
||||
|
||||
}, VididinEvents.Event_Finish_One_Ad, VididinEvents.Event_Finish_One_Video,
|
||||
}, VididinEvents.EVENT_FINISHED_ONE_AD, VididinEvents.Event_Finish_One_Video,
|
||||
VididinEvents.Event_Finish_One_Sign, VididinEvents.Event_Finish_One_Zerobuy)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class DailyWatchAdTaskHelper : BaseDailyTaskHelper<TaskStateWatchAd>() {
|
|||
registerEvents( { eventData->
|
||||
val watchedAdNum: Int = eventData?.mData as Int
|
||||
handleOneAdWatched(watchedAdNum)
|
||||
}, VididinEvents.Event_Finish_One_Ad)
|
||||
}, VididinEvents.EVENT_FINISHED_ONE_AD)
|
||||
}
|
||||
|
||||
override fun loadTaskFromSp() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue