Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
L
location share white
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wanglei
location share white
Commits
cfd8ca08
Commit
cfd8ca08
authored
Dec 04, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
07a8a13e
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
797 additions
and
738 deletions
+797
-738
AdDialog.kt
...src/main/java/com/base/locationsharewhite/ads/AdDialog.kt
+4
-1
AdEvent.kt
app/src/main/java/com/base/locationsharewhite/ads/AdEvent.kt
+55
-0
AdsMgr.kt
app/src/main/java/com/base/locationsharewhite/ads/AdsMgr.kt
+30
-28
AdsShowCallBack.kt
...n/java/com/base/locationsharewhite/ads/AdsShowCallBack.kt
+3
-3
BaseAdMgr.kt
...rc/main/java/com/base/locationsharewhite/ads/BaseAdMgr.kt
+85
-3
LimitUtils.kt
...c/main/java/com/base/locationsharewhite/ads/LimitUtils.kt
+25
-37
AdBannerMgr.kt
...java/com/base/locationsharewhite/ads/admob/AdBannerMgr.kt
+17
-4
AdInsertMgr.kt
...java/com/base/locationsharewhite/ads/admob/AdInsertMgr.kt
+98
-131
AdNativeMgr.kt
...java/com/base/locationsharewhite/ads/admob/AdNativeMgr.kt
+28
-47
AdOpenMgr.kt
...n/java/com/base/locationsharewhite/ads/admob/AdOpenMgr.kt
+95
-130
AdmobEvent.kt
.../java/com/base/locationsharewhite/ads/admob/AdmobEvent.kt
+77
-56
AdMaxEvent.kt
...va/com/base/locationsharewhite/ads/applovin/AdMaxEvent.kt
+20
-13
MaxInsertMgr.kt
.../com/base/locationsharewhite/ads/applovin/MaxInsertMgr.kt
+122
-138
MaxNativeMgr.kt
.../com/base/locationsharewhite/ads/applovin/MaxNativeMgr.kt
+15
-9
MaxOpenMgr.kt
...va/com/base/locationsharewhite/ads/applovin/MaxOpenMgr.kt
+111
-129
AdConfigBean.kt
...n/java/com/base/locationsharewhite/config/AdConfigBean.kt
+1
-1
MainActivity.kt
.../java/com/base/locationsharewhite/ui/main/MainActivity.kt
+7
-4
SplashActivity.kt
...a/com/base/locationsharewhite/ui/splash/SplashActivity.kt
+3
-3
DialogView.kt
...n/java/com/base/locationsharewhite/ui/views/DialogView.kt
+1
-1
No files found.
app/src/main/java/com/base/locationsharewhite/ads/AdDialog.kt
View file @
cfd8ca08
...
...
@@ -8,11 +8,14 @@ import android.view.LayoutInflater
import
android.view.animation.LinearInterpolator
import
com.base.locationsharewhite.databinding.DialogAdPreparingBinding
import
com.base.locationsharewhite.utils.DensityUtils
import
com.base.locationsharewhite.utils.LogEx
object
AdDialog
{
fun
Context
.
showAdPreparingDialog
():
AlertDialog
{
private
val
TAG
=
"AdDialog"
fun
Context
.
showAdPreparingDialog
(
where
:
Int
=
0
):
AlertDialog
{
LogEx
.
logDebug
(
TAG
,
"where=$where"
)
val
binding
=
DialogAdPreparingBinding
.
inflate
(
LayoutInflater
.
from
(
this
))
val
dialog
=
AlertDialog
.
Builder
(
this
).
create
()
dialog
.
setView
(
binding
.
root
)
...
...
app/src/main/java/com/base/locationsharewhite/ads/AdEvent.kt
0 → 100644
View file @
cfd8ca08
package
com.base.locationsharewhite.ads
import
com.base.locationsharewhite.helper.EventUtils
import
com.base.locationsharewhite.utils.LogEx
import
org.json.JSONObject
import
java.util.UUID
abstract
class
AdEvent
{
abstract
val
TAG
:
String
var
adUnit
:
String
=
""
var
from
:
String
=
""
val
reqId
=
UUID
.
randomUUID
().
toString
()
fun
adPrepareShow
()
{
val
obj1
=
JSONObject
()
obj1
.
put
(
"ad_unit"
,
adUnit
)
obj1
.
put
(
"req_id"
,
reqId
)
obj1
.
put
(
"from"
,
from
)
EventUtils
.
event
(
"ad_prepare_show"
,
ext
=
obj1
)
LogEx
.
logDebug
(
TAG
,
"ad_prepare_show $obj1"
)
}
fun
adPulStart
()
{
val
obj
=
JSONObject
()
obj
.
put
(
"req_id"
,
reqId
)
obj
.
put
(
"ad_unit"
,
adUnit
)
obj
.
put
(
"ad_type"
,
adUnit
)
obj
.
put
(
"from"
,
from
)
EventUtils
.
event
(
"ad_pull_start"
,
ext
=
obj
)
LogEx
.
logDebug
(
TAG
,
"ad_pull_start $obj"
)
}
fun
adShowError
(
reason
:
Any
)
{
val
obj
=
JSONObject
()
obj
.
put
(
"ad_unit"
,
adUnit
)
obj
.
put
(
"req_id"
,
reqId
)
obj
.
put
(
"from"
,
from
)
obj
.
put
(
"reason"
,
reason
.
toString
())
EventUtils
.
event
(
"ad_show_error"
,
ext
=
obj
)
LogEx
.
logDebug
(
TAG
,
"ad_show_error $obj"
)
}
fun
adLimited
(
value
:
String
)
{
val
obj
=
JSONObject
()
obj
.
put
(
"ad_unit"
,
adUnit
)
obj
.
put
(
"req_id"
,
reqId
)
EventUtils
.
event
(
"ad_limit"
,
value
,
obj
)
LogEx
.
logDebug
(
TAG
,
"ad_limit $obj"
)
}
}
\ No newline at end of file
app/src/main/java/com/base/locationsharewhite/ads/AdsMgr.kt
View file @
cfd8ca08
...
...
@@ -12,7 +12,8 @@ import com.base.locationsharewhite.ads.admob.AdBannerMgr
import
com.base.locationsharewhite.ads.admob.AdInsertMgr
import
com.base.locationsharewhite.ads.admob.AdNativeMgr
import
com.base.locationsharewhite.ads.admob.AdOpenMgr
import
com.base.locationsharewhite.ads.admob.LimitUtils
import
com.base.locationsharewhite.ads.admob.AdmobEvent
import
com.base.locationsharewhite.ads.applovin.AdMaxEvent
import
com.base.locationsharewhite.ads.applovin.MaxInsertMgr
import
com.base.locationsharewhite.ads.applovin.MaxNativeMgr
import
com.base.locationsharewhite.ads.applovin.MaxOpenMgr
...
...
@@ -100,16 +101,16 @@ object AdsMgr {
}
isAdmobInit
=
readyAdapter
!=
null
EventUtils
.
event
(
"AdmobInit"
,
"AdmobInit"
)
//if (isInit) {
//成功初始化就提前预加载开屏广告和插页广告
// }
context
.
toast
(
"admob init"
)
admobInitCallBack
?.
invoke
()
admobInitCallBack
=
null
if
(
adsConfigBean
.
adSwitch
)
{
admobInitCallBack
?.
invoke
()
admobInitCallBack
=
null
adOpenMgr
.
loadAd
(
context
,
false
,
AdmobEvent
(
"openAd"
,
context
::
class
.
java
.
simpleName
))
adInsertMgr
.
loadAd
(
context
,
false
,
AdmobEvent
(
"interAd"
,
context
::
class
.
java
.
simpleName
))
}
}
//据说可以初始化之前就预加载广告
adOpenMgr
.
loadAd
(
context
)
adInsertMgr
.
loadAd
(
context
)
}
private
fun
initMax
(
context
:
Context
)
{
...
...
@@ -131,11 +132,12 @@ object AdsMgr {
AppLovinSdk
.
getInstance
(
context
).
initialize
(
initConfig
)
{
isMaxInit
=
true
// maxOpenMgr.loadAd(context)
maxInsertMgr
.
loadAd
(
context
)
context
.
toast
(
"max init"
)
maxInitCallBack
?.
invoke
()
maxInitCallBack
=
null
if
(!
adsConfigBean
.
adSwitch
)
{
maxInsertMgr
.
loadAd
(
context
,
false
,
AdMaxEvent
(
"interAd"
,
context
::
class
.
java
.
simpleName
))
context
.
toast
(
"max init"
)
maxInitCallBack
?.
invoke
()
maxInitCallBack
=
null
}
}
}
...
...
@@ -158,27 +160,25 @@ object AdsMgr {
showCallBack
:
AdsShowCallBack
?
=
null
,
)
{
if
(
configBean
.
isInBlackList
)
{
activity
.
toast
(
"isInBlackList"
)
EventUtils
.
event
(
"isInBlackList"
,
"isInBlackList=${configBean.isInBlackList}"
)
return
}
val
from
=
activity
::
class
.
java
.
simpleName
if
(
adsConfigBean
.
adSwitch
)
{
if
(
isAdmobInit
)
{
adOpenMgr
.
show
(
activity
,
isUnLimit
,
showCallBack
)
adOpenMgr
.
show
(
activity
,
isUnLimit
,
AdmobEvent
(
"openAd"
,
from
),
showCallBack
)
}
else
{
admobInitCallBack
=
{
LogEx
.
logDebug
(
"showOpen"
,
"admobInitCallBack"
)
adOpenMgr
.
show
(
activity
,
isUnLimit
,
showCallBack
)
adOpenMgr
.
show
(
activity
,
isUnLimit
,
AdmobEvent
(
"openAd"
,
from
),
showCallBack
)
}
}
}
else
{
if
(
isMaxInit
)
{
maxOpenMgr
.
show
(
activity
,
isUnLimit
,
showCallBack
)
maxOpenMgr
.
show
(
activity
,
isUnLimit
,
AdMaxEvent
(
"openAd"
,
from
),
showCallBack
)
}
else
{
maxInitCallBack
=
{
LogEx
.
logDebug
(
"showOpen"
,
"maxInitCallBack"
)
maxOpenMgr
.
show
(
activity
,
isUnLimit
,
showCallBack
)
maxOpenMgr
.
show
(
activity
,
isUnLimit
,
AdMaxEvent
(
"openAd"
,
from
),
showCallBack
)
}
}
}
...
...
@@ -201,11 +201,12 @@ object AdsMgr {
EventUtils
.
event
(
"isInBlackList"
,
configBean
.
isInBlackList
.
toString
())
return
}
LogEx
.
logDebug
(
"showInsert"
,
"adSwitch=${adsConfigBean.adSwitch}"
)
LogEx
.
logDebug
(
"showAd"
,
"adSwitch=${adsConfigBean.adSwitch}"
)
val
from
=
activity
::
class
.
java
.
simpleName
if
(
adsConfigBean
.
adSwitch
)
{
adInsertMgr
.
show
(
activity
,
isUnLimit
,
showCallBack
)
adInsertMgr
.
show
(
activity
,
isUnLimit
,
AdmobEvent
(
"interAd"
,
from
),
showCallBack
)
}
else
{
maxInsertMgr
.
show
(
activity
,
isUnLimit
,
showCallBack
)
maxInsertMgr
.
show
(
activity
,
isUnLimit
,
AdMaxEvent
(
"interAd"
,
from
),
showCallBack
)
}
}
...
...
@@ -227,14 +228,15 @@ object AdsMgr {
if
(!
isAdmobInit
)
return
if
(
adsConfigBean
.
adSwitch
)
{
adNativeMgr
.
show
(
nativeView
,
layout
,
nativeCallBack
)
adNativeMgr
.
show
(
AdmobEvent
(
"nativeAd"
,
"nativeAd"
),
nativeView
,
layout
,
nativeCallBack
)
}
else
{
maxNativeMgr
.
show
(
nativeView
,
layout
,
nativeCallBack
)
maxNativeMgr
.
show
(
AdMaxEvent
(
"nativeAd"
,
"nativeAd"
),
nativeView
,
layout
,
nativeCallBack
)
}
}
fun
isNativeShow
()
=
(
isAdmobInit
&&
!
configBean
.
isInBlackList
)
&&
LimitUtils
.
isAdShow
(
AdsType
.
NATIVE
)
fun
isNativeShow
()
=
(
isAdmobInit
&&
!
configBean
.
isInBlackList
)
&&
LimitUtils
.
isAdShow
(
AdsType
.
NATIVE
,
null
)
/**
* 展示banner广告
...
...
@@ -246,7 +248,7 @@ object AdsMgr {
EventUtils
.
event
(
"isInBlackList"
,
configBean
.
isInBlackList
.
toString
())
return
}
if
(
!
isAdmobInit
)
{
if
(
adsConfigBean
.
adSwitch
)
{
adBannerMgr
.
show
(
parent
)
}
}
...
...
app/src/main/java/com/base/locationsharewhite/ads/AdsShowCallBack.kt
View file @
cfd8ca08
...
...
@@ -2,7 +2,7 @@ package com.base.locationsharewhite.ads
abstract
class
AdsShowCallBack
{
open
fun
show
()
{}
abstract
fun
close
()
abstract
fun
failed
()
abstract
fun
googleFailed
()
abstract
fun
close
(
where
:
Int
=
0
)
abstract
fun
failed
(
where
:
Int
=
0
)
abstract
fun
googleFailed
(
where
:
Int
=
0
)
}
\ No newline at end of file
app/src/main/java/com/base/locationsharewhite/ads/BaseAdMgr.kt
View file @
cfd8ca08
package
com.base.locationsharewhite.ads
import
android.app.Activity
import
android.app.Dialog
import
android.content.Context
import
java.lang.ref.WeakReference
class
adState
<
T
>()
{
var
adDialog
:
Dialog
?
=
null
/**
* 当前缓存的广告
*/
var
currentAd
:
T
?
=
null
/**
* 是否正在缓存加载广告
*/
var
loadingAd
:
Boolean
=
false
/**
* 是否正在显示广告
*/
var
showingAd
:
Boolean
=
false
/**
* 用于保存引用现有页面,在此页面显示广告(因为要等待广告加载完毕)
*/
var
activityRef
:
WeakReference
<
Activity
>?
=
null
/**
* 上一次的缓存成功时间
*/
var
lastLoadTime
:
Long
=
0
/**
* 上次展示时间
*/
var
lastShowTime
:
Long
=
0
fun
onAdDisplayed
()
{
showingAd
=
true
adDialog
?.
dismiss
()
adDialog
=
null
lastShowTime
=
System
.
currentTimeMillis
()
currentAd
=
null
activityRef
=
null
}
fun
onAdHidden
()
{
// 广告关闭,清空缓存数据,重新加载
showingAd
=
false
}
fun
onAdDisplayFailed
()
{
adDialog
?.
dismiss
()
adDialog
=
null
showingAd
=
false
currentAd
=
null
activityRef
=
null
}
fun
onAdLoaded
(
ad
:
T
?)
{
//这里可能提前设置,所有可以不设置,max回调的类型可能不同
if
(
ad
!=
null
)
{
currentAd
=
ad
}
loadingAd
=
false
lastLoadTime
=
System
.
currentTimeMillis
()
}
fun
onAdLoadFailed
()
{
adDialog
?.
dismiss
()
adDialog
=
null
loadingAd
=
false
}
}
/**
* 特定广告管理基类
* @param T 缓存广告的类
...
...
@@ -38,7 +120,7 @@ abstract class BaseAdMgr<T> {
/**
* 上一次的缓存成功时间
*/
protected
var
lastTime
:
Long
=
0
protected
var
last
Load
Time
:
Long
=
0
/**
...
...
@@ -46,14 +128,14 @@ abstract class BaseAdMgr<T> {
*
* @param context 加载所用的上下文,一般使用appContext
*/
abstract
fun
loadAd
(
context
:
Context
,
isUnLimit
:
Boolean
=
true
)
abstract
fun
loadAd
(
context
:
Context
,
isUnLimit
:
Boolean
=
true
,
adEvent
:
AdEvent
)
/**
* 广告显示
*
* @param activity 当前页面
*/
abstract
fun
show
(
activity
:
Activity
,
isUnLimit
:
Boolean
=
true
,
showCallBack
:
AdsShowCallBack
?
=
null
)
abstract
fun
show
(
activity
:
Activity
,
isUnLimit
:
Boolean
=
true
,
adEvent
:
AdEvent
,
showCallBack
:
AdsShowCallBack
?
=
null
)
/**
...
...
app/src/main/java/com/base/locationsharewhite/ads/
admob/
LimitUtils.kt
→
app/src/main/java/com/base/locationsharewhite/ads/LimitUtils.kt
View file @
cfd8ca08
package
com.base.locationsharewhite.ads
.admob
package
com.base.locationsharewhite.ads
import
com.base.locationsharewhite.ads.AdsMgr
import
com.base.locationsharewhite.ads.AdsType
import
com.base.locationsharewhite.helper.EventUtils
import
com.base.locationsharewhite.utils.AppPreferences
import
com.base.locationsharewhite.utils.KotlinExt.toFormatTime4
import
com.base.locationsharewhite.utils.LogEx
/**
...
...
@@ -75,7 +71,7 @@ object LimitUtils {
*
* @return true or false
*/
fun
isAdShow
(
adsType
:
AdsType
):
Boolean
{
fun
isAdShow
(
adsType
:
AdsType
,
adEvent
:
AdEvent
?
):
Boolean
{
val
currentDate
=
System
.
currentTimeMillis
().
toFormatTime4
()
if
(
saveDate
!=
currentDate
)
{
//如果已经不是今天了,就重置个数
...
...
@@ -85,39 +81,27 @@ object LimitUtils {
AppPreferences
.
getInstance
().
put
(
NUM_CLICK
,
0
)
}
if
(
isDisplayLimited
)
{
LogEx
.
logDebug
(
"LimitUtils"
,
"isDisplayLimited"
)
EventUtils
.
event
(
"ad_limit"
,
"current${getAdEventMsg(adsType)}Show=${
AppPreferences
.
getInstance
()
.
getInt
(
NUM_DISPLAY
,
0
)
}
$
{
getAdEventMsg
(
adsType
).
lowercase
()}
_max_show
=
$
{
AdsMgr
.
adsConfigBean
?.
numDisplayLimit
}
"
)
val
value
=
"current${getAdEventMsg(adsType)} "
+
"show=${AppPreferences.getInstance().getInt(NUM_DISPLAY, 0)} "
+
"${getAdEventMsg(adsType).lowercase()}_"
+
"max_show=${AdsMgr.adsConfigBean.numDisplayLimit}"
adEvent
?.
adLimited
(
value
)
}
if
(
isClickLimited
)
{
LogEx
.
logDebug
(
"LimitUtils"
,
"isClickLimited"
)
EventUtils
.
event
(
"ad_limit"
,
"current${getAdEventMsg(adsType)}Click=${
AppPreferences
.
getInstance
()
.
getInt
(
NUM_CLICK
,
0
)
}
$
{
getAdEventMsg
(
adsType
).
lowercase
()}
_max_click
=
$
{
AdsMgr
.
adsConfigBean
?.
numClickLimit
}
"
)
val
value
=
"current${getAdEventMsg(adsType)}Click=${AppPreferences.getInstance().getInt(NUM_CLICK, 0)} "
"${getAdEventMsg(adsType).lowercase()}_max_click=${AdsMgr.adsConfigBean.numClickLimit}"
adEvent
?.
adLimited
(
value
)
}
if
(
isRequestLimited
)
{
LogEx
.
logDebug
(
"LimitUtils"
,
"isRequestLimited"
)
EventUtils
.
event
(
"ad_limit"
,
"current${getAdEventMsg(adsType)}Request=${
AppPreferences
.
getInstance
()
.
getInt
(
NUM_REQUEST
,
0
)
}
$
{
getAdEventMsg
(
adsType
).
lowercase
()}
_max_request
=
$
{
AdsMgr
.
adsConfigBean
?.
numRequestLimit
}
"
)
val
value
=
"current${getAdEventMsg(adsType)}Request=${AppPreferences.getInstance().getInt(NUM_REQUEST, 0)} "
+
"${getAdEventMsg(adsType).lowercase()}_max_request=${AdsMgr.adsConfigBean.numRequestLimit}"
adEvent
?.
adLimited
(
value
)
}
LogEx
.
logDebug
(
"LimitUtils"
,
"adsType=$adsType isDisplayLimited=$isDisplayLimited isClickLimited=$isClickLimited isRequestLimited=$isRequestLimited"
)
return
!(
isDisplayLimited
||
isClickLimited
||
isRequestLimited
)
}
...
...
@@ -152,7 +136,11 @@ object LimitUtils {
*
* @param lastTime 上一次显示的时间
*/
fun
isIntervalLimited
(
lastTime
:
Long
)
=
((
System
.
currentTimeMillis
()
-
lastTime
)
/
1000
/
60
).
toInt
()
<
(
AdsMgr
.
adsConfigBean
?.
timeInterval
?:
1
)
fun
isIntervalLimited
(
lastTime
:
Long
,
adEvent
:
AdEvent
):
Boolean
{
val
flag
=
((
System
.
currentTimeMillis
()
-
lastTime
)
/
1000
).
toInt
()
<
(
AdsMgr
.
adsConfigBean
.
timeInterval
)
if
(
flag
)
{
adEvent
.
adShowError
(
"ad in timeInterval"
)
}
return
flag
}
}
\ No newline at end of file
app/src/main/java/com/base/locationsharewhite/ads/admob/AdBannerMgr.kt
View file @
cfd8ca08
...
...
@@ -3,13 +3,16 @@ package com.base.locationsharewhite.ads.admob
import
android.os.Bundle
import
android.view.ViewGroup
import
android.view.ViewTreeObserver
import
com.base.locationsharewhite.ads.AdsMgr
import
com.base.locationsharewhite.ads.AdsType
import
com.base.locationsharewhite.ads.ConstConfig
import
com.base.locationsharewhite.ads.LimitUtils
import
com.google.ads.mediation.admob.AdMobAdapter
import
com.google.android.gms.ads.AdListener
import
com.google.android.gms.ads.AdRequest
import
com.google.android.gms.ads.AdSize
import
com.google.android.gms.ads.AdView
import
com.google.android.gms.ads.LoadAdError
import
java.util.UUID
/**
...
...
@@ -22,7 +25,12 @@ class AdBannerMgr {
fun
show
(
parent
:
ViewGroup
,
adClose
:
(()
->
Unit
)?
=
null
)
{
if
(!
LimitUtils
.
isAdShow
(
AdsType
.
BANNER
))
{
if
(!
AdsMgr
.
adsConfigBean
.
adSwitch
)
{
return
}
val
admobEvent
=
AdmobEvent
(
"banner"
,
"banner"
)
if
(!
LimitUtils
.
isAdShow
(
AdsType
.
BANNER
,
admobEvent
))
{
adView
=
null
return
}
...
...
@@ -43,14 +51,14 @@ class AdBannerMgr {
AdSize
.
getCurrentOrientationAnchoredAdaptiveBannerAdSize
(
parent
.
context
,
adWidth
)
adView
?.
adUnitId
=
ConstConfig
.
ADMOB_BANNER_UNIT_ID
adView
?.
setAdSize
(
adSize
)
loadAd
(
adClose
)
loadAd
(
ad
mobEvent
,
ad
Close
)
parent
.
viewTreeObserver
.
removeOnGlobalLayoutListener
(
listener
)
}
parent
.
viewTreeObserver
.
addOnGlobalLayoutListener
(
listener
)
}
fun
loadAd
(
adClose
:
(()
->
Unit
)?)
{
fun
loadAd
(
ad
mobEvent
:
AdmobEvent
,
ad
Close
:
(()
->
Unit
)?)
{
val
extras
=
Bundle
()
extras
.
putString
(
"collapsible"
,
"bottom"
)
extras
.
putString
(
"collapsible_request_id"
,
UUID
.
randomUUID
().
toString
())
...
...
@@ -58,8 +66,13 @@ class AdBannerMgr {
AdRequest
.
Builder
().
addNetworkExtrasBundle
(
AdMobAdapter
::
class
.
java
,
extras
).
build
()
adView
?.
adListener
=
object
:
AdListener
()
{
override
fun
onAdLoaded
()
{
override
fun
onAdFailedToLoad
(
loadAdError
:
LoadAdError
)
{
super
.
onAdFailedToLoad
(
loadAdError
)
admobEvent
.
pullAd
(
loadAdError
.
responseInfo
,
loadAdError
)
}
override
fun
onAdLoaded
()
{
admobEvent
.
pullAd
(
adView
?.
responseInfo
)
}
override
fun
onAdOpened
()
{
...
...
app/src/main/java/com/base/locationsharewhite/ads/admob/AdInsertMgr.kt
View file @
cfd8ca08
...
...
@@ -3,188 +3,155 @@ package com.base.locationsharewhite.ads.admob
import
android.app.Activity
import
android.content.Context
import
com.base.locationsharewhite.ads.AdDialog.showAdPreparingDialog
import
com.base.locationsharewhite.ads.AdEvent
import
com.base.locationsharewhite.ads.AdsShowCallBack
import
com.base.locationsharewhite.ads.AdsType
import
com.base.locationsharewhite.ads.BaseAdMgr
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.ads.
LimitUtils
import
com.base.locationsharewhite.
ads.adState
import
com.google.android.gms.ads.AdError
import
com.google.android.gms.ads.AdRequest
import
com.google.android.gms.ads.FullScreenContentCallback
import
com.google.android.gms.ads.LoadAdError
import
com.google.android.gms.ads.interstitial.InterstitialAd
import
com.google.android.gms.ads.interstitial.InterstitialAdLoadCallback
import
org.json.JSONObject
import
java.lang.ref.WeakReference
import
java.util.UUID
/**
*插屏广告加载显示管理类
*/
class
AdInsertMgr
:
BaseAdMgr
<
InterstitialAd
>()
{
private
var
lastOpenDate
:
Long
=
0
override
fun
loadAd
(
context
:
Context
,
isUnLimit
:
Boolean
)
{
if
((!
loadingAd
&&
LimitUtils
.
isAdShow
(
AdsType
.
INSERT
))
||
isUnLimit
)
{
loadingAd
=
true
//计数
LimitUtils
.
addRequestNum
()
val
reqId
=
UUID
.
randomUUID
().
toString
()
val
obj
=
JSONObject
()
obj
.
put
(
"req_id"
,
reqId
)
obj
.
put
(
"ad_type"
,
"interAd"
)
obj
.
put
(
"from"
,
context
.
javaClass
.
simpleName
)
EventUtils
.
event
(
"ad_pull_start"
,
ext
=
obj
)
InterstitialAd
.
load
(
context
,
ADMOB_INSERT_UNIT_ID
,
AdRequest
.
Builder
().
build
(),
object
:
InterstitialAdLoadCallback
()
{
override
fun
onAdLoaded
(
ad
:
InterstitialAd
)
{
super
.
onAdLoaded
(
ad
)
AdmobEvent
.
pullAd
(
ad
.
responseInfo
,
"interAd"
,
reqId
=
reqId
)
ad
.
onPaidEventListener
=
AdmobEvent
.
EventOnPaidEventListener
(
ad
)
// 开屏广告加载成功
currentAd
=
ad
loadingAd
=
false
lastTime
=
System
.
currentTimeMillis
()
val
ac
=
activityRef
?.
get
()
if
(
ac
!=
null
)
{
show
(
ac
,
isUnLimit
=
isUnLimit
)
}
}
class
AdInsertMgr
{
override
fun
onAdFailedToLoad
(
loadAdError
:
LoadAdError
)
{
super
.
onAdFailedToLoad
(
loadAdError
)
AdmobEvent
.
pullAd
(
loadAdError
.
responseInfo
,
"interAd"
,
loadAdError
.
message
,
reqId
=
reqId
)
// 广告加载失败
// 官方不建议在此回调中重新加载广告
// 如果确实需要,则必须限制最大重试次数,避免在网络受限的情况下连续多次请求
loadingAd
=
false
if
(
activityRef
!=
null
&&
!
showingAd
&&
showCallBack
!=
null
)
{
showCallBack
?.
googleFailed
()
showCallBack
=
null
}
}
}
)
}
}
private
var
adState
=
adState
<
InterstitialAd
>()
private
var
showCallBack
:
AdsShowCallBack
?
=
null
fun
show
(
activity
:
Activity
,
isUnLimit
:
Boolean
,
adEvent
:
AdEvent
,
showCallBack
:
AdsShowCallBack
?)
{
override
fun
show
(
activity
:
Activity
,
isUnLimit
:
Boolean
,
showCallBack
:
AdsShowCallBack
?)
{
if
(
activity
.
isFinishing
||
activity
.
isDestroyed
)
{
showCallBack
?.
failed
()
return
}
if
(
adState
.
showingAd
)
{
showCallBack
?.
failed
()
return
}
adPrepareShow
(
"interAd"
)
if
(!
isUnLimit
)
{
if
(!
LimitUtils
.
isAdShow
(
AdsType
.
INSERT
))
{
showCallBack
?.
failed
()
return
if
(
showCallBack
!=
null
)
{
this
.
showCallBack
=
showCallBack
adState
.
activityRef
=
WeakReference
(
activity
)
if
(
adState
.
adDialog
==
null
)
{
adState
.
adDialog
=
activity
.
showAdPreparingDialog
(
1
)
}
if
(
LimitUtils
.
isIntervalLimited
(
lastOpenDate
))
{
showCallBack
?.
failed
()
return
}
}
if
(
showingAd
)
{
// 开屏广告正在展示
return
adEvent
.
adPrepareShow
()
}
if
(
showCallBack
!=
null
&&
this
.
showCallBack
!=
showCallBack
)
this
.
showCallBack
=
showCallBack
if
((
currentAd
==
null
).
also
{
if
(
it
)
{
val
obj
=
JSONObject
()
obj
.
put
(
"reason"
,
"no_ad"
)
obj
.
put
(
"ad_unit"
,
"interAd"
)
EventUtils
.
event
(
"ad_show_error"
,
ext
=
obj
)
if
(!
adState
.
loadingAd
)
{
if
(!
isUnLimit
)
{
if
(!
LimitUtils
.
isAdShow
(
AdsType
.
INSERT
,
adEvent
))
{
showCallBack
?.
failed
()
return
}
}
||
(!
adAvailable
()).
also
{
if
(
it
)
{
val
obj2
=
JSONObject
()
obj2
.
put
(
"ad_unit"
,
"interAd"
)
EventUtils
.
event
(
"ad_expire"
,
ext
=
obj2
)
if
(
LimitUtils
.
isIntervalLimited
(
adState
.
lastShowTime
,
adEvent
))
{
showCallBack
?.
failed
()
return
}
})
{
//缓存广告过期
currentAd
=
null
if
(
activityRef
==
null
)
{
activityRef
=
WeakReference
(
activity
)
// 开屏广告不可用或者缓存超时过期,重新加载
loadAd
(
activity
.
applicationContext
)
}
else
{
activityRef
=
null
this
.
showCallBack
?.
failed
()
this
.
showCallBack
=
null
val
obj
=
JSONObject
()
obj
.
put
(
"reason"
,
"no_ad"
)
obj
.
put
(
"ad_unit"
,
"interAd"
)
EventUtils
.
event
(
"ad_show_error"
,
ext
=
obj
)
}
return
if
(
adState
.
currentAd
==
null
)
{
loadAd
(
activity
,
isUnLimit
,
adEvent
)
return
}
if
(!
adAvailable
())
{
loadAd
(
activity
,
isUnLimit
,
adEvent
)
return
}
showReadyAd
(
adEvent
,
activity
)
}
val
dialog
=
activity
.
showAdPreparingDialog
()
currentAd
?.
run
{
}
private
fun
showReadyAd
(
adEvent
:
AdEvent
,
activity
:
Activity
)
{
adState
.
currentAd
?.
run
{
fullScreenContentCallback
=
object
:
FullScreenContentCallback
()
{
override
fun
onAdShowedFullScreenContent
()
{
super
.
onAdShowedFullScreenContent
()
dialog
.
cancel
()
lastOpenDate
=
System
.
currentTimeMillis
()
// 广告展示
currentAd
=
null
activityRef
=
null
adState
.
onAdDisplayed
()
this
@AdInsertMgr
.
showCallBack
?.
show
()
AdmobEvent
.
showAd
(
this
@run
.
responseInfo
,
"interAd"
,
activity
)
//计数
(
adEvent
as
AdmobEvent
).
showAd
(
responseInfo
,
activity
)
LimitUtils
.
addDisplayNum
()
}
override
fun
onAdFailedToShowFullScreenContent
(
adError
:
AdError
)
{
super
.
onAdFailedToShowFullScreenContent
(
adError
)
dialog
.
cancel
()
// 广告展示失败,清空缓存数据,重新加载
showingAd
=
false
currentAd
=
null
activityRef
=
null
this
@AdInsertMgr
.
showCallBack
?.
googleFailed
()
this
@AdInsertMgr
.
showCallBack
=
null
val
obj
=
JSONObject
()
obj
.
put
(
"reason"
,
adError
.
message
)
obj
.
put
(
"code"
,
adError
.
code
)
obj
.
put
(
"ad_unit"
,
"interAd"
)
EventUtils
.
event
(
"ad_show_error"
,
ext
=
obj
)
adState
.
onAdDisplayFailed
()
showCallBack
?.
googleFailed
()
showCallBack
=
null
adEvent
.
adShowError
(
adError
)
}
override
fun
onAdDismissedFullScreenContent
()
{
super
.
onAdDismissedFullScreenContent
()
// 广告关闭,清空缓存数据,重新加载
showingAd
=
false
this
@AdInsertMgr
.
showCallBack
?.
close
()
this
@AdInsertMgr
.
showCallBack
=
null
loadAd
(
activity
.
applicationContext
)
adState
.
onAdHidden
()
showCallBack
?.
close
()
showCallBack
=
null
loadAd
(
activity
.
applicationContext
,
false
,
AdmobEvent
(
"interAd"
,
"preload"
))
}
override
fun
onAdClicked
()
{
super
.
onAdClicked
()
AdmobEvent
.
clickAd
(
this
@run
.
responseInfo
,
"interAd"
)
(
adEvent
as
AdmobEvent
).
clickAd
(
responseInfo
)
//计数
LimitUtils
.
addClickNum
()
}
}
showingAd
=
true
show
(
activity
)
}
}
override
fun
adAvailable
()
=
((
System
.
currentTimeMillis
()
-
lastTime
)
/
1000
/
60
).
toInt
()
<
30
fun
loadAd
(
context
:
Context
,
isUnLimit
:
Boolean
,
adEvent
:
AdEvent
)
{
if
(!
isUnLimit
)
{
if
(!
LimitUtils
.
isAdShow
(
AdsType
.
INSERT
,
adEvent
))
{
this
.
showCallBack
?.
close
()
this
.
showCallBack
=
null
return
}
}
if
(!
adState
.
loadingAd
)
{
adState
.
loadingAd
=
true
adEvent
.
adPulStart
()
InterstitialAd
.
load
(
context
,
ADMOB_INSERT_UNIT_ID
,
AdRequest
.
Builder
().
build
(),
object
:
InterstitialAdLoadCallback
()
{
override
fun
onAdLoaded
(
ad
:
InterstitialAd
)
{
adState
.
onAdLoaded
(
ad
)
val
ac
=
adState
.
activityRef
?.
get
()
if
(
ac
!=
null
)
{
show
(
ac
,
isUnLimit
,
adEvent
,
null
)
}
(
adEvent
as
AdmobEvent
).
pullAd
(
ad
.
responseInfo
)
LimitUtils
.
addRequestNum
()
ad
.
onPaidEventListener
=
AdmobEvent
.
EventOnPaidEventListener
(
ad
)
}
override
fun
onAdFailedToLoad
(
loadAdError
:
LoadAdError
)
{
adState
.
onAdLoadFailed
()
(
adEvent
as
AdmobEvent
).
pullAd
(
loadAdError
.
responseInfo
,
loadAdError
)
showCallBack
?.
googleFailed
()
showCallBack
=
null
}
}
)
}
}
private
fun
adAvailable
()
=
((
System
.
currentTimeMillis
()
-
adState
.
lastLoadTime
)
/
1000
/
60
).
toInt
()
<
30
}
\ No newline at end of file
app/src/main/java/com/base/locationsharewhite/ads/admob/AdNativeMgr.kt
View file @
cfd8ca08
package
com.base.locationsharewhite.ads.admob
import
android.content.Context
import
android.view.ViewGroup
import
androidx.core.view.isVisible
import
com.base.locationsharewhite.ads.NativeParentView
import
com.base.locationsharewhite.ads.AdsType
import
com.base.locationsharewhite.ads.ConstConfig
import
com.base.locationsharewhite.helper.EventUtils
import
com.base.locationsharewhite.utils.LogEx
import
com.base.locationsharewhite.ads.LimitUtils
import
com.google.android.gms.ads.AdListener
import
com.google.android.gms.ads.AdLoader
import
com.google.android.gms.ads.AdRequest
import
com.google.android.gms.ads.LoadAdError
import
com.google.android.gms.ads.nativead.NativeAd
import
com.google.android.gms.ads.nativead.NativeAdOptions
import
org.json.JSONObject
import
java.util.UUID
import
java.util.concurrent.ConcurrentLinkedDeque
/**
...
...
@@ -33,35 +27,37 @@ class AdNativeMgr {
*/
private
val
cacheItems
=
ConcurrentLinkedDeque
<
NativeAd
>()
fun
loadAd
(
context
:
Contex
t
,
parent
:
NativeParentView
?
=
null
,
layout
:
Int
?
=
null
private
fun
loadAd
(
admobEvent
:
AdmobEven
t
,
parent
:
NativeParentView
,
layout
:
Int
)
{
if
(!
LimitUtils
.
isAdShow
(
AdsType
.
NATIVE
))
return
admobEvent
.
adPulStart
()
if
(!
LimitUtils
.
isAdShow
(
AdsType
.
NATIVE
,
admobEvent
))
return
val
reqId
=
UUID
.
randomUUID
().
toString
()
val
obj
=
JSONObject
()
obj
.
put
(
"req_id"
,
reqId
)
obj
.
put
(
"ad_type"
,
"nativeAd"
)
var
currentNativeAd
:
NativeAd
?
=
null
val
adLoader
=
AdLoader
.
Builder
(
context
,
parent
.
context
,
ConstConfig
.
ADMOB_NATIVE_UNIT_ID
).
forNativeAd
{
nativeAd
->
currentNativeAd
=
nativeAd
cacheItems
.
offer
(
nativeAd
)
lastTime
=
System
.
currentTimeMillis
()
nativeAd
.
setOnPaidEventListener
(
AdmobEvent
.
EventOnPaidEventListener
(
nativeAd
))
AdmobEvent
.
pullAd
(
nativeAd
.
responseInfo
,
"nativeAd"
,
reqId
=
reqId
)
if
(
parent
!=
null
&&
layout
!=
null
)
show
(
parent
,
layout
)
admobEvent
.
pullAd
(
nativeAd
.
responseInfo
)
show
(
admobEvent
,
parent
,
layout
)
}.
withAdListener
(
object
:
AdListener
()
{
override
fun
onAdFailedToLoad
(
error
:
LoadAdError
)
{
AdmobEvent
.
pullAd
(
error
.
responseInfo
,
"nativeAd"
,
error
.
message
,
reqId
=
reqId
)
admobEvent
.
pullAd
(
error
.
responseInfo
,
error
)
}
override
fun
onAdClicked
()
{
super
.
onAdClicked
()
AdmobEvent
.
clickAd
(
cacheItems
.
lastOrNull
()
?.
responseInfo
,
"nativeAd"
)
admobEvent
.
clickAd
(
currentNativeAd
?.
responseInfo
)
}
override
fun
onAdClosed
()
{
...
...
@@ -75,45 +71,30 @@ class AdNativeMgr {
}
fun
show
(
admobEvent
:
AdmobEvent
,
parent
:
NativeParentView
,
layout
:
Int
,
nativeCallBack
:
((
Any
?)
->
Unit
)?
=
null
)
{
if
(!
LimitUtils
.
isAdShow
(
AdsType
.
NATIVE
))
{
admobEvent
.
adPrepareShow
()
if
(!
LimitUtils
.
isAdShow
(
AdsType
.
NATIVE
,
admobEvent
))
{
cacheItems
.
clear
()
LogEx
.
logDebug
(
"AdNativeMgr"
,
"0"
)
return
}
val
nativeAd
=
cacheItems
.
peek
()
if
((
nativeAd
==
null
).
also
{
if
(
it
)
{
LogEx
.
logDebug
(
"AdNativeMgr"
,
"1"
)
val
obj2
=
JSONObject
()
obj2
.
put
(
"reason"
,
"no_ad"
)
obj2
.
put
(
"ad_unit"
,
"nativeAd"
)
EventUtils
.
event
(
"ad_show_error"
,
ext
=
obj2
)
}
}
||
(!
adAvailable
()).
also
{
if
(
it
)
{
LogEx
.
logDebug
(
"AdNativeMgr"
,
"2"
)
val
obj2
=
JSONObject
()
obj2
.
put
(
"ad_unit"
,
"nativeAd"
)
EventUtils
.
event
(
"ad_expire"
,
ext
=
obj2
)
}
})
{
if
(
nativeAd
==
null
||
!
adAvailable
())
{
//缓存过期了就清空
cacheItems
.
clear
()
LogEx
.
logDebug
(
"AdNativeMgr"
,
"loadAd"
)
loadAd
(
parent
.
context
.
applicationContext
,
parent
,
layout
)
loadAd
(
admobEvent
,
parent
,
layout
)
return
}
nativeCallBack
?.
invoke
(
nativeAd
)
LogEx
.
logDebug
(
"AdNativeMgr"
,
"3"
)
val
obj
=
JSONObject
()
obj
.
put
(
"ad_unit"
,
"nativeAd"
)
EventUtils
.
event
(
"ad_prepare_show_native"
,
ext
=
obj
)
parent
.
setNativeAd
(
nativeAd
!!
,
layout
)
AdmobEvent
.
showAd
(
nativeAd
.
responseInfo
,
"nativeAd"
)
parent
.
setNativeAd
(
nativeAd
,
layout
)
admobEvent
.
showAd
(
nativeAd
.
responseInfo
)
}
private
fun
adAvailable
():
Boolean
{
...
...
app/src/main/java/com/base/locationsharewhite/ads/admob/AdOpenMgr.kt
View file @
cfd8ca08
...
...
@@ -2,184 +2,149 @@ package com.base.locationsharewhite.ads.admob
import
android.app.Activity
import
android.content.Context
import
com.base.locationsharewhite.ads.AdEvent
import
com.base.locationsharewhite.ads.AdsShowCallBack
import
com.base.locationsharewhite.ads.AdsType
import
com.base.locationsharewhite.ads.BaseAdMgr
import
com.base.locationsharewhite.ads.ConstConfig
import
com.base.locationsharewhite.ads.
admob.AdmobEvent.adPrepareShow
import
com.base.locationsharewhite.
helper.EventUtils
import
com.base.locationsharewhite.ads.
LimitUtils
import
com.base.locationsharewhite.
ads.adState
import
com.google.android.gms.ads.AdError
import
com.google.android.gms.ads.AdRequest
import
com.google.android.gms.ads.FullScreenContentCallback
import
com.google.android.gms.ads.LoadAdError
import
com.google.android.gms.ads.appopen.AppOpenAd
import
org.json.JSONObject
import
java.lang.ref.WeakReference
import
java.util.UUID
/**
* 开屏广告加载显示管理类
*/
class
AdOpenMgr
:
BaseAdMgr
<
AppOpenAd
>()
{
private
var
lastOpenDate
:
Long
=
0
override
fun
loadAd
(
context
:
Context
,
isUnLimit
:
Boolean
)
{
if
(!
loadingAd
&&
LimitUtils
.
isAdShow
(
AdsType
.
OPEN
))
{
loadingAd
=
true
//计数
LimitUtils
.
addRequestNum
()
val
reqId
=
UUID
.
randomUUID
().
toString
()
val
obj
=
JSONObject
()
obj
.
put
(
"req_id"
,
reqId
)
obj
.
put
(
"ad_type"
,
"openAd"
)
EventUtils
.
event
(
"ad_pull_start"
,
ext
=
obj
)
AppOpenAd
.
load
(
context
,
ConstConfig
.
ADMOB_OPEN_UNIT_ID
,
AdRequest
.
Builder
().
build
(),
object
:
AppOpenAd
.
AppOpenAdLoadCallback
()
{
override
fun
onAdLoaded
(
appOpenAd
:
AppOpenAd
)
{
super
.
onAdLoaded
(
appOpenAd
)
// 开屏广告加载成功
currentAd
=
appOpenAd
loadingAd
=
false
lastTime
=
System
.
currentTimeMillis
()
val
ac
=
activityRef
?.
get
()
if
(
ac
!=
null
)
{
show
(
ac
)
}
AdmobEvent
.
pullAd
(
appOpenAd
.
responseInfo
,
"openAd"
,
reqId
=
reqId
)
appOpenAd
.
onPaidEventListener
=
AdmobEvent
.
EventOnPaidEventListener
(
appOpenAd
)
}
class
AdOpenMgr
{
override
fun
onAdFailedToLoad
(
loadAdError
:
LoadAdError
)
{
super
.
onAdFailedToLoad
(
loadAdError
)
// 开屏广告加载失败
// 官方不建议在此回调中重新加载广告
// 如果确实需要,则必须限制最大重试次数,避免在网络受限的情况下连续多次请求
loadingAd
=
false
if
(
activityRef
!=
null
&&
!
showingAd
&&
showCallBack
!=
null
)
{
showCallBack
?.
googleFailed
()
showCallBack
=
null
}
AdmobEvent
.
pullAd
(
loadAdError
.
responseInfo
,
"openAd"
,
loadAdError
.
message
,
reqId
=
reqId
)
}
}
)
}
}
private
val
adState
=
adState
<
AppOpenAd
>()
private
var
showCallBack
:
AdsShowCallBack
?
=
null
override
fun
show
(
activity
:
Activity
,
isUnLimit
:
Boolean
,
showCallBack
:
AdsShowCallBack
?)
{
fun
show
(
activity
:
Activity
,
isUnLimit
:
Boolean
,
adEvent
:
AdEvent
,
showCallBack
:
AdsShowCallBack
?)
{
if
(
activity
.
isFinishing
||
activity
.
isDestroyed
)
{
showCallBack
?.
failed
()
return
}
adPrepareShow
(
"openAd"
)
if
(!
LimitUtils
.
isAdShow
(
AdsType
.
OPEN
))
{
if
(
adState
.
showingAd
)
{
showCallBack
?.
failed
()
adEvent
.
adShowError
(
"showingAd"
)
return
}
if
(
LimitUtils
.
isIntervalLimited
(
lastOpenDate
))
{
showCallBack
?.
failed
()
return
if
(
showCallBack
!=
null
)
{
this
.
showCallBack
=
showCallBack
adState
.
activityRef
=
WeakReference
(
activity
)
adEvent
.
adPrepareShow
()
}
if
(
showingAd
)
{
// 开屏广告正在展示
return
}
if
(
showCallBack
!=
null
&&
this
.
showCallBack
!=
showCallBack
)
this
.
showCallBack
=
showCallBack
if
((
currentAd
==
null
).
also
{
if
(
it
)
{
val
obj
=
JSONObject
()
obj
.
put
(
"reason"
,
"no_ad"
)
obj
.
put
(
"ad_unit"
,
"openAd"
)
EventUtils
.
event
(
"ad_show_error"
,
ext
=
obj
)
if
(!
adState
.
loadingAd
)
{
if
(!
isUnLimit
)
{
if
(!
LimitUtils
.
isAdShow
(
AdsType
.
OPEN
,
adEvent
))
{
showCallBack
?.
failed
()
return
}
}
||
(!
adAvailable
()).
also
{
if
(
it
)
{
val
obj2
=
JSONObject
()
obj2
.
put
(
"ad_unit"
,
"openAd"
)
EventUtils
.
event
(
"ad_expire"
,
ext
=
obj2
)
if
(
LimitUtils
.
isIntervalLimited
(
adState
.
lastShowTime
,
adEvent
))
{
showCallBack
?.
failed
()
return
}
})
{
//缓存广告过期
currentAd
=
null
if
(
activityRef
==
null
)
{
activityRef
=
WeakReference
(
activity
)
// 开屏广告不可用或者缓存超时过期,重新加载
loadAd
(
activity
.
applicationContext
)
}
else
{
activityRef
=
null
this
.
showCallBack
?.
failed
()
this
.
showCallBack
=
null
val
obj
=
JSONObject
()
obj
.
put
(
"reason"
,
"no_ad"
)
obj
.
put
(
"ad_unit"
,
"openAd"
)
EventUtils
.
event
(
"ad_show_error"
,
ext
=
obj
)
}
return
if
(!
adAvailable
()
||
adState
.
currentAd
==
null
)
{
loadAd
(
activity
,
isUnLimit
,
adEvent
)
return
}
showReadyAd
(
adEvent
,
activity
)
}
currentAd
?.
run
{
}
private
fun
showReadyAd
(
adEvent
:
AdEvent
,
activity
:
Activity
)
{
adState
.
currentAd
?.
run
{
fullScreenContentCallback
=
object
:
FullScreenContentCallback
()
{
override
fun
onAdShowedFullScreenContent
()
{
super
.
onAdShowedFullScreenContent
()
lastOpenDate
=
System
.
currentTimeMillis
()
// 广告展示
currentAd
=
null
activityRef
=
null
this
@AdOpenMgr
.
showCallBack
?.
show
()
showCallBack
?.
show
()
(
adEvent
as
AdmobEvent
).
showAd
(
this
@run
.
responseInfo
,
activity
)
adState
.
onAdDisplayed
()
//计数
LimitUtils
.
addDisplayNum
()
AdmobEvent
.
showAd
(
this
@run
.
responseInfo
,
"openAd"
,
activity
)
}
override
fun
onAdFailedToShowFullScreenContent
(
adError
:
AdError
)
{
super
.
onAdFailedToShowFullScreenContent
(
adError
)
// 广告展示失败,清空缓存数据,重新加载
showingAd
=
false
currentAd
=
null
activityRef
=
null
this
@AdOpenMgr
.
showCallBack
?.
googleFailed
()
this
@AdOpenMgr
.
showCallBack
=
null
val
obj
=
JSONObject
()
obj
.
put
(
"reason"
,
adError
.
message
)
obj
.
put
(
"code"
,
adError
.
code
)
obj
.
put
(
"ad_unit"
,
"openAd"
)
EventUtils
.
event
(
"ad_show_error"
,
ext
=
obj
)
showCallBack
?.
googleFailed
()
showCallBack
=
null
adState
.
onAdDisplayed
()
(
adEvent
as
AdmobEvent
).
adShowError
(
adError
)
}
override
fun
onAdDismissedFullScreenContent
()
{
super
.
onAdDismissedFullScreenContent
()
// 广告关闭,清空缓存数据,重新加载
showingAd
=
false
this
@AdOpenMgr
.
showCallBack
?.
close
()
this
@AdOpenMgr
.
showCallBack
=
null
loadAd
(
activity
.
applicationContext
)
showCallBack
?.
close
()
showCallBack
=
null
adState
.
onAdHidden
()
loadAd
(
activity
.
applicationContext
,
false
,
AdmobEvent
(
"openAd"
,
"preload"
))
}
override
fun
onAdClicked
()
{
super
.
onAdClicked
()
AdmobEvent
.
clickAd
(
this
@run
.
responseInfo
,
"openAd"
)
(
adEvent
as
AdmobEvent
).
clickAd
(
this
@run
.
responseInfo
)
//计数
LimitUtils
.
addClickNum
()
}
}
showingAd
=
true
show
(
activity
)
}
}
override
fun
adAvailable
()
=
((
System
.
currentTimeMillis
()
-
lastTime
)
/
1000
/
60
).
toInt
()
<
30
fun
loadAd
(
context
:
Context
,
isUnLimit
:
Boolean
,
adEvent
:
AdEvent
)
{
if
(!
isUnLimit
)
{
if
(!
LimitUtils
.
isAdShow
(
AdsType
.
OPEN
,
adEvent
))
{
this
.
showCallBack
?.
close
()
this
.
showCallBack
=
null
return
}
}
if
(!
adState
.
loadingAd
)
{
adState
.
loadingAd
=
true
adEvent
.
adPulStart
()
AppOpenAd
.
load
(
context
,
ConstConfig
.
ADMOB_OPEN_UNIT_ID
,
AdRequest
.
Builder
().
build
(),
object
:
AppOpenAd
.
AppOpenAdLoadCallback
()
{
override
fun
onAdLoaded
(
appOpenAd
:
AppOpenAd
)
{
adState
.
onAdLoaded
(
appOpenAd
)
val
ac
=
adState
.
activityRef
?.
get
()
if
(
ac
!=
null
)
{
show
(
ac
,
isUnLimit
,
adEvent
,
null
)
}
(
adEvent
as
AdmobEvent
).
pullAd
(
appOpenAd
.
responseInfo
)
appOpenAd
.
onPaidEventListener
=
AdmobEvent
.
EventOnPaidEventListener
(
appOpenAd
)
LimitUtils
.
addRequestNum
()
}
override
fun
onAdFailedToLoad
(
loadAdError
:
LoadAdError
)
{
showCallBack
?.
googleFailed
()
showCallBack
=
null
adState
.
onAdLoadFailed
()
(
adEvent
as
AdmobEvent
).
pullAd
(
loadAdError
.
responseInfo
,
loadAdError
)
}
}
)
}
}
private
fun
adAvailable
()
=
((
System
.
currentTimeMillis
()
-
adState
.
lastLoadTime
)
/
1000
/
60
).
toInt
()
<
30
}
\ No newline at end of file
app/src/main/java/com/base/locationsharewhite/ads/admob/AdmobEvent.kt
View file @
cfd8ca08
...
...
@@ -2,13 +2,16 @@ package com.base.locationsharewhite.ads.admob
import
android.app.Activity
import
android.os.Bundle
import
com.base.locationsharewhite.ads.AdEvent
import
com.base.locationsharewhite.helper.EventUtils
import
com.base.locationsharewhite.helper.MyApplication
import
com.base.locationsharewhite.utils.LogEx
import
com.facebook.appevents.AppEventsConstants
import
com.facebook.appevents.AppEventsLogger
import
com.google.android.gms.ads.AdError
import
com.google.android.gms.ads.AdValue
import
com.google.android.gms.ads.AdView
import
com.google.android.gms.ads.LoadAdError
import
com.google.android.gms.ads.OnPaidEventListener
import
com.google.android.gms.ads.ResponseInfo
import
com.google.android.gms.ads.appopen.AppOpenAd
...
...
@@ -20,23 +23,31 @@ import com.google.firebase.analytics.ktx.analytics
import
com.google.firebase.ktx.Firebase
import
org.json.JSONObject
object
AdmobEvent
{
private
val
TAG
=
"AdmobEvent"
private
val
taichiPref
by
lazy
{
MyApplication
.
appContext
.
getSharedPreferences
(
"TaichiTroasCache"
,
0
)
}
fun
adPrepareShow
(
adUnit
:
String
)
{
val
obj1
=
JSONObject
()
obj1
.
put
(
"ad_unit"
,
adUnit
)
EventUtils
.
event
(
"ad_prepare_show"
,
ext
=
obj1
)
private
val
taichiSharedPreferencesEditor
by
lazy
{
taichiPref
.
edit
()
}
class
AdmobEvent
:
AdEvent
{
override
val
TAG
:
String
=
"AdmobEvent"
constructor
(
adUnit
:
String
,
from
:
String
)
:
super
()
{
this
.
adUnit
=
adUnit
this
.
from
=
from
}
fun
pullAd
(
responseInfo
:
ResponseInfo
?,
adUnit
:
String
,
error
:
String
?
=
null
,
reqId
:
String
?
=
null
error
:
LoadAdError
?
=
null
,
)
{
val
obj
=
JSONObject
()
obj
.
put
(
"req_id"
,
reqId
)
if
(
responseInfo
!=
null
)
{
val
response
=
responseInfo
.
adapterResponses
.
getOrNull
(
0
)
if
(
response
!=
null
)
{
...
...
@@ -53,23 +64,63 @@ object AdmobEvent {
}
obj
.
put
(
"networkname"
,
responseInfo
?.
mediationAdapterClassName
)
obj
.
put
(
"ad_unit"
,
adUnit
)
obj
.
put
(
"
req_id"
,
reqId
)
obj
.
put
(
"
from"
,
from
)
if
(
error
==
null
)
{
obj
.
put
(
"status"
,
"1"
)
}
else
{
obj
.
put
(
"errMsg"
,
error
)
obj
.
put
(
"errMsg"
,
error
.
toString
()
)
obj
.
put
(
"status"
,
"2"
)
}
LogEx
.
logDebug
(
TAG
,
"obj=$obj"
)
EventUtils
.
event
(
"ad_pull"
,
ext
=
obj
)
LogEx
.
logDebug
(
TAG
,
"ad_pull obj=$obj"
)
}
private
val
taichiPref
by
lazy
{
MyApplication
.
appContext
.
getSharedPreferences
(
"TaichiTroasCache"
,
0
)
fun
clickAd
(
responseInfo
:
ResponseInfo
?)
{
val
response
=
responseInfo
?.
adapterResponses
?.
getOrNull
(
0
)
val
obj
=
JSONObject
()
obj
.
put
(
"req_id"
,
reqId
)
obj
.
put
(
"source"
,
response
?.
adSourceName
)
obj
.
put
(
"ad_unit"
,
adUnit
)
val
credentials
=
mapOf
(
"placementid"
to
response
?.
credentials
?.
get
(
"placementid"
),
"appid"
to
response
?.
credentials
?.
get
(
"appid"
),
"pubid"
to
response
?.
credentials
?.
get
(
"pubid"
)
)
obj
.
put
(
"credentials"
,
credentials
.
toString
())
obj
.
put
(
"session_id"
,
responseInfo
?.
responseId
)
obj
.
put
(
"from"
,
from
)
obj
.
put
(
"networkname"
,
responseInfo
?.
mediationAdapterClassName
)
if
(
adUnit
!=
"nativeAd"
)
{
EventUtils
.
event
(
"ad_click"
,
ext
=
obj
)
}
else
{
EventUtils
.
event
(
"ad_click"
,
ext
=
obj
)
}
}
private
val
taichiSharedPreferencesEditor
by
lazy
{
taichiPref
.
edit
()
fun
showAd
(
responseInfo
:
ResponseInfo
?,
activity
:
Activity
?
=
null
)
{
val
response
=
responseInfo
?.
adapterResponses
?.
getOrNull
(
0
)
val
obj
=
JSONObject
()
obj
.
put
(
"req_id"
,
reqId
)
obj
.
put
(
"source"
,
response
?.
adSourceName
)
obj
.
put
(
"ad_unit"
,
adUnit
)
obj
.
put
(
"networkname"
,
responseInfo
?.
mediationAdapterClassName
)
val
credentials
=
mapOf
(
"placementid"
to
response
?.
credentials
?.
get
(
"placementid"
),
"appid"
to
response
?.
credentials
?.
get
(
"appid"
),
"pubid"
to
response
?.
credentials
?.
get
(
"pubid"
)
)
obj
.
put
(
"credentials"
,
credentials
.
toString
())
obj
.
put
(
"session_id"
,
responseInfo
?.
responseId
)
obj
.
put
(
"from"
,
activity
?.
javaClass
?.
simpleName
)
if
(
adUnit
!=
"nativeAd"
)
{
EventUtils
.
event
(
"ad_show"
,
ext
=
obj
)
}
else
{
EventUtils
.
event
(
"ad_show"
,
ext
=
obj
)
}
LogEx
.
logDebug
(
TAG
,
"ad_show $obj"
)
}
class
EventOnPaidEventListener
(
private
val
ad
:
Any
?)
:
OnPaidEventListener
{
...
...
@@ -248,46 +299,16 @@ object AdmobEvent {
}
}
fun
clickAd
(
responseInfo
:
ResponseInfo
?,
adUnit
:
String
)
{
val
response
=
responseInfo
?.
adapterResponses
?.
getOrNull
(
0
)
fun
adShowError
(
adError
:
AdError
)
{
val
obj
=
JSONObject
()
obj
.
put
(
"source"
,
response
?.
adSourceName
)
obj
.
put
(
"ad_unit"
,
adUnit
)
val
credentials
=
mapOf
(
"placementid"
to
response
?.
credentials
?.
get
(
"placementid"
),
"appid"
to
response
?.
credentials
?.
get
(
"appid"
),
"pubid"
to
response
?.
credentials
?.
get
(
"pubid"
)
)
obj
.
put
(
"credentials"
,
credentials
.
toString
())
obj
.
put
(
"session_id"
,
responseInfo
?.
responseId
)
obj
.
put
(
"networkname"
,
responseInfo
?.
mediationAdapterClassName
)
if
(
adUnit
!=
"nativeAd"
)
{
EventUtils
.
event
(
"ad_click"
,
ext
=
obj
)
}
else
{
EventUtils
.
event
(
"bigimage_ad_click"
,
ext
=
obj
)
}
obj
.
put
(
"req_id"
,
reqId
)
obj
.
put
(
"reason"
,
adError
.
message
)
obj
.
put
(
"code"
,
adError
.
code
)
obj
.
put
(
"from"
,
from
)
obj
.
put
(
"ad_unit"
,
"openAd"
)
EventUtils
.
event
(
"ad_show_error"
,
ext
=
obj
)
LogEx
.
logDebug
(
TAG
,
"ad_show_error $obj"
)
}
}
fun
showAd
(
responseInfo
:
ResponseInfo
?,
adUnit
:
String
,
activity
:
Activity
?
=
null
)
{
val
response
=
responseInfo
?.
adapterResponses
?.
getOrNull
(
0
)
val
obj
=
JSONObject
()
obj
.
put
(
"source"
,
response
?.
adSourceName
)
obj
.
put
(
"ad_unit"
,
adUnit
)
obj
.
put
(
"networkname"
,
responseInfo
?.
mediationAdapterClassName
)
val
credentials
=
mapOf
(
"placementid"
to
response
?.
credentials
?.
get
(
"placementid"
),
"appid"
to
response
?.
credentials
?.
get
(
"appid"
),
"pubid"
to
response
?.
credentials
?.
get
(
"pubid"
)
)
obj
.
put
(
"credentials"
,
credentials
.
toString
())
obj
.
put
(
"session_id"
,
responseInfo
?.
responseId
)
obj
.
put
(
"from"
,
activity
?.
javaClass
?.
simpleName
)
if
(
adUnit
!=
"nativeAd"
)
{
EventUtils
.
event
(
"ad_show"
,
ext
=
obj
)
}
else
{
EventUtils
.
event
(
"ad_show"
,
ext
=
obj
)
}
}
}
\ No newline at end of file
app/src/main/java/com/base/locationsharewhite/ads/applovin/AdMaxEvent.kt
View file @
cfd8ca08
...
...
@@ -5,8 +5,10 @@ import com.applovin.mediation.MaxAd
import
com.applovin.mediation.MaxAdRevenueListener
import
com.applovin.mediation.MaxError
import
com.applovin.sdk.AppLovinSdk
import
com.base.locationsharewhite.ads.AdEvent
import
com.base.locationsharewhite.helper.EventUtils
import
com.base.locationsharewhite.helper.MyApplication
import
com.base.locationsharewhite.utils.LogEx
import
com.facebook.FacebookSdk
import
com.facebook.appevents.AppEventsConstants
import
com.facebook.appevents.AppEventsLogger
...
...
@@ -14,19 +16,22 @@ import com.google.firebase.analytics.FirebaseAnalytics
import
org.json.JSONObject
object
AdMaxEvent
{
private
val
taichiPref
=
FacebookSdk
.
getApplicationContext
()
.
getSharedPreferences
(
"TaichiTroasCache"
,
0
)
fun
adPrepareShow
(
adUnit
:
String
)
{
val
obj1
=
JSONObject
()
obj1
.
put
(
"ad_unit"
,
adUnit
)
EventUtils
.
event
(
"ad_prepare_show"
,
ext
=
obj1
)
}
private
val
taichiSharedPreferencesEditor
=
taichiPref
.
edit
()
class
AdMaxEvent
:
AdEvent
{
override
val
TAG
:
String
=
"AdMaxEvent"
constructor
(
adUnit
:
String
,
from
:
String
)
:
super
()
{
this
.
adUnit
=
adUnit
this
.
from
=
from
}
fun
pullAd
(
ad
:
MaxAd
?,
adUnit
:
String
,
reqId
:
String
?
=
null
,
error
:
MaxError
?
=
null
)
{
val
obj
=
JSONObject
()
...
...
@@ -37,6 +42,7 @@ object AdMaxEvent {
ad
?.
creativeId
)
obj
.
put
(
"req_id"
,
reqId
)
obj
.
put
(
"from"
,
from
)
obj
.
put
(
"status"
,
if
(
ad
==
null
)
"0"
else
"1"
)
obj
.
put
(
"networkname"
,
ad
?.
networkName
)
obj
.
put
(
"placement"
,
ad
?.
placement
)
...
...
@@ -50,9 +56,10 @@ object AdMaxEvent {
obj
.
put
(
"status"
,
"2"
)
}
EventUtils
.
event
(
"ad_pull"
,
ext
=
obj
)
LogEx
.
run
{
logDebug
(
TAG
,
"ad_pull $obj"
)
}
}
fun
clickAd
(
ad
:
MaxAd
?
,
adUnit
:
String
)
{
fun
clickAd
(
ad
:
MaxAd
?)
{
val
obj
=
JSONObject
()
obj
.
put
(
"UnitId"
,
ad
?.
adUnitId
)
...
...
@@ -74,7 +81,7 @@ object AdMaxEvent {
}
fun
showAd
(
ad
:
MaxAd
?,
a
dUnit
:
String
,
a
ctivity
:
String
?)
{
fun
showAd
(
ad
:
MaxAd
?,
activity
:
String
?)
{
val
obj
=
JSONObject
()
obj
.
put
(
"UnitId"
,
ad
?.
adUnitId
)
obj
.
put
(
"ad_unit"
,
adUnit
)
...
...
@@ -97,9 +104,6 @@ object AdMaxEvent {
}
private
val
taichiPref
=
FacebookSdk
.
getApplicationContext
()
.
getSharedPreferences
(
"TaichiTroasCache"
,
0
)
private
val
taichiSharedPreferencesEditor
=
taichiPref
.
edit
()
class
EventOnPaidEventListener
:
MaxAdRevenueListener
{
override
fun
onAdRevenuePaid
(
ad
:
MaxAd
)
{
...
...
@@ -152,6 +156,9 @@ object AdMaxEvent {
obj
.
put
(
"networkPlacement"
,
networkPlacement
)
EventUtils
.
event
(
"ad_price"
,
ext
=
obj
)
}
}
fun
adShowError
(
reason
:
String
)
{
}
}
\ No newline at end of file
app/src/main/java/com/base/locationsharewhite/ads/applovin/MaxInsertMgr.kt
View file @
cfd8ca08
...
...
@@ -7,188 +7,172 @@ import com.applovin.mediation.MaxAdListener
import
com.applovin.mediation.MaxError
import
com.applovin.mediation.ads.MaxInterstitialAd
import
com.base.locationsharewhite.ads.AdDialog.showAdPreparingDialog
import
com.base.locationsharewhite.ads.AdEvent
import
com.base.locationsharewhite.ads.AdsShowCallBack
import
com.base.locationsharewhite.ads.AdsType
import
com.base.locationsharewhite.ads.BaseAdMgr
import
com.base.locationsharewhite.ads.ConstConfig
import
com.base.locationsharewhite.ads.admob.LimitUtils
import
com.base.locationsharewhite.helper.EventUtils
import
org.json.JSONObject
import
com.base.locationsharewhite.ads.LimitUtils
import
com.base.locationsharewhite.ads.adState
import
java.lang.ref.WeakReference
import
java.util.UUID
/**
*插屏广告加载显示管理类
*/
class
MaxInsertMgr
:
BaseAdMgr
<
MaxInterstitialAd
>()
{
private
var
lastOpenDate
:
Long
=
0
override
fun
loadAd
(
context
:
Context
,
isUnLimit
:
Boolean
)
{
if
((!
loadingAd
&&
LimitUtils
.
isAdShow
(
AdsType
.
INSERT
))
||
isUnLimit
)
{
loadingAd
=
true
//计数
LimitUtils
.
addRequestNum
()
val
reqId
=
UUID
.
randomUUID
().
toString
()
val
obj
=
JSONObject
()
obj
.
put
(
"req_id"
,
reqId
)
obj
.
put
(
"ad_type"
,
"interAd"
)
obj
.
put
(
"from"
,
context
.
javaClass
.
simpleName
)
EventUtils
.
event
(
"ad_pull_start"
,
ext
=
obj
)
currentAd
=
MaxInterstitialAd
(
ConstConfig
.
MAX_INSERT_UNIT_ID
,
context
)
currentAd
?.
setListener
(
object
:
MaxAdListener
{
override
fun
onAdLoaded
(
ad
:
MaxAd
)
{
AdMaxEvent
.
pullAd
(
ad
,
"interAd"
,
reqId
=
reqId
)
// 开屏广告加载成功
loadingAd
=
false
lastTime
=
System
.
currentTimeMillis
()
val
ac
=
activityRef
?.
get
()
if
(
ac
!=
null
)
{
show
(
ac
,
isUnLimit
=
isUnLimit
)
}
}
override
fun
onAdDisplayed
(
p0
:
MaxAd
)
{
}
class
MaxInsertMgr
{
override
fun
onAdHidden
(
p0
:
MaxAd
)
{
}
override
fun
onAdClicked
(
p0
:
MaxAd
)
{
}
private
var
adState
=
adState
<
MaxInterstitialAd
>()
private
var
showCallBack
:
AdsShowCallBack
?
=
null
override
fun
onAdLoadFailed
(
ad
:
String
,
error
:
MaxError
)
{
AdMaxEvent
.
pullAd
(
null
,
"interAd"
,
reqId
,
error
)
// 广告加载失败
// 官方不建议在此回调中重新加载广告
loadingAd
=
false
if
(
activityRef
!=
null
&&
!
showingAd
&&
showCallBack
!=
null
)
{
showCallBack
?.
googleFailed
()
showCallBack
=
null
}
}
override
fun
onAdDisplayFailed
(
p0
:
MaxAd
,
p1
:
MaxError
)
{
}
})
currentAd
?.
loadAd
()
}
}
fun
show
(
activity
:
Activity
,
isUnLimit
:
Boolean
,
adEvent
:
AdEvent
,
showCallBack
:
AdsShowCallBack
?
)
{
override
fun
show
(
activity
:
Activity
,
isUnLimit
:
Boolean
,
showCallBack
:
AdsShowCallBack
?)
{
if
(
activity
.
isFinishing
||
activity
.
isDestroyed
)
{
showCallBack
?.
failed
()
showCallBack
?.
failed
(
1
)
return
}
if
(
adState
.
showingAd
)
{
showCallBack
?.
failed
(
2
)
return
}
AdMaxEvent
.
adPrepareShow
(
"interAd"
)
if
(!
isUnLimit
)
{
if
(!
LimitUtils
.
isAdShow
(
AdsType
.
INSERT
))
{
showCallBack
?.
failed
()
return
}
if
(
LimitUtils
.
isIntervalLimited
(
lastOpenDate
))
{
showCallBack
?.
failed
()
return
if
(
showCallBack
!=
null
)
{
adState
.
activityRef
=
WeakReference
(
activity
)
this
.
showCallBack
=
showCallBack
if
(
adState
.
adDialog
==
null
)
{
adState
.
adDialog
=
activity
.
showAdPreparingDialog
(
2
)
}
adEvent
.
adPrepareShow
()
}
if
(
showingAd
)
{
// 开屏广告正在展示
return
}
if
(
showCallBack
!=
null
&&
this
.
showCallBack
!=
showCallBack
)
this
.
showCallBack
=
showCallBack
if
((
currentAd
?.
isReady
!=
true
).
also
{
if
(
it
)
{
val
obj
=
JSONObject
()
obj
.
put
(
"reason"
,
"no_ad"
)
obj
.
put
(
"ad_unit"
,
"interAd"
)
EventUtils
.
event
(
"ad_show_error"
,
ext
=
obj
)
if
(!
adState
.
loadingAd
)
{
if
(!
isUnLimit
)
{
if
(!
LimitUtils
.
isAdShow
(
AdsType
.
INSERT
,
adEvent
))
{
showCallBack
?.
failed
(
3
)
return
}
}
||
(!
adAvailable
()).
also
{
if
(
it
)
{
val
obj2
=
JSONObject
()
obj2
.
put
(
"ad_unit"
,
"interAd"
)
EventUtils
.
event
(
"ad_expire"
,
ext
=
obj2
)
if
(
LimitUtils
.
isIntervalLimited
(
adState
.
lastShowTime
,
adEvent
))
{
showCallBack
?.
failed
(
4
)
return
}
})
{
//缓存广告过期
currentAd
=
null
if
(
activityRef
==
null
)
{
activityRef
=
WeakReference
(
activity
)
// 开屏广告不可用或者缓存超时过期,重新加载
loadAd
(
activity
,
isUnLimit
)
}
else
{
activityRef
=
null
this
.
showCallBack
?.
failed
()
this
.
showCallBack
=
null
val
obj
=
JSONObject
()
obj
.
put
(
"reason"
,
"no_ad"
)
obj
.
put
(
"ad_unit"
,
"interAd"
)
EventUtils
.
event
(
"ad_show_error"
,
ext
=
obj
)
}
return
if
(!
adAvailable
()
||
adState
.
currentAd
==
null
)
{
loadAd
(
activity
,
isUnLimit
,
adEvent
)
return
}
if
(
adState
.
currentAd
?.
isReady
==
false
)
{
loadAd
(
activity
,
isUnLimit
,
adEvent
)
return
}
showReadyAd
(
adEvent
)
}
val
dialog
=
activity
.
showAdPreparingDialog
()
currentAd
?.
run
{
}
private
fun
showReadyAd
(
adEvent
:
AdEvent
)
{
adState
.
currentAd
?.
run
{
setListener
(
object
:
MaxAdListener
{
override
fun
onAdLoaded
(
p0
:
MaxAd
)
{
}
override
fun
onAdLoaded
(
p0
:
MaxAd
)
=
Unit
override
fun
onAdLoadFailed
(
p0
:
String
,
p1
:
MaxError
)
=
Unit
override
fun
onAdDisplayed
(
ad
:
MaxAd
)
{
dialog
.
cancel
()
lastOpenDate
=
System
.
currentTimeMillis
()
// 广告展示
currentAd
=
null
activityRef
=
null
this
@MaxInsertMgr
.
showCallBack
?.
show
()
AdMaxEvent
.
showAd
(
ad
,
"interAd"
,
activity
::
class
.
simpleName
)
adState
.
onAdDisplayed
()
showCallBack
?.
show
()
(
adEvent
as
AdMaxEvent
).
showAd
(
ad
,
activity
::
class
.
simpleName
)
//计数
LimitUtils
.
addDisplayNum
()
}
override
fun
onAdDisplayFailed
(
ad
:
MaxAd
,
error
:
MaxError
)
{
adState
.
onAdDisplayFailed
()
showCallBack
?.
googleFailed
()
showCallBack
=
null
(
adEvent
as
AdMaxEvent
).
adShowError
(
error
)
}
override
fun
onAdHidden
(
p0
:
MaxAd
)
{
// 广告关闭,清空缓存数据,重新加载
showingAd
=
false
this
@MaxInsertMgr
.
showCallBack
?.
close
()
this
@MaxInsertMgr
.
showCallBack
=
null
loadAd
(
activity
.
applicationContext
)
adState
.
onAdHidden
()
showCallBack
?.
close
()
loadAd
(
activity
.
applicationContext
,
false
,
AdMaxEvent
(
"interAd"
,
"preload"
))
}
override
fun
onAdClicked
(
ad
:
MaxAd
)
{
AdMaxEvent
.
clickAd
(
ad
,
"interAd"
)
(
adEvent
as
AdMaxEvent
).
clickAd
(
ad
)
//计数
LimitUtils
.
addClickNum
()
}
override
fun
onAdLoadFailed
(
p0
:
String
,
p1
:
MaxError
)
{
})
setRevenueListener
(
AdMaxEvent
.
EventOnPaidEventListener
())
showAd
(
activity
)
}
}
fun
loadAd
(
context
:
Context
,
isUnLimit
:
Boolean
,
adEvent
:
AdEvent
,
)
{
if
(!
isUnLimit
)
{
if
(!
LimitUtils
.
isAdShow
(
AdsType
.
INSERT
,
adEvent
))
{
this
.
showCallBack
?.
close
(
4
)
this
.
showCallBack
=
null
return
}
}
if
(!
adState
.
loadingAd
)
{
adState
.
loadingAd
=
true
adEvent
.
adPulStart
()
adState
.
currentAd
=
MaxInterstitialAd
(
ConstConfig
.
MAX_INSERT_UNIT_ID
,
context
)
adState
.
currentAd
?.
setListener
(
object
:
MaxAdListener
{
override
fun
onAdDisplayed
(
p0
:
MaxAd
)
=
Unit
override
fun
onAdHidden
(
p0
:
MaxAd
)
=
Unit
override
fun
onAdClicked
(
p0
:
MaxAd
)
=
Unit
override
fun
onAdDisplayFailed
(
p0
:
MaxAd
,
p1
:
MaxError
)
=
Unit
override
fun
onAdLoaded
(
ad
:
MaxAd
)
{
adState
.
onAdLoaded
(
null
)
val
ac
=
adState
.
activityRef
?.
get
()
if
(
ac
!=
null
)
{
show
(
ac
,
isUnLimit
,
adEvent
,
null
)
}
(
adEvent
as
AdMaxEvent
).
pullAd
(
ad
)
LimitUtils
.
addRequestNum
()
}
override
fun
onAdDisplayFailed
(
p0
:
MaxAd
,
p1
:
MaxError
)
{
dialog
.
cancel
()
// 广告展示失败,清空缓存数据,重新加载
showingAd
=
false
currentAd
=
null
activityRef
=
null
this
@MaxInsertMgr
.
showCallBack
?.
googleFailed
()
this
@MaxInsertMgr
.
showCallBack
=
null
val
obj
=
JSONObject
()
obj
.
put
(
"reason"
,
p1
.
message
)
obj
.
put
(
"code"
,
p1
.
code
)
obj
.
put
(
"ad_unit"
,
"interAd"
)
EventUtils
.
event
(
"ad_show_error"
,
ext
=
obj
)
override
fun
onAdLoadFailed
(
ad
:
String
,
error
:
MaxError
)
{
adState
.
onAdLoadFailed
()
(
adEvent
as
AdMaxEvent
).
pullAd
(
null
,
error
)
showCallBack
?.
googleFailed
(
5
)
showCallBack
=
null
}
})
setRevenueListener
(
AdMaxEvent
.
EventOnPaidEventListener
())
showingAd
=
true
showAd
(
activity
)
adState
.
currentAd
?.
loadAd
()
}
}
override
fun
adAvailable
()
=
((
System
.
currentTimeMillis
()
-
lastTime
)
/
1000
/
60
).
toInt
()
<
30
private
fun
adAvailable
()
=
((
System
.
currentTimeMillis
()
-
adState
.
lastLoadTime
)
/
1000
/
60
).
toInt
()
<
30
}
\ No newline at end of file
app/src/main/java/com/base/locationsharewhite/ads/applovin/MaxNativeMgr.kt
View file @
cfd8ca08
...
...
@@ -10,7 +10,7 @@ import com.applovin.mediation.nativeAds.MaxNativeAdView
import
com.base.locationsharewhite.ads.AdsType
import
com.base.locationsharewhite.ads.ConstConfig
import
com.base.locationsharewhite.ads.NativeParentView
import
com.base.locationsharewhite.ads.
admob.
LimitUtils
import
com.base.locationsharewhite.ads.LimitUtils
import
com.base.locationsharewhite.helper.EventUtils
import
org.json.JSONObject
import
java.util.UUID
...
...
@@ -32,15 +32,20 @@ class MaxNativeMgr {
private
var
currentLoader
:
MaxNativeAdLoader
?
=
null
fun
loadAd
(
context
:
Context
,
parent
:
NativeParentView
?
=
null
,
@LayoutRes
layout
:
Int
?
=
null
)
{
if
(!
LimitUtils
.
isAdShow
(
AdsType
.
NATIVE
))
return
private
fun
loadAd
(
adMaxEvent
:
AdMaxEvent
,
parent
:
NativeParentView
,
@LayoutRes
layout
:
Int
)
{
if
(!
LimitUtils
.
isAdShow
(
AdsType
.
NATIVE
,
adMaxEvent
))
return
val
reqId
=
UUID
.
randomUUID
().
toString
()
val
obj
=
JSONObject
()
obj
.
put
(
"req_id"
,
reqId
)
obj
.
put
(
"ad_type"
,
"nativeAd"
)
val
nativeAdLoader
=
MaxNativeAdLoader
(
ConstConfig
.
MAX_NATIVE_UNIT_ID
,
context
)
val
nativeAdLoader
=
MaxNativeAdLoader
(
ConstConfig
.
MAX_NATIVE_UNIT_ID
,
parent
.
context
)
nativeAdLoader
.
setNativeAdListener
(
object
:
MaxNativeAdListener
()
{
...
...
@@ -48,13 +53,13 @@ class MaxNativeMgr {
currentLoader
=
nativeAdLoader
currentAd
=
ad
lastTime
=
System
.
currentTimeMillis
()
AdMaxEvent
.
pullAd
(
ad
,
"nativeAd"
,
reqId
=
reqI
d
)
adMaxEvent
.
pullAd
(
a
d
)
nativeAdLoader
.
setRevenueListener
(
AdMaxEvent
.
EventOnPaidEventListener
())
if
(
parent
!=
null
&&
layout
!=
null
)
show
(
parent
,
layout
)
show
(
adMaxEvent
,
parent
,
layout
)
}
override
fun
onNativeAdLoadFailed
(
adUnitId
:
String
,
error
:
MaxError
)
{
AdMaxEvent
.
pullAd
(
null
,
"nativeAd"
,
reqId
=
reqId
,
error
)
adMaxEvent
.
pullAd
(
null
,
error
)
}
override
fun
onNativeAdClicked
(
ad
:
MaxAd
)
{
...
...
@@ -66,11 +71,12 @@ class MaxNativeMgr {
}
fun
show
(
adMaxEvent
:
AdMaxEvent
,
parent
:
NativeParentView
,
@LayoutRes
layout
:
Int
,
nativeCallBack
:
((
Any
?)
->
Unit
)?
=
null
)
{
if
(!
LimitUtils
.
isAdShow
(
AdsType
.
NATIVE
))
{
if
(!
LimitUtils
.
isAdShow
(
AdsType
.
NATIVE
,
adMaxEvent
))
{
currentLoader
=
null
currentAd
=
null
return
...
...
@@ -94,7 +100,7 @@ class MaxNativeMgr {
//缓存过期了就清空
currentLoader
=
null
currentAd
=
null
loadAd
(
parent
.
context
.
applicationContext
,
parent
,
layout
)
loadAd
(
AdMaxEvent
(
"nativeAd"
,
"preload"
)
,
parent
,
layout
)
return
}
val
obj
=
JSONObject
()
...
...
app/src/main/java/com/base/locationsharewhite/ads/applovin/MaxOpenMgr.kt
View file @
cfd8ca08
...
...
@@ -6,186 +6,168 @@ import com.applovin.mediation.MaxAd
import
com.applovin.mediation.MaxAdListener
import
com.applovin.mediation.MaxError
import
com.applovin.mediation.ads.MaxAppOpenAd
import
com.base.locationsharewhite.ads.AdEvent
import
com.base.locationsharewhite.ads.AdsShowCallBack
import
com.base.locationsharewhite.ads.AdsType
import
com.base.locationsharewhite.ads.BaseAdMgr
import
com.base.locationsharewhite.ads.ConstConfig
import
com.base.locationsharewhite.ads.admob.LimitUtils
import
com.base.locationsharewhite.helper.EventUtils
import
org.json.JSONObject
import
com.base.locationsharewhite.ads.LimitUtils
import
com.base.locationsharewhite.ads.adState
import
java.lang.ref.WeakReference
import
java.util.UUID
/**
* 开屏广告加载显示管理类
*/
class
MaxOpenMgr
:
BaseAdMgr
<
MaxAppOpenAd
>()
{
private
var
lastOpenDate
:
Long
=
0
override
fun
loadAd
(
context
:
Context
,
isUnLimit
:
Boolean
)
{
if
(!(
loadingAd
&&
LimitUtils
.
isAdShow
(
AdsType
.
OPEN
))
||
isUnLimit
)
{
loadingAd
=
true
//计数
LimitUtils
.
addRequestNum
()
val
reqId
=
UUID
.
randomUUID
().
toString
()
val
obj
=
JSONObject
()
obj
.
put
(
"req_id"
,
reqId
)
obj
.
put
(
"ad_type"
,
"openAd"
)
EventUtils
.
event
(
"ad_pull_start"
,
ext
=
obj
)
currentAd
=
MaxAppOpenAd
(
ConstConfig
.
MAX_OPEN_UNIT_ID
,
context
)
currentAd
?.
setListener
(
object
:
MaxAdListener
{
override
fun
onAdLoaded
(
ad
:
MaxAd
)
{
loadingAd
=
false
lastTime
=
System
.
currentTimeMillis
()
val
ac
=
activityRef
?.
get
()
if
(
ac
!=
null
)
{
show
(
ac
,
isUnLimit
=
isUnLimit
)
}
AdMaxEvent
.
pullAd
(
ad
,
"openAd"
,
reqId
)
class
MaxOpenMgr
{
private
val
adState
=
adState
<
MaxAppOpenAd
>()
private
var
showCallBack
:
AdsShowCallBack
?
=
null
fun
show
(
activity
:
Activity
,
isUnLimit
:
Boolean
,
adEvent
:
AdEvent
,
showCallBack
:
AdsShowCallBack
?)
{
if
(
activity
.
isFinishing
||
activity
.
isDestroyed
)
{
return
}
if
(
adState
.
showingAd
)
{
showCallBack
?.
failed
()
adEvent
.
adShowError
(
"showingAd"
)
return
}
if
(
showCallBack
!=
null
)
{
this
.
showCallBack
=
showCallBack
adState
.
activityRef
=
WeakReference
(
activity
)
adEvent
.
adPrepareShow
()
}
if
(!
adState
.
loadingAd
)
{
if
(!
isUnLimit
)
{
if
(!
LimitUtils
.
isAdShow
(
AdsType
.
OPEN
,
adEvent
))
{
showCallBack
?.
failed
()
return
}
if
(
LimitUtils
.
isIntervalLimited
(
adState
.
lastShowTime
,
adEvent
))
{
showCallBack
?.
failed
()
return
}
}
override
fun
onAdDisplayed
(
p0
:
MaxAd
)
{
if
(!
adAvailable
()
||
adState
.
currentAd
==
null
)
{
loadAd
(
activity
,
isUnLimit
,
adEvent
)
return
}
if
(
adState
.
currentAd
?.
isReady
!=
true
)
{
loadAd
(
activity
,
isUnLimit
,
adEvent
)
return
}
showReadyAd
(
activity
,
adEvent
)
}
}
private
fun
showReadyAd
(
activity
:
Activity
,
adEvent
:
AdEvent
)
{
adState
.
currentAd
?.
run
{
setListener
(
object
:
MaxAdListener
{
override
fun
onAdLoaded
(
p0
:
MaxAd
)
{
}
override
fun
onAdHidden
(
p0
:
MaxAd
)
{
override
fun
onAdDisplayed
(
ad
:
MaxAd
)
{
adState
.
onAdDisplayed
()
showCallBack
?.
show
()
LimitUtils
.
addDisplayNum
()
(
adEvent
as
AdMaxEvent
).
showAd
(
ad
,
activity
::
class
.
simpleName
)
}
override
fun
onAdClicked
(
p0
:
MaxAd
)
{
override
fun
onAdHidden
(
p0
:
MaxAd
)
{
adState
.
onAdHidden
()
showCallBack
?.
close
()
showCallBack
=
null
loadAd
(
activity
.
applicationContext
,
false
,
AdMaxEvent
(
"openAd"
,
"preload"
))
}
override
fun
onAdLoadFailed
(
p0
:
String
,
error
:
MaxError
)
{
loadingAd
=
false
if
(
activityRef
!=
null
&&
!
showingAd
&&
showCallBack
!=
null
)
{
showCallBack
?.
googleFailed
()
showCallBack
=
null
}
AdMaxEvent
.
pullAd
(
null
,
"openAd"
,
reqId
,
error
)
override
fun
onAdClicked
(
ad
:
MaxAd
)
{
(
adEvent
as
AdMaxEvent
).
clickAd
(
ad
)
//计数
LimitUtils
.
addClickNum
()
}
override
fun
onAdDisplayFailed
(
p0
:
MaxAd
,
p1
:
MaxError
)
{
override
fun
onAdLoadFailed
(
p0
:
String
,
p1
:
MaxError
)
{
}
override
fun
onAdDisplayFailed
(
p0
:
MaxAd
,
error
:
MaxError
)
{
adState
.
onAdDisplayFailed
()
showCallBack
?.
googleFailed
()
showCallBack
=
null
adEvent
.
adShowError
(
error
)
}
})
currentAd
?.
loadAd
()
showAd
()
}
}
override
fun
show
(
activity
:
Activity
,
isUnLimit
:
Boolean
,
showCallBack
:
AdsShowCallBack
?)
{
if
(
activity
.
isFinishing
||
activity
.
isDestroyed
)
{
showCallBack
?.
failed
()
return
}
AdMaxEvent
.
adPrepareShow
(
"openAd"
)
fun
loadAd
(
context
:
Context
,
isUnLimit
:
Boolean
,
adEvent
:
AdEvent
)
{
if
(!
isUnLimit
)
{
if
(!
LimitUtils
.
isAdShow
(
AdsType
.
OPEN
))
{
showCallBack
?.
failed
()
return
}
if
(
LimitUtils
.
isIntervalLimited
(
lastOpenDate
))
{
showCallBack
?.
failed
()
if
(!
LimitUtils
.
isAdShow
(
AdsType
.
OPEN
,
adEvent
))
{
this
.
showCallBack
?.
close
()
this
.
showCallBack
=
null
return
}
}
if
(
showingAd
)
{
// 开屏广告正在展示
return
}
if
(
showCallBack
!=
null
&&
this
.
showCallBack
!=
showCallBack
)
this
.
showCallBack
=
showCallBack
if
((
currentAd
?.
isReady
!=
true
).
also
{
if
(
it
)
{
val
obj
=
JSONObject
()
obj
.
put
(
"reason"
,
"no_ad"
)
obj
.
put
(
"ad_unit"
,
"openAd"
)
EventUtils
.
event
(
"ad_show_error"
,
ext
=
obj
)
}
}
||
(!
adAvailable
()).
also
{
if
(
it
)
{
val
obj2
=
JSONObject
()
obj2
.
put
(
"ad_unit"
,
"openAd"
)
EventUtils
.
event
(
"ad_expire"
,
ext
=
obj2
)
}
})
{
//缓存广告过期
currentAd
=
null
if
(
activityRef
==
null
)
{
activityRef
=
WeakReference
(
activity
)
// 开屏广告不可用或者缓存超时过期,重新加载
loadAd
(
activity
.
applicationContext
,
isUnLimit
)
}
else
{
activityRef
=
null
this
.
showCallBack
?.
failed
()
this
.
showCallBack
=
null
val
obj
=
JSONObject
()
obj
.
put
(
"reason"
,
"no_ad"
)
obj
.
put
(
"ad_unit"
,
"openAd"
)
EventUtils
.
event
(
"ad_show_error"
,
ext
=
obj
)
}
return
}
if
(!
adState
.
loadingAd
)
{
adState
.
loadingAd
=
true
currentAd
?.
run
{
setListener
(
object
:
MaxAdListener
{
override
fun
onAdLoaded
(
p0
:
MaxAd
)
{
adEvent
.
adPulStart
()
adState
.
currentAd
=
MaxAppOpenAd
(
ConstConfig
.
MAX_OPEN_UNIT_ID
,
context
)
adState
.
currentAd
?.
setListener
(
object
:
MaxAdListener
{
override
fun
onAdLoaded
(
ad
:
MaxAd
)
{
adState
.
onAdLoaded
(
null
)
val
ac
=
adState
.
activityRef
?.
get
()
if
(
ac
!=
null
)
{
show
(
ac
,
isUnLimit
,
adEvent
,
null
)
}
(
adEvent
as
AdMaxEvent
).
pullAd
(
ad
)
LimitUtils
.
addRequestNum
()
}
override
fun
onAdDisplayed
(
ad
:
MaxAd
)
{
lastOpenDate
=
System
.
currentTimeMillis
()
// 广告展示
currentAd
=
null
activityRef
=
null
this
@MaxOpenMgr
.
showCallBack
?.
show
()
//计数
LimitUtils
.
addDisplayNum
()
AdMaxEvent
.
showAd
(
ad
,
"openAd"
,
activity
::
class
.
simpleName
)
currentAd
?.
setRevenueListener
(
AdMaxEvent
.
EventOnPaidEventListener
())
override
fun
onAdDisplayed
(
p0
:
MaxAd
)
{
}
override
fun
onAdHidden
(
p0
:
MaxAd
)
{
// 广告关闭,清空缓存数据,重新加载
showingAd
=
false
this
@MaxOpenMgr
.
showCallBack
?.
close
()
this
@MaxOpenMgr
.
showCallBack
=
null
loadAd
(
activity
.
applicationContext
)
}
override
fun
onAdClicked
(
ad
:
MaxAd
)
{
AdMaxEvent
.
clickAd
(
ad
,
"openAd"
)
//计数
LimitUtils
.
addClickNum
()
}
override
fun
onAdLoadFailed
(
p0
:
String
,
p1
:
MaxError
)
{
override
fun
onAdClicked
(
p0
:
MaxAd
)
{
}
override
fun
onAdLoadFailed
(
p0
:
String
,
error
:
MaxError
)
{
adState
.
onAdLoadFailed
()
showCallBack
?.
googleFailed
()
showCallBack
=
null
(
adEvent
as
AdMaxEvent
).
pullAd
(
null
,
error
)
}
override
fun
onAdDisplayFailed
(
p0
:
MaxAd
,
p1
:
MaxError
)
{
// 广告展示失败,清空缓存数据,重新加载
showingAd
=
false
currentAd
=
null
activityRef
=
null
this
@MaxOpenMgr
.
showCallBack
?.
googleFailed
()
this
@MaxOpenMgr
.
showCallBack
=
null
val
obj
=
JSONObject
()
obj
.
put
(
"reason"
,
p1
.
message
)
obj
.
put
(
"code"
,
p1
.
code
)
obj
.
put
(
"ad_unit"
,
"openAd"
)
EventUtils
.
event
(
"ad_show_error"
,
ext
=
obj
)
}
})
showingAd
=
true
showAd
()
adState
.
currentAd
?.
loadAd
()
}
}
override
fun
adAvailable
()
=
((
System
.
currentTimeMillis
()
-
lastTime
)
/
1000
/
60
).
toInt
()
<
30
fun
adAvailable
()
=
((
System
.
currentTimeMillis
()
-
adState
.
lastLoadTime
)
/
1000
/
60
).
toInt
()
<
30
}
\ No newline at end of file
app/src/main/java/com/base/locationsharewhite/config/AdConfigBean.kt
View file @
cfd8ca08
package
com.base.locationsharewhite.config
class
AdConfigBean
(
var
adSwitch
:
Boolean
=
true
,
var
adSwitch
:
Boolean
=
true
,
//true 走admob,false走max
var
numDisplayLimit
:
Int
=
-
1
,
var
numRequestLimit
:
Int
=
-
1
,
var
numClickLimit
:
Int
=
-
1
,
...
...
app/src/main/java/com/base/locationsharewhite/ui/main/MainActivity.kt
View file @
cfd8ca08
...
...
@@ -103,7 +103,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnMapReadyCallback {
showNotificationDialog
()
if
(!
bannerShowed
.
get
())
{
bannerShowed
.
set
(
true
)
Ad
BannerMgr
().
show
(
binding
.
flAd
)
Ad
sMgr
.
showBanner
(
binding
.
flAd
)
}
}
...
...
@@ -209,15 +209,18 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnMapReadyCallback {
private
fun
showAdJump
(
jumpAction
:
()
->
Unit
)
{
AdsMgr
.
showInsert
(
this
,
false
,
object
:
AdsShowCallBack
()
{
override
fun
close
()
{
override
fun
close
(
where
:
Int
)
{
LogEx
.
logDebug
(
TAG
,
"close where=$where"
)
jumpAction
.
invoke
()
}
override
fun
failed
()
{
override
fun
failed
(
where
:
Int
)
{
LogEx
.
logDebug
(
TAG
,
"failed where=$where"
)
jumpAction
.
invoke
()
}
override
fun
googleFailed
()
{
override
fun
googleFailed
(
where
:
Int
)
{
LogEx
.
logDebug
(
TAG
,
"googleFailed where=$where"
)
jumpAction
.
invoke
()
}
})
...
...
app/src/main/java/com/base/locationsharewhite/ui/splash/SplashActivity.kt
View file @
cfd8ca08
...
...
@@ -70,17 +70,17 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>(), SplashView {
cancelProgressJob
()
}
override
fun
close
()
{
override
fun
close
(
where
:
Int
)
{
LogEx
.
logDebug
(
TAG
,
"AdsShowCallBack close"
)
jumpNext
()
}
override
fun
failed
()
{
override
fun
failed
(
where
:
Int
)
{
LogEx
.
logDebug
(
TAG
,
"AdsShowCallBack failed"
)
jumpNext
()
}
override
fun
googleFailed
()
{
override
fun
googleFailed
(
where
:
Int
)
{
LogEx
.
logDebug
(
TAG
,
"AdsShowCallBack googleFailed"
)
jumpNext
()
}
...
...
app/src/main/java/com/base/locationsharewhite/ui/views/DialogView.kt
View file @
cfd8ca08
...
...
@@ -81,7 +81,7 @@ object DialogView {
binding
.
ivClose
.
setOnClickListener
{
dialog
.
dismiss
()
}
AdsMgr
.
showNative
(
binding
.
flAd
,
R
.
layout
.
layout_admob_app_exit
)
AdsMgr
.
showNative
(
binding
.
flAd
,
R
.
layout
.
layout_admob_app_exit
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment