Commit 4764fd73 authored by wanglei's avatar wanglei

...开屏广告

parent cb086dda
......@@ -84,19 +84,9 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>() {
if (ifAgreePrivacy) {
LogEx.logDebug(TAG, "ifAgreePrivacy=$ifAgreePrivacy")
if (ConfigHelper.admobTrueMaxFlase) {
LogEx.logDebug(TAG, "load admob")
AdmobNativeUtils.loadNativeAd()
AdmobInterstitialUtils.loadInterstitialAd(this)
} else {
LogEx.logDebug(TAG, "load max")
maxInitAction = {
Log.d(TAG, "max init suc")
AdMaxOpenUtils.loadAppOpenAd(this)
AdMaxInterstitialUtils.loadInterstitialAd(this)
maxInitAction = null
}
}
AdmobMaxHelper.preloadAd(this)
job = startProgress()
binding.llStart.visibility = View.GONE
binding.llProgress.visibility = View.VISIBLE
......@@ -130,7 +120,7 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>() {
progressFlow.collectLatest {
if (it >= 100) {
job?.cancel()
LogEx.logDebug(TAG,"jumpNext")
LogEx.logDebug(TAG, "jumpNext")
jumpNext()
this.cancel()
}
......@@ -139,7 +129,7 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>() {
}
private fun jumpNext() {
LogEx.logDebug(TAG," when (actionId) {:jumpNext: "+actionId )
LogEx.logDebug(TAG, " when (actionId) {:jumpNext: " + actionId)
when (actionId) {
ID_JUNK_CLEAN_PUSH -> {
......@@ -212,15 +202,7 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>() {
oneClickStart = true
ifAgreePrivacy = true
(application as MyApplication).initApp()
if (ConfigHelper.admobTrueMaxFlase) {
AdmobNativeUtils.loadNativeAd()
AdmobInterstitialUtils.loadInterstitialAd(this)
} else {
maxInitAction = {
AdMaxOpenUtils.loadAppOpenAd(this)
AdMaxInterstitialUtils.loadInterstitialAd(this)
}
}
AdmobMaxHelper.preloadAd(this)
binding.llStart.visibility = View.GONE
binding.llProgress.visibility = View.VISIBLE
job = startProgress()
......@@ -235,18 +217,18 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>() {
val value = binding.pb.progress + 2
binding.pb.setProgress(value, true)
progress.emit(value)
LogEx.logDebug(TAG, "startProgress:"+isActive+" progress.emit(value)")
LogEx.logDebug(TAG, "startProgress:" + isActive + " progress.emit(value)")
val delayTime = 450L
delay(delayTime)
LogEx.logDebug(TAG, "startProgress:"+isActive+" delay(delayTime)")
LogEx.logDebug(TAG, "startProgress:" + isActive + " delay(delayTime)")
processTime += delayTime
LogEx.logDebug(TAG, "startProgress:"+isActive+" processTime += delayTime")
LogEx.logDebug(TAG, "startProgress:" + isActive + " processTime += delayTime")
if (processTime >= Random.nextLong(3000, 4000)) {
LogEx.logDebug(TAG, "startProgress:"+isActive+" Random.nextLong(3000, 4000)")
LogEx.logDebug(TAG, "startProgress:" + isActive + " Random.nextLong(3000, 4000)")
if (!outTimeAdStart) {
outTimeAdStart = true
LogEx.logDebug(TAG, "outTimeAd:"+isActive)
LogEx.logDebug(TAG, "outTimeAd:" + isActive)
outTimeAd()
}
}
......
......@@ -2,12 +2,15 @@ package com.base.datarecovery.ads
import AdMaxNativeUtils
import android.app.Activity
import android.content.Context
import android.util.Log
import android.view.View
import android.view.ViewGroup
import com.base.datarecovery.R
import com.base.datarecovery.ads.admob.AdmobInterstitialUtils
import com.base.datarecovery.ads.admob.AdmobNativeUtils
import com.base.datarecovery.ads.admob.AdmobOpenUtils
import com.base.datarecovery.ads.max.AdMaxInit
import com.base.datarecovery.ads.max.AdMaxInit.initAdMax
import com.base.datarecovery.ads.max.AdMaxInterstitialUtils
import com.base.datarecovery.ads.max.AdMaxOpenUtils
......@@ -69,7 +72,7 @@ object AdmobMaxHelper {
}
}
fun initAdmobMaxAd() {
fun initAdmobMaxAd(activity: Activity? = null) {
if (ConfigHelper.admobTrueMaxFlase) {
if (!isAdInit.get()) {
MobileAds.initialize(BaseApplication.context) { initializationStatus ->
......@@ -83,4 +86,22 @@ object AdmobMaxHelper {
}
}
fun preloadAd(activity: Activity) {
if (ConfigHelper.admobTrueMaxFlase) {
AdmobOpenUtils.loadAppOpenAd()
AdmobInterstitialUtils.loadInterstitialAd(activity)
} else {
if (isAdInit.get()) {
AdMaxOpenUtils.loadAppOpenAd(activity)
AdMaxInterstitialUtils.loadInterstitialAd(activity)
} else {
AdMaxInit.maxInitAction = {
Log.d(TAG, "max init suc")
AdMaxOpenUtils.loadAppOpenAd(activity)
AdMaxInterstitialUtils.loadInterstitialAd(activity)
}
}
}
}
}
\ No newline at end of file
......@@ -46,6 +46,7 @@ object AdMaxInit {
LogEx.logDebug(TAG, "max init")
isAdInit.set(true)
maxInitAction?.invoke()
maxInitAction = null
}
executor.shutdown()
......
......@@ -165,6 +165,7 @@ object AdMaxOpenUtils {
}
if (AdmobMaxHelper.isAdInit.get()) {
LogEx.logDebug(TAG, "appOpenAd loadAd")
val reqId = UUID.randomUUID().toString()
val obj = JSONObject()
obj.put("req_id", reqId)
......
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