Commit b098b9ca authored by wanglei's avatar wanglei

...

parent bc34ac4c
......@@ -30,14 +30,14 @@ object AdmobOpenUtils {
}
fun loadAppOpenAd(onLoad: ((where: Int) -> Unit)? = null) {
fun loadAppOpenAd(onLoad: ((loaded: Boolean) -> Unit)? = null) {
if (mOpenAd != null) {
onLoad?.invoke(1)
onLoad?.invoke(false)
return
}
if (!AdDisplayUtils.shouldShowOpenAd()) {
onLoad?.invoke(2)
onLoad?.invoke(false)
return
}
val reqId = UUID.randomUUID().toString()
......@@ -54,7 +54,7 @@ object AdmobOpenUtils {
LogEx.logDebug(TAG, "onAdLoaded")
openLoadTime = System.currentTimeMillis()
mOpenAd = ad
onLoad?.invoke(3)
onLoad?.invoke(true)
pullAd(ad.responseInfo, "openAd", reqId = reqId)
ad.onPaidEventListener = AdmobEvent.EventOnPaidEventListener(ad)
}
......@@ -62,7 +62,7 @@ object AdmobOpenUtils {
override fun onAdFailedToLoad(p0: LoadAdError) {
LogEx.logDebug(TAG, "LoadAdError ${p0.message}")
mOpenAd = null
onLoad?.invoke(4)
onLoad?.invoke(false)
pullAd(p0.responseInfo, "openAd", p0.message, reqId = reqId)
}
})
......
......@@ -52,7 +52,7 @@ class SplashActivity : BaseActivity<ActivitySplash2Binding>(), SplashView {
)
}
splashPresenter = SplashPresenter(this)
startStayNotification()
// 获取当前日期
val calendar: Calendar = Calendar.getInstance()
......@@ -103,7 +103,7 @@ class SplashActivity : BaseActivity<ActivitySplash2Binding>(), SplashView {
agreePrivacy()
} else {
UmpUtils.callback = {
LogEx.logDebug(TAG, "UmpUtils.callback")
LogEx.logDebug(TAG, "UmpUtils.callback $it")
umpCanAd = it
agreePrivacy()
}
......@@ -114,27 +114,34 @@ class SplashActivity : BaseActivity<ActivitySplash2Binding>(), SplashView {
override fun showAd() {
AdmobOpenUtils.loadAppOpenAd {
AdmobOpenUtils.showAppOpenAd(this, showBefore = {
if (it) {
splashPresenter.pauseJumpJob()
}
}, onHidden = {
LogEx.logDebug(TAG, "ad jumpNext")
LogEx.logDebug(TAG, "showAd")
AdmobOpenUtils.loadAppOpenAd { loaded ->
LogEx.logDebug(TAG, "loadAppOpenAd loaded=$loaded")
if (loaded) {
AdmobOpenUtils.showAppOpenAd(this, showBefore = {
if (it) {
splashPresenter.pauseJumpJob()
}
}, onHidden = {
LogEx.logDebug(TAG, "ad jumpNext")
jumpNext()
})
} else {
LogEx.logDebug(TAG, "no load ad jumpNext")
jumpNext()
})
}
}
}
override fun agreePrivacy() {
startStayNotification()
if (umpCanAd) {
initAdmobAd()
showAd()
splashPresenter.startJumpJob = true
splashPresenter.startJumpJob(lifecycleScope)
} else {
jumpNext()
}
splashPresenter.startJumpJob = true
splashPresenter.startJumpJob(lifecycleScope)
}
override fun onPause() {
......
......@@ -27,7 +27,7 @@ object UmpUtils {
return debugSettings.build()
}
var callback: ((flag: Boolean) -> Unit)? = null
var callback: ((canAd: Boolean) -> Unit)? = null
private val TAG = "UmpUtils"
......@@ -59,13 +59,13 @@ object UmpUtils {
loadAndShowConsentFormIfRequired(activity, consentInformation)
}
} else {
callback?.invoke(false)
callback?.invoke(true)
callback = null
}
}
val updateFailureListener = ConsentInformation.OnConsentInfoUpdateFailureListener {
LogEx.logDebug(TAG, "message=${it.message} errorCode=${it.errorCode}")
callback?.invoke(false)
callback?.invoke(true)
callback = null
}
......@@ -90,7 +90,7 @@ object UmpUtils {
override fun onConsentFormLoadFailure(p0: FormError) {
//https://groups.google.com/g/google-admob-ads-sdk/c/x-fyDOfMSqU/m/MeZX3mO4AAAJ
LogEx.logDebug(TAG, "onConsentFormLoadFailure ${p0.message} ${p0.errorCode}")
callback?.invoke(consentInformation.canRequestAds())
callback?.invoke(true)
callback = null
}
})
......
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