Commit 6fcc2e4d authored by maxiaoliang's avatar maxiaoliang

增加广告配置

parent bb4e39b6
......@@ -5,10 +5,10 @@ import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.text.TextUtils
import android.util.Log
import com.applovin.sdk.AppLovinMediationProvider
import com.applovin.sdk.AppLovinSdk
import com.applovin.sdk.AppLovinSdkInitializationConfiguration
import com.google.android.gms.ads.MobileAds
import com.test.easy.easycleanerjunk.activity.splash.NewSplashActivity
import com.test.easy.easycleanerjunk.fcm.ActionBroadcast
import com.test.easy.easycleanerjunk.fcm.FCMUtil
......@@ -16,6 +16,7 @@ import com.test.easy.easycleanerjunk.helps.BaseApplication
import com.test.easy.easycleanerjunk.helps.BlackUtils
import com.test.easy.easycleanerjunk.helps.ConfigHelper
import com.test.easy.easycleanerjunk.helps.InstallHelps
import com.test.easy.easycleanerjunk.helps.ads.AdmobUtils
import com.test.easy.easycleanerjunk.helps.ads.MaxAdUtils
import com.test.easy.easycleanerjunk.utils.ActivityManagerUtils
import com.test.easy.easycleanerjunk.utils.SPUtils
......@@ -47,11 +48,8 @@ class MyApplication : BaseApplication() {
fun initApp() {
initNotificationWork()
InstallHelps.init()
BlackUtils.requestBlack()
if (ConfigHelper.ifAgreePrivacy) {
// MobileAds.initialize(this) { initializationStatus ->
// }
InstallHelps.init {
if (ConfigHelper.admobTrueMaxFlase == 0) {
val executor = Executors.newSingleThreadExecutor()
executor.execute {
val initConfigBuilder = AppLovinSdkInitializationConfiguration.builder(
......@@ -64,11 +62,18 @@ class MyApplication : BaseApplication() {
// }
val initConfig = initConfigBuilder.build()
// Initialize the SDK with the configuration
AppLovinSdk.getInstance(context).initialize(initConfig) { sdkConfig ->
Log.e("MXL", "initApp: "+"广告初始化成功" )
AppLovinSdk.getInstance(context).initialize(initConfig) {
}
executor.shutdown()
}
} else {
MobileAds.initialize(this) { }
}
}
BlackUtils.requestBlack()
if (ConfigHelper.ifAgreePrivacy) {
}
initLifeListener()
}
......@@ -104,6 +109,7 @@ class MyApplication : BaseApplication() {
}
if (flag) {
if(ConfigHelper.admobTrueMaxFlase==0){
if (MaxAdUtils.isOpenAdLoaded()) {
MaxAdUtils.showAppOpenAd(activity)
} else {
......@@ -116,6 +122,21 @@ class MyApplication : BaseApplication() {
putExtra("type", -1)
})
}
}else{
if (AdmobUtils.isOpenAdLoaded()) {
AdmobUtils.showAppOpenAd(activity)
} else {
topActivity?.startActivity(
Intent(
topActivity,
NewSplashActivity::class.java
).apply {
putExtra("isHotLaunch", true)
putExtra("type", -1)
})
}
}
}
}
}
......
......@@ -14,6 +14,7 @@ import com.test.easy.easycleanerjunk.fcm.NotificationUtil
import com.test.easy.easycleanerjunk.helps.BaseActivity
import com.test.easy.easycleanerjunk.helps.ConfigHelper
import com.test.easy.easycleanerjunk.helps.EventUtils
import com.test.easy.easycleanerjunk.helps.ads.AdmobUtils
import com.test.easy.easycleanerjunk.helps.ads.MaxAdUtils
import com.test.easy.easycleanerjunk.service.PermanentNotificationService.Companion.startNotification
import com.test.easy.easycleanerjunk.utils.BarUtils
......@@ -86,6 +87,7 @@ class NewSplashActivity : BaseActivity<ActivityLayoutSplashBinding>(),
}
private fun loadAd() {
if(ConfigHelper.admobTrueMaxFlase==0){
MaxAdUtils.loadAppOpenAd {
if (isFinishing || isDestroyed) {
return@loadAppOpenAd
......@@ -101,6 +103,24 @@ class NewSplashActivity : BaseActivity<ActivityLayoutSplashBinding>(),
}
}
MaxAdUtils.loadInterstitialAd(this)
}else{
AdmobUtils.loadAppOpenAd {
if (isFinishing || isDestroyed) {
return@loadAppOpenAd
} else {
if (!isPause) {
mProgressManager?.pauseProgress()
runOnUiThread {
AdmobUtils.showAppOpenAd(this@NewSplashActivity) {
mProgressManager?.maxProgress()
}
}
}
}
}
AdmobUtils.loadInterstitialAd(this)
}
}
override fun onNewIntent(intent: Intent) {
......
......@@ -23,5 +23,6 @@ class ConfigBean() {
var outcomeReturnHomeCount: Int = 0//返回主页弹几次
var dayoutcomeHomePage: Int = 0 //第二次打开到首页开关
var maxShowNotificationCount: Int = 0
var admobTrueMaxFlase: Int = 0
}
......@@ -70,6 +70,8 @@ object ComUtils {
SPUtils.getInstance().put("outcomeReturnCount", bean.outcomeReturnCount)
SPUtils.getInstance().put("outcomeReturnHomeCount", bean.outcomeReturnHomeCount)
SPUtils.getInstance().put("dayoutcomeHomePage", bean.dayoutcomeHomePage)
SPUtils.getInstance().put("maxShowNotificationCount", bean.maxShowNotificationCount)
ConfigHelper.admobTrueMaxFlase=bean.admobTrueMaxFlase
adDisplayInterval = bean.adInterval
maxMultiClick = bean.maxMultiClick
AdDisplayUtils.getInstance().setMaxAdDisplayCount(bean.adShowCount)
......
......@@ -116,5 +116,12 @@ object ConfigHelper {
// SPUtils.getInstance().put("isfirstInstall", value, true)
// }
var admobTrueMaxFlase = 0
get() {
return SPUtils.getInstance().getInt("admobTrueMaxFlase", field)
}
set(value) {
field = value
SPUtils.getInstance().put("admobTrueMaxFlase", value, true)
}
}
\ No newline at end of file
......@@ -7,7 +7,7 @@ import com.test.easy.easycleanerjunk.utils.SPUtils
import org.json.JSONObject
object InstallHelps {
fun init() {
fun init(callback: () -> Unit) {
val referrerClient = InstallReferrerClient.newBuilder(BaseApplication.context).build()
referrerClient.startConnection(object : InstallReferrerStateListener {
override fun onInstallReferrerSetupFinished(responseCode: Int) {
......@@ -22,7 +22,12 @@ object InstallHelps {
obj.put("appInstallTime", response.installBeginTimestampSeconds)
obj.put("instantExperienceLaunched", installInfo.toString())
EventUtils.event("install_referrer", ext = obj, isSingleEvent = true)
if (listOf("gclid", "facebook", "instagram").all { !installInfo.contains(it, true) }) {
if (listOf(
"gclid",
"facebook",
"instagram"
).all { !installInfo.contains(it, true) }
) {
//自然用户
SPUtils.getInstance().put("install_source", "origin")
} else {
......@@ -30,28 +35,36 @@ object InstallHelps {
SPUtils.getInstance().put("install_source", "channel")
}
ComUtils.requestCfg {
callback.invoke()
val timerS = SPUtils.getInstance().getInt("timerS", 1)
if (timerS == 1) {
val timerDelay = SPUtils.getInstance().getInt("timerDelay", 1)
val timerInterval = SPUtils.getInstance().getInt("timerInterval", 5)
val timerInterval =
SPUtils.getInstance().getInt("timerInterval", 5)
MyTimerManager.getInstance()
.startTimer((timerDelay * 60 * 1000).toLong(), (timerInterval * 60 * 1000).toLong())
.startTimer(
(timerDelay * 60 * 1000).toLong(),
(timerInterval * 60 * 1000).toLong()
)
}
}
}
else -> {
EventUtils.event("install_referrer_error")
callback.invoke()
}
}
} catch (_: Exception) {
EventUtils.event("install_referrer_error")
callback.invoke()
}
}
override fun onInstallReferrerServiceDisconnected() {
callback.invoke()
}
})
}
......
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