Commit 05d5ab15 authored by wanglei's avatar wanglei

[商业化]优化广告逻辑

parent 0db1da16
...@@ -76,27 +76,27 @@ class AdInterMgr { ...@@ -76,27 +76,27 @@ class AdInterMgr {
if (!adState.loadingAd) { if (!adState.loadingAd) {
LogEx.logDebug(adEvent.TAG, "inter adState !loadingAd") LogEx.logDebug(adEvent.TAG, "inter adState !loadingAd")
loadAd(activity, nowAdEvent) { loadAd(activity, nowAdEvent) {
showReadyAd(activity) showReadyAd(activity, nowAdEvent)
} }
} else { } else {
LogEx.logDebug(adEvent.TAG, "inter adState is loadingAd") LogEx.logDebug(adEvent.TAG, "inter adState is loadingAd")
loadingCallBack = { loadingCallBack = {
showReadyAd(activity) showReadyAd(activity, nowAdEvent)
} }
} }
} else { } else {
LogEx.logDebug(adEvent.TAG, "inter ad ready") LogEx.logDebug(adEvent.TAG, "inter ad ready")
showReadyAd(activity) showReadyAd(activity, nowAdEvent)
} }
} }
private fun showReadyAd(ac: Activity) { private fun showReadyAd(ac: Activity, adEvent: AdEvent) {
val adEvent = (adState.currentAdEvent as AdmobEvent?)
// val ac = adState.activityRef?.get() // val ac = adState.activityRef?.get()
val tag = adEvent?.TAG ?: "" val admobEvent = (adEvent as AdmobEvent)
val tag = adEvent.TAG
LogEx.logDebug(tag, "showReadyAd ac=$ac currentAd=${adState.currentAd}") LogEx.logDebug(tag, "showReadyAd ac=$ac currentAd=${adState.currentAd}")
if (ac.isFinishing || ac.isDestroyed || adState.currentAd == null) { if (ac.isFinishing || ac.isDestroyed || adState.currentAd == null) {
...@@ -112,7 +112,7 @@ class AdInterMgr { ...@@ -112,7 +112,7 @@ class AdInterMgr {
override fun onAdShowedFullScreenContent() { override fun onAdShowedFullScreenContent() {
super.onAdShowedFullScreenContent() super.onAdShowedFullScreenContent()
adEvent?.showAd(responseInfo, ac) admobEvent.showAd(responseInfo, ac)
adState.onAdDisplayed() adState.onAdDisplayed()
showCallBack?.show() showCallBack?.show()
...@@ -127,7 +127,7 @@ class AdInterMgr { ...@@ -127,7 +127,7 @@ class AdInterMgr {
showCallBack?.adFailed() showCallBack?.adFailed()
showCallBack = null showCallBack = null
adEvent?.adShowError(adError) admobEvent.adShowError(adError)
} }
override fun onAdDismissedFullScreenContent() { override fun onAdDismissedFullScreenContent() {
...@@ -142,7 +142,7 @@ class AdInterMgr { ...@@ -142,7 +142,7 @@ class AdInterMgr {
override fun onAdClicked() { override fun onAdClicked() {
super.onAdClicked() super.onAdClicked()
adEvent?.clickAd(responseInfo) admobEvent.clickAd(responseInfo)
//计数 //计数
LimitUtils.addClickNum() LimitUtils.addClickNum()
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment