Commit 3d9c463a authored by wanglei's avatar wanglei

[商业化]修改ad_price bug

parent 4ad1f495
...@@ -42,7 +42,7 @@ class AdBannerMgr { ...@@ -42,7 +42,7 @@ class AdBannerMgr {
adView = AdView(parent.context) adView = AdView(parent.context)
parent.addView(adView) parent.addView(adView)
adView?.onPaidEventListener = AdmobOnPaidEventListener(adView, admobEvent.scope) adView?.let { it.onPaidEventListener = AdmobOnPaidEventListener(it, admobEvent.scope) }
listener = ViewTreeObserver.OnGlobalLayoutListener { listener = ViewTreeObserver.OnGlobalLayoutListener {
val screenPixelDensity = parent.context.resources.displayMetrics.density val screenPixelDensity = parent.context.resources.displayMetrics.density
......
...@@ -186,15 +186,16 @@ class AdInterMgr { ...@@ -186,15 +186,16 @@ class AdInterMgr {
context, GlobalConfig.ID_ADMOB_INTER, AdRequest.Builder().build(), context, GlobalConfig.ID_ADMOB_INTER, AdRequest.Builder().build(),
object : InterstitialAdLoadCallback() { object : InterstitialAdLoadCallback() {
override fun onAdLoaded(ad: InterstitialAd) { override fun onAdLoaded(ad: InterstitialAd) {
val event = (adEvent as AdmobEvent)
ad.onPaidEventListener = AdmobOnPaidEventListener(ad, adEvent.scope)
adState.onAdLoaded(ad, adEvent) adState.onAdLoaded(ad, adEvent)
loadCallBack?.invoke()
loadCallBack?.invoke()
loadingCallBack?.invoke() loadingCallBack?.invoke()
loadingCallBack = null loadingCallBack = null
(adEvent as AdmobEvent).pullAd(ad.responseInfo)
LimitUtils.addRequestNum() LimitUtils.addRequestNum()
ad.onPaidEventListener = AdmobOnPaidEventListener(adEvent.scope) event.pullAd(ad.responseInfo)
} }
override fun onAdFailedToLoad(loadAdError: LoadAdError) { override fun onAdFailedToLoad(loadAdError: LoadAdError) {
......
...@@ -141,16 +141,15 @@ class AdmobEvent : AdEvent { ...@@ -141,16 +141,15 @@ class AdmobEvent : AdEvent {
class AdmobOnPaidEventListener( class AdmobOnPaidEventListener(
private val ad: Any?, private val ad: Any,
private val coroutineScope: CoroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.IO) private val coroutineScope: CoroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
) : OnPaidEventListener { ) : OnPaidEventListener {
override fun onPaidEvent(adValue: AdValue) { override fun onPaidEvent(adValue: AdValue) {
ad ?: return
onPaidEvent2(ad, adValue) onPaidEvent2(ad, adValue)
} }
fun onPaidEvent2(ad: Any?, adValue: AdValue) { fun onPaidEvent2(ad: Any, adValue: AdValue) {
// coroutineScope.launch { // coroutineScope.launch {
try { try {
val flag = eventAdRatio() val flag = eventAdRatio()
......
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