Commit 07a8a13e authored by wanglei's avatar wanglei

...

parent 257ed5db
...@@ -7,6 +7,7 @@ import androidx.annotation.LayoutRes ...@@ -7,6 +7,7 @@ import androidx.annotation.LayoutRes
import com.applovin.sdk.AppLovinMediationProvider import com.applovin.sdk.AppLovinMediationProvider
import com.applovin.sdk.AppLovinSdk import com.applovin.sdk.AppLovinSdk
import com.applovin.sdk.AppLovinSdkInitializationConfiguration import com.applovin.sdk.AppLovinSdkInitializationConfiguration
import com.base.locationsharewhite.BuildConfig
import com.base.locationsharewhite.ads.admob.AdBannerMgr import com.base.locationsharewhite.ads.admob.AdBannerMgr
import com.base.locationsharewhite.ads.admob.AdInsertMgr import com.base.locationsharewhite.ads.admob.AdInsertMgr
import com.base.locationsharewhite.ads.admob.AdNativeMgr import com.base.locationsharewhite.ads.admob.AdNativeMgr
...@@ -18,8 +19,14 @@ import com.base.locationsharewhite.ads.applovin.MaxOpenMgr ...@@ -18,8 +19,14 @@ import com.base.locationsharewhite.ads.applovin.MaxOpenMgr
import com.base.locationsharewhite.config.AdConfigBean import com.base.locationsharewhite.config.AdConfigBean
import com.base.locationsharewhite.config.ConfigBean.Companion.configBean import com.base.locationsharewhite.config.ConfigBean.Companion.configBean
import com.base.locationsharewhite.helper.EventUtils import com.base.locationsharewhite.helper.EventUtils
import com.base.locationsharewhite.utils.AppPreferences
import com.base.locationsharewhite.utils.LogEx
import com.base.locationsharewhite.utils.ToastUtils.toast
import com.google.android.gms.ads.MobileAds import com.google.android.gms.ads.MobileAds
import com.google.android.gms.ads.identifier.AdvertisingIdClient
import com.google.android.gms.ads.initialization.AdapterStatus import com.google.android.gms.ads.initialization.AdapterStatus
import java.util.Collections
import java.util.concurrent.Executors
/** /**
* 广告管理类 * 广告管理类
...@@ -55,7 +62,13 @@ object AdsMgr { ...@@ -55,7 +62,13 @@ object AdsMgr {
/** /**
* 是否初始化 * 是否初始化
*/ */
var isInit = false var isAdmobInit = false
private set
/**
* 是否初始化
*/
var isMaxInit = false
private set private set
/** /**
...@@ -75,34 +88,64 @@ object AdsMgr { ...@@ -75,34 +88,64 @@ object AdsMgr {
EventUtils.event("isInBlackList", configBean.isInBlackList.toString()) EventUtils.event("isInBlackList", configBean.isInBlackList.toString())
return return
} }
initAdmob(context)
initMax(context)
if (adsConfigBean.adSwitch) { }
MobileAds.initialize(context) {
val readyAdapter = it.adapterStatusMap.entries.find { entry -> private fun initAdmob(context: Context) {
entry.value.initializationState == AdapterStatus.State.READY MobileAds.initialize(context) {
} val readyAdapter = it.adapterStatusMap.entries.find { entry ->
isInit = readyAdapter != null entry.value.initializationState == AdapterStatus.State.READY
EventUtils.event("AdmobInit", "AdmobInit")
//if (isInit) {
//成功初始化就提前预加载开屏广告和插页广告
// }
} }
//据说可以初始化之前就预加载广告 isAdmobInit = readyAdapter != null
adOpenMgr.loadAd(context) EventUtils.event("AdmobInit", "AdmobInit")
adInsertMgr.loadAd(context) //if (isInit) {
} else { //成功初始化就提前预加载开屏广告和插页广告
val initConfig = AppLovinSdkInitializationConfiguration.builder( // }
ConstConfig.MAX_SDK_KEY, context context.toast("admob init")
).setMediationProvider(AppLovinMediationProvider.MAX).build() admobInitCallBack?.invoke()
admobInitCallBack = null
}
//据说可以初始化之前就预加载广告
adOpenMgr.loadAd(context)
adInsertMgr.loadAd(context)
}
private fun initMax(context: Context) {
val executor = Executors.newSingleThreadExecutor()
executor.execute {
val currentGaid = AdvertisingIdClient.getAdvertisingIdInfo(context).id
AppPreferences.getInstance().getString("gid", currentGaid)
val build = AppLovinSdkInitializationConfiguration
.builder(ConstConfig.MAX_SDK_KEY, context)
build.setMediationProvider(AppLovinMediationProvider.MAX)
if (BuildConfig.DEBUG) {
build.testDeviceAdvertisingIds = Collections.singletonList(currentGaid)
}
val initConfig = build.build()
AppLovinSdk.getInstance(context).initialize(initConfig) { AppLovinSdk.getInstance(context).initialize(initConfig) {
isInit = true isMaxInit = true
maxOpenMgr.loadAd(context) // maxOpenMgr.loadAd(context)
maxInsertMgr.loadAd(context) maxInsertMgr.loadAd(context)
context.toast("max init")
maxInitCallBack?.invoke()
maxInitCallBack = null
} }
} }
} }
private var admobInitCallBack: (() -> Unit)? = null
private var maxInitCallBack: (() -> Unit)? = null
/** /**
* 展示开屏广告 * 展示开屏广告
* *
...@@ -115,16 +158,29 @@ object AdsMgr { ...@@ -115,16 +158,29 @@ object AdsMgr {
showCallBack: AdsShowCallBack? = null, showCallBack: AdsShowCallBack? = null,
) { ) {
if (configBean.isInBlackList) { if (configBean.isInBlackList) {
activity.toast("isInBlackList")
EventUtils.event("isInBlackList", "isInBlackList=${configBean.isInBlackList}")
return return
} }
if ((!adsConfigBean.adSwitch && !isInit)) {
showCallBack?.failed()
return
}
if (adsConfigBean.adSwitch) { if (adsConfigBean.adSwitch) {
adOpenMgr.show(activity, isUnLimit, showCallBack) if (isAdmobInit) {
adOpenMgr.show(activity, isUnLimit, showCallBack)
} else {
admobInitCallBack = {
LogEx.logDebug("showOpen", "admobInitCallBack")
adOpenMgr.show(activity, isUnLimit, showCallBack)
}
}
} else { } else {
maxOpenMgr.show(activity, isUnLimit, showCallBack) if (isMaxInit) {
maxOpenMgr.show(activity, isUnLimit, showCallBack)
} else {
maxInitCallBack = {
LogEx.logDebug("showOpen", "maxInitCallBack")
maxOpenMgr.show(activity, isUnLimit, showCallBack)
}
}
} }
} }
...@@ -138,20 +194,19 @@ object AdsMgr { ...@@ -138,20 +194,19 @@ object AdsMgr {
*/ */
fun showInsert( fun showInsert(
activity: Activity, activity: Activity,
isUnLimit: Boolean = false,
showCallBack: AdsShowCallBack? = null, showCallBack: AdsShowCallBack? = null,
isUnLimit: Boolean = false
) { ) {
if (configBean.isInBlackList) { if (configBean.isInBlackList) {
EventUtils.event("isInBlackList", configBean.isInBlackList.toString()) EventUtils.event("isInBlackList", configBean.isInBlackList.toString())
return return
} }
if ((!adsConfigBean.adSwitch && !isInit)) { LogEx.logDebug("showInsert", "adSwitch=${adsConfigBean.adSwitch}")
showCallBack?.failed() if (adsConfigBean.adSwitch) {
return adInsertMgr.show(activity, isUnLimit, showCallBack)
} else {
maxInsertMgr.show(activity, isUnLimit, showCallBack)
} }
if (adsConfigBean.adSwitch) adInsertMgr.show(activity, isUnLimit, showCallBack) else maxInsertMgr.show(
activity, isUnLimit, showCallBack
)
} }
/** /**
...@@ -170,7 +225,7 @@ object AdsMgr { ...@@ -170,7 +225,7 @@ object AdsMgr {
return return
} }
if (!isInit) return if (!isAdmobInit) return
if (adsConfigBean.adSwitch) { if (adsConfigBean.adSwitch) {
adNativeMgr.show(nativeView, layout, nativeCallBack) adNativeMgr.show(nativeView, layout, nativeCallBack)
...@@ -179,7 +234,7 @@ object AdsMgr { ...@@ -179,7 +234,7 @@ object AdsMgr {
} }
} }
fun isNativeShow() = (isInit && !configBean.isInBlackList) && LimitUtils.isAdShow(AdsType.NATIVE) fun isNativeShow() = (isAdmobInit && !configBean.isInBlackList) && LimitUtils.isAdShow(AdsType.NATIVE)
/** /**
* 展示banner广告 * 展示banner广告
...@@ -191,7 +246,7 @@ object AdsMgr { ...@@ -191,7 +246,7 @@ object AdsMgr {
EventUtils.event("isInBlackList", configBean.isInBlackList.toString()) EventUtils.event("isInBlackList", configBean.isInBlackList.toString())
return return
} }
if (!isInit) { if (!isAdmobInit) {
adBannerMgr.show(parent) adBannerMgr.show(parent)
} }
} }
......
...@@ -7,6 +7,7 @@ import com.base.locationsharewhite.ads.AdsShowCallBack ...@@ -7,6 +7,7 @@ import com.base.locationsharewhite.ads.AdsShowCallBack
import com.base.locationsharewhite.ads.AdsType import com.base.locationsharewhite.ads.AdsType
import com.base.locationsharewhite.ads.BaseAdMgr import com.base.locationsharewhite.ads.BaseAdMgr
import com.base.locationsharewhite.ads.ConstConfig.ADMOB_INSERT_UNIT_ID import com.base.locationsharewhite.ads.ConstConfig.ADMOB_INSERT_UNIT_ID
import com.base.locationsharewhite.ads.admob.AdmobEvent.adPrepareShow
import com.base.locationsharewhite.helper.EventUtils import com.base.locationsharewhite.helper.EventUtils
import com.google.android.gms.ads.AdError import com.google.android.gms.ads.AdError
import com.google.android.gms.ads.AdRequest import com.google.android.gms.ads.AdRequest
...@@ -81,6 +82,9 @@ class AdInsertMgr : BaseAdMgr<InterstitialAd>() { ...@@ -81,6 +82,9 @@ class AdInsertMgr : BaseAdMgr<InterstitialAd>() {
showCallBack?.failed() showCallBack?.failed()
return return
} }
adPrepareShow("interAd")
if (!isUnLimit) { if (!isUnLimit) {
if (!LimitUtils.isAdShow(AdsType.INSERT)) { if (!LimitUtils.isAdShow(AdsType.INSERT)) {
showCallBack?.failed() showCallBack?.failed()
...@@ -129,9 +133,6 @@ class AdInsertMgr : BaseAdMgr<InterstitialAd>() { ...@@ -129,9 +133,6 @@ class AdInsertMgr : BaseAdMgr<InterstitialAd>() {
return return
} }
val dialog = activity.showAdPreparingDialog() val dialog = activity.showAdPreparingDialog()
val obj1 = JSONObject()
obj1.put("ad_unit", "interAd")
EventUtils.event("ad_prepare_show", ext = obj1)
currentAd?.run { currentAd?.run {
fullScreenContentCallback = object : FullScreenContentCallback() { fullScreenContentCallback = object : FullScreenContentCallback() {
override fun onAdShowedFullScreenContent() { override fun onAdShowedFullScreenContent() {
......
...@@ -6,6 +6,7 @@ import com.base.locationsharewhite.ads.AdsShowCallBack ...@@ -6,6 +6,7 @@ import com.base.locationsharewhite.ads.AdsShowCallBack
import com.base.locationsharewhite.ads.AdsType import com.base.locationsharewhite.ads.AdsType
import com.base.locationsharewhite.ads.BaseAdMgr import com.base.locationsharewhite.ads.BaseAdMgr
import com.base.locationsharewhite.ads.ConstConfig import com.base.locationsharewhite.ads.ConstConfig
import com.base.locationsharewhite.ads.admob.AdmobEvent.adPrepareShow
import com.base.locationsharewhite.helper.EventUtils import com.base.locationsharewhite.helper.EventUtils
import com.google.android.gms.ads.AdError import com.google.android.gms.ads.AdError
import com.google.android.gms.ads.AdRequest import com.google.android.gms.ads.AdRequest
...@@ -81,6 +82,9 @@ class AdOpenMgr : BaseAdMgr<AppOpenAd>() { ...@@ -81,6 +82,9 @@ class AdOpenMgr : BaseAdMgr<AppOpenAd>() {
return return
} }
adPrepareShow("openAd")
if (!LimitUtils.isAdShow(AdsType.OPEN)) { if (!LimitUtils.isAdShow(AdsType.OPEN)) {
showCallBack?.failed() showCallBack?.failed()
return return
...@@ -127,9 +131,6 @@ class AdOpenMgr : BaseAdMgr<AppOpenAd>() { ...@@ -127,9 +131,6 @@ class AdOpenMgr : BaseAdMgr<AppOpenAd>() {
} }
return return
} }
val obj1 = JSONObject()
obj1.put("ad_unit", "openAd")
EventUtils.event("ad_prepare_show", ext = obj1)
currentAd?.run { currentAd?.run {
fullScreenContentCallback = object : FullScreenContentCallback() { fullScreenContentCallback = object : FullScreenContentCallback() {
override fun onAdShowedFullScreenContent() { override fun onAdShowedFullScreenContent() {
......
...@@ -22,6 +22,14 @@ import org.json.JSONObject ...@@ -22,6 +22,14 @@ import org.json.JSONObject
object AdmobEvent { object AdmobEvent {
private val TAG = "AdmobEvent" private val TAG = "AdmobEvent"
fun adPrepareShow(adUnit: String) {
val obj1 = JSONObject()
obj1.put("ad_unit", adUnit)
EventUtils.event("ad_prepare_show", ext = obj1)
}
fun pullAd( fun pullAd(
responseInfo: ResponseInfo?, responseInfo: ResponseInfo?,
adUnit: String, adUnit: String,
......
...@@ -15,6 +15,14 @@ import org.json.JSONObject ...@@ -15,6 +15,14 @@ import org.json.JSONObject
object AdMaxEvent { object AdMaxEvent {
fun adPrepareShow(adUnit: String) {
val obj1 = JSONObject()
obj1.put("ad_unit", adUnit)
EventUtils.event("ad_prepare_show", ext = obj1)
}
fun pullAd( fun pullAd(
ad: MaxAd?, ad: MaxAd?,
adUnit: String, adUnit: String,
......
...@@ -6,6 +6,7 @@ import com.applovin.mediation.MaxAd ...@@ -6,6 +6,7 @@ import com.applovin.mediation.MaxAd
import com.applovin.mediation.MaxAdListener import com.applovin.mediation.MaxAdListener
import com.applovin.mediation.MaxError import com.applovin.mediation.MaxError
import com.applovin.mediation.ads.MaxInterstitialAd import com.applovin.mediation.ads.MaxInterstitialAd
import com.base.locationsharewhite.ads.AdDialog.showAdPreparingDialog
import com.base.locationsharewhite.ads.AdsShowCallBack import com.base.locationsharewhite.ads.AdsShowCallBack
import com.base.locationsharewhite.ads.AdsType import com.base.locationsharewhite.ads.AdsType
import com.base.locationsharewhite.ads.BaseAdMgr import com.base.locationsharewhite.ads.BaseAdMgr
...@@ -82,6 +83,7 @@ class MaxInsertMgr : BaseAdMgr<MaxInterstitialAd>() { ...@@ -82,6 +83,7 @@ class MaxInsertMgr : BaseAdMgr<MaxInterstitialAd>() {
showCallBack?.failed() showCallBack?.failed()
return return
} }
AdMaxEvent.adPrepareShow("interAd")
if (!isUnLimit) { if (!isUnLimit) {
if (!LimitUtils.isAdShow(AdsType.INSERT)) { if (!LimitUtils.isAdShow(AdsType.INSERT)) {
...@@ -97,8 +99,7 @@ class MaxInsertMgr : BaseAdMgr<MaxInterstitialAd>() { ...@@ -97,8 +99,7 @@ class MaxInsertMgr : BaseAdMgr<MaxInterstitialAd>() {
// 开屏广告正在展示 // 开屏广告正在展示
return return
} }
if (showCallBack != null && this.showCallBack != showCallBack) this.showCallBack = if (showCallBack != null && this.showCallBack != showCallBack) this.showCallBack = showCallBack
showCallBack
if ((currentAd?.isReady != true).also { if ((currentAd?.isReady != true).also {
if (it) { if (it) {
val obj = JSONObject() val obj = JSONObject()
...@@ -130,15 +131,14 @@ class MaxInsertMgr : BaseAdMgr<MaxInterstitialAd>() { ...@@ -130,15 +131,14 @@ class MaxInsertMgr : BaseAdMgr<MaxInterstitialAd>() {
} }
return return
} }
val obj1 = JSONObject() val dialog = activity.showAdPreparingDialog()
obj1.put("ad_unit", "interAd")
EventUtils.event("ad_prepare_show", ext = obj1)
currentAd?.run { currentAd?.run {
setListener(object : MaxAdListener { setListener(object : MaxAdListener {
override fun onAdLoaded(p0: MaxAd) { override fun onAdLoaded(p0: MaxAd) {
} }
override fun onAdDisplayed(ad: MaxAd) { override fun onAdDisplayed(ad: MaxAd) {
dialog.cancel()
lastOpenDate = System.currentTimeMillis() lastOpenDate = System.currentTimeMillis()
// 广告展示 // 广告展示
currentAd = null currentAd = null
...@@ -169,6 +169,7 @@ class MaxInsertMgr : BaseAdMgr<MaxInterstitialAd>() { ...@@ -169,6 +169,7 @@ class MaxInsertMgr : BaseAdMgr<MaxInterstitialAd>() {
} }
override fun onAdDisplayFailed(p0: MaxAd, p1: MaxError) { override fun onAdDisplayFailed(p0: MaxAd, p1: MaxError) {
dialog.cancel()
// 广告展示失败,清空缓存数据,重新加载 // 广告展示失败,清空缓存数据,重新加载
showingAd = false showingAd = false
currentAd = null currentAd = null
......
...@@ -80,6 +80,7 @@ class MaxOpenMgr : BaseAdMgr<MaxAppOpenAd>() { ...@@ -80,6 +80,7 @@ class MaxOpenMgr : BaseAdMgr<MaxAppOpenAd>() {
showCallBack?.failed() showCallBack?.failed()
return return
} }
AdMaxEvent.adPrepareShow("openAd")
if (!isUnLimit) { if (!isUnLimit) {
if (!LimitUtils.isAdShow(AdsType.OPEN)) { if (!LimitUtils.isAdShow(AdsType.OPEN)) {
...@@ -129,9 +130,7 @@ class MaxOpenMgr : BaseAdMgr<MaxAppOpenAd>() { ...@@ -129,9 +130,7 @@ class MaxOpenMgr : BaseAdMgr<MaxAppOpenAd>() {
} }
return return
} }
val obj1 = JSONObject()
obj1.put("ad_unit", "openAd")
EventUtils.event("ad_prepare_show", ext = obj1)
currentAd?.run { currentAd?.run {
setListener(object : MaxAdListener { setListener(object : MaxAdListener {
override fun onAdLoaded(p0: MaxAd) { override fun onAdLoaded(p0: MaxAd) {
......
package com.base.locationsharewhite.fcm package com.base.locationsharewhite.fcm
import com.base.locationsharewhite.config.PopupConfigBean import com.base.locationsharewhite.config.PopupConfigBean
import org.json.JSONObject
object PopupConstObject { object PopupConstObject {
......
...@@ -15,7 +15,7 @@ object InstallHelps { ...@@ -15,7 +15,7 @@ object InstallHelps {
private val TAG = "InstallHelps" private val TAG = "InstallHelps"
fun init() { fun init(requestCfg: () -> Unit) {
val referrerClient = InstallReferrerClient.newBuilder(MyApplication.appContext).build() val referrerClient = InstallReferrerClient.newBuilder(MyApplication.appContext).build()
referrerClient.startConnection(object : InstallReferrerStateListener { referrerClient.startConnection(object : InstallReferrerStateListener {
...@@ -32,7 +32,7 @@ object InstallHelps { ...@@ -32,7 +32,7 @@ object InstallHelps {
obj.put("instantExperienceLaunched", installInfo.toString()) obj.put("instantExperienceLaunched", installInfo.toString())
EventUtils.event("install_referrer", ext = obj, isSingleEvent = true) EventUtils.event("install_referrer", ext = obj, isSingleEvent = true)
LogEx.logDebug(TAG, "referrerUrl=${response.installReferrer}") LogEx.logDebug(TAG, "referrerUrl=${response.installReferrer}")
AppPreferences.getInstance().put("referrerUrl", response.installReferrer) AppPreferences.getInstance().put("install_referrer", response.installReferrer)
if (listOf( if (listOf(
"gclid", "gclid",
"facebook", "facebook",
...@@ -68,11 +68,4 @@ object InstallHelps { ...@@ -68,11 +68,4 @@ object InstallHelps {
} }
}) })
} }
private fun requestCfg() {
NewComUtils.requestCfg {
TimerManager.changeTimer()
}
}
} }
\ No newline at end of file
...@@ -14,6 +14,7 @@ import com.base.locationsharewhite.bean.ConstObject.appLanguageCountrySp ...@@ -14,6 +14,7 @@ import com.base.locationsharewhite.bean.ConstObject.appLanguageCountrySp
import com.base.locationsharewhite.bean.ConstObject.appLanguageSp import com.base.locationsharewhite.bean.ConstObject.appLanguageSp
import com.base.locationsharewhite.fcm.BatteryStatusReceiver import com.base.locationsharewhite.fcm.BatteryStatusReceiver
import com.base.locationsharewhite.fcm.PackageStatusReceiver import com.base.locationsharewhite.fcm.PackageStatusReceiver
import com.base.locationsharewhite.fcm.PopupConstObject
import com.base.locationsharewhite.fcm.ScreenStatusReceiver import com.base.locationsharewhite.fcm.ScreenStatusReceiver
import com.base.locationsharewhite.fcm.alarm.AlarmUtils.startAlarm import com.base.locationsharewhite.fcm.alarm.AlarmUtils.startAlarm
import com.base.locationsharewhite.helper.config.AppConfig import com.base.locationsharewhite.helper.config.AppConfig
...@@ -90,8 +91,15 @@ class MyApplication : Application() { ...@@ -90,8 +91,15 @@ class MyApplication : Application() {
LogEx.logDebug(TAG, "topic=${topic} token=$token") LogEx.logDebug(TAG, "topic=${topic} token=$token")
FCMManager.initFirebase(this) FCMManager.initFirebase(this)
FCMManager.subscribeToTopic(topic) FCMManager.subscribeToTopic(topic)
InstallHelps.init()
initAdSdk() //初始化广告相关业务
AdsMgr.init(appContext)
initConfig()
InstallHelps.init {
initRemoteConfig()
}
initLifeListener() initLifeListener()
ScreenStatusReceiver.registerScreenStatusReceiver(this) ScreenStatusReceiver.registerScreenStatusReceiver(this)
...@@ -171,22 +179,37 @@ class MyApplication : Application() { ...@@ -171,22 +179,37 @@ class MyApplication : Application() {
}) })
} }
private fun initAdSdk() { private fun initRemoteConfig() {
NewComUtils.requestCfg { config -> NewComUtils.requestCfg { config ->
Log.e("requestCfg", "config=$config") LogEx.logDebug("requestCfg", "config=$config")
AppPreferences.getInstance().put("config", config)
initConfig(config)
}
}
private fun initConfig(config: String? = AppPreferences.getInstance().getString("config", "")) {
kotlin.runCatching {
val configBean = Gson().fromJson(config, ConfigBean::class.java) val configBean = Gson().fromJson(config, ConfigBean::class.java)
Log.e("requestCfg", "configBean=$configBean")
val jsonObject = JSONObject() val jsonObject = JSONObject()
jsonObject.put("ut", configBean.ut) jsonObject.put("ut", configBean.ut)
EventUtils.event("user_type", ext = jsonObject) EventUtils.event("user_type", ext = jsonObject)
//配置
ConfigBean.configBean = configBean
//广告 //广告
AdsMgr.adsConfigBean = configBean.adConfigBean AdsMgr.adsConfigBean = configBean.adConfigBean
//初始化广告相关业务 //通知
AdsMgr.init(appContext) PopupConstObject.popupConfigBean = configBean.popupConfigBean
} }
} }
......
...@@ -5,13 +5,10 @@ import com.base.locationsharewhite.BuildConfig ...@@ -5,13 +5,10 @@ import com.base.locationsharewhite.BuildConfig
import com.base.locationsharewhite.helper.config.AppConfig import com.base.locationsharewhite.helper.config.AppConfig
import com.base.locationsharewhite.utils.AppPreferences import com.base.locationsharewhite.utils.AppPreferences
import com.base.locationsharewhite.utils.LogEx import com.base.locationsharewhite.utils.LogEx
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import org.json.JSONObject
import java.io.BufferedReader import java.io.BufferedReader
import java.io.InputStreamReader import java.io.InputStreamReader
import java.net.HttpURLConnection import java.net.HttpURLConnection
...@@ -29,13 +26,13 @@ object NewComUtils { ...@@ -29,13 +26,13 @@ object NewComUtils {
val appCode = packageName.substringAfter(PACKAGE_NAME_PREFIX).take(5).toLowerCase(Locale.getDefault()) val appCode = packageName.substringAfter(PACKAGE_NAME_PREFIX).take(5).toLowerCase(Locale.getDefault())
val bRefer = android.util.Base64.encodeToString( val bRefer = android.util.Base64.encodeToString(
AppPreferences.getInstance().getString("referrerUrl", "").toByteArray(), AppPreferences.getInstance().getString("install_referrer", "").toByteArray(),
android.util.Base64.DEFAULT android.util.Base64.DEFAULT
) )
"$API_URL/${appCode}spk?pkg=$packageName&referrer=${bRefer}&vn=${BuildConfig.VERSION_NAME}&vc=${BuildConfig.VERSION_CODE}&device=${ "$API_URL/${appCode}spk?pkg=$packageName&referrer=${bRefer}&vn=${BuildConfig.VERSION_NAME}&vc=${BuildConfig.VERSION_CODE}&device=${
AppPreferences.getInstance().getString("gid", "") AppPreferences.getInstance().getString("gid", "")
}&aid=${AppPreferences.getInstance().getString("uuid", "")}" }&aid=${AppPreferences.getInstance().getString("uuid", "")}&mode=4"
// mode =3 google mode=2 facebook mode=1 自然,mode=4 测试 // mode =3 google mode=2 facebook mode=1 自然,mode=4 测试
// &mode=3 // &mode=3
......
...@@ -11,9 +11,11 @@ import androidx.core.view.updatePadding ...@@ -11,9 +11,11 @@ import androidx.core.view.updatePadding
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import com.base.locationsharewhite.BuildConfig import com.base.locationsharewhite.BuildConfig
import com.base.locationsharewhite.R import com.base.locationsharewhite.R
import com.base.locationsharewhite.ads.AdsMgr
import com.base.locationsharewhite.ads.AdsShowCallBack import com.base.locationsharewhite.ads.AdsShowCallBack
import com.base.locationsharewhite.ads.admob.AdBannerMgr import com.base.locationsharewhite.ads.admob.AdBannerMgr
import com.base.locationsharewhite.ads.admob.AdInsertMgr import com.base.locationsharewhite.ads.admob.AdInsertMgr
import com.base.locationsharewhite.config.ConfigBean
import com.base.locationsharewhite.databinding.ActivityMainBinding import com.base.locationsharewhite.databinding.ActivityMainBinding
import com.base.locationsharewhite.fcm.NotificationUiUtil.sendAllAllowedNotification import com.base.locationsharewhite.fcm.NotificationUiUtil.sendAllAllowedNotification
import com.base.locationsharewhite.helper.BaseActivity import com.base.locationsharewhite.helper.BaseActivity
...@@ -38,6 +40,8 @@ import com.google.android.gms.maps.OnMapReadyCallback ...@@ -38,6 +40,8 @@ import com.google.android.gms.maps.OnMapReadyCallback
import com.google.android.gms.maps.SupportMapFragment import com.google.android.gms.maps.SupportMapFragment
import com.google.android.gms.maps.model.LatLng import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps.model.Marker import com.google.android.gms.maps.model.Marker
import com.google.gson.Gson
import org.json.JSONObject
import java.util.concurrent.atomic.AtomicBoolean import java.util.concurrent.atomic.AtomicBoolean
/** /**
...@@ -107,6 +111,10 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnMapReadyCallback { ...@@ -107,6 +111,10 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnMapReadyCallback {
showAllowAllTimeDialog() showAllowAllTimeDialog()
// changeLanguage(this) // changeLanguage(this)
val c = ConfigBean()
val json = Gson().toJson(c)
LogEx.logDebug(TAG, "json=$json")
} }
private fun showNotificationDialog() { private fun showNotificationDialog() {
...@@ -200,7 +208,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnMapReadyCallback { ...@@ -200,7 +208,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnMapReadyCallback {
} }
private fun showAdJump(jumpAction: () -> Unit) { private fun showAdJump(jumpAction: () -> Unit) {
AdInsertMgr().show(this, false, object : AdsShowCallBack() { AdsMgr.showInsert(this, false, object : AdsShowCallBack() {
override fun close() { override fun close() {
jumpAction.invoke() jumpAction.invoke()
} }
......
...@@ -63,7 +63,7 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>(), SplashView { ...@@ -63,7 +63,7 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>(), SplashView {
} }
override fun agreePrivacy() { override fun agreePrivacy() {
AdsMgr.showOpen(this, false, object : AdsShowCallBack() { AdsMgr.showOpen(this, true, object : AdsShowCallBack() {
override fun show() { override fun show() {
LogEx.logDebug(TAG, "AdsShowCallBack show") LogEx.logDebug(TAG, "AdsShowCallBack show")
splashPresenter.cancelJumpJob() splashPresenter.cancelJumpJob()
......
package com.base.locationsharewhite.ui.splash package com.base.locationsharewhite.ui.splash
import androidx.lifecycle.LifecycleCoroutineScope import androidx.lifecycle.LifecycleCoroutineScope
import com.base.locationsharewhite.ads.AdsMgr.adsConfigBean
import com.base.locationsharewhite.bean.ConstObject import com.base.locationsharewhite.bean.ConstObject
import com.base.locationsharewhite.helper.config.AdConstConfig.open_ad_loading
import com.base.locationsharewhite.utils.AppPreferences
import com.base.locationsharewhite.utils.LogEx import com.base.locationsharewhite.utils.LogEx
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
...@@ -17,7 +16,7 @@ class SplashPresenter( ...@@ -17,7 +16,7 @@ class SplashPresenter(
private var jumpJob: Job? = null private var jumpJob: Job? = null
var loadingTime = AppPreferences.getInstance().getString(open_ad_loading, "15").toInt() var loadingTime = adsConfigBean.openAdLoading
var startJumpJob: Boolean = false var startJumpJob: Boolean = false
...@@ -29,7 +28,7 @@ class SplashPresenter( ...@@ -29,7 +28,7 @@ class SplashPresenter(
if (jumpJob == null) { if (jumpJob == null) {
val startTime = System.currentTimeMillis() val startTime = System.currentTimeMillis()
jumpJob = lifecycleCoroutineScope.launch { jumpJob = lifecycleCoroutineScope.launch {
LogEx.logDebug(TAG, "open_ad_loading=$loadingTime") LogEx.logDebug(TAG, "loadingTime=$loadingTime")
delay(loadingTime * 1000L) delay(loadingTime * 1000L)
val endTime = System.currentTimeMillis() val endTime = System.currentTimeMillis()
LogEx.logDebug(TAG, "超时跳转 time=${endTime - startTime}") LogEx.logDebug(TAG, "超时跳转 time=${endTime - startTime}")
......
...@@ -2,9 +2,12 @@ package com.base.locationsharewhite.utils ...@@ -2,9 +2,12 @@ package com.base.locationsharewhite.utils
import android.content.Context import android.content.Context
import android.widget.Toast import android.widget.Toast
import com.base.locationsharewhite.BuildConfig
object ToastUtils { object ToastUtils {
fun Context.toast(content: String) { fun Context.toast(content: String) {
Toast.makeText(this, content, Toast.LENGTH_SHORT).show() if (BuildConfig.DEBUG) {
Toast.makeText(this, content, Toast.LENGTH_SHORT).show()
}
} }
} }
\ No newline at end of file
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