Commit b098b9ca authored by wanglei's avatar wanglei

...

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