Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
D
Data Recovery 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
Data Recovery White
Commits
19e872a6
Commit
19e872a6
authored
Jul 19, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...插页广告
parent
f3621897
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
28 deletions
+32
-28
AdMaxInterstitialUtils.kt
...a/com/base/datarecovery/ads/max/AdMaxInterstitialUtils.kt
+32
-28
No files found.
app/src/main/java/com/base/datarecovery/ads/max/AdMaxInterstitialUtils.kt
View file @
19e872a6
...
@@ -2,6 +2,7 @@ package com.base.datarecovery.ads.max
...
@@ -2,6 +2,7 @@ package com.base.datarecovery.ads.max
import
android.annotation.SuppressLint
import
android.annotation.SuppressLint
import
android.app.Activity
import
android.app.Activity
import
android.app.Dialog
import
com.applovin.mediation.MaxAd
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
...
@@ -27,11 +28,6 @@ object AdMaxInterstitialUtils {
...
@@ -27,11 +28,6 @@ object AdMaxInterstitialUtils {
private
var
interLoadTime
=
Long
.
MAX_VALUE
private
var
interLoadTime
=
Long
.
MAX_VALUE
private
var
onHidden
:
(()
->
Unit
)?
=
null
private
var
onHidden
:
(()
->
Unit
)?
=
null
private
var
loadingListener
:
(()
->
Unit
)?
=
null
private
var
loadingListener
:
(()
->
Unit
)?
=
null
private
var
retryAttempt
=
0
@SuppressLint
(
"StaticFieldLeak"
)
private
var
customDialog
:
CustomDialog
?
=
null
private
var
activityString
:
String
=
""
private
var
activityString
:
String
=
""
private
fun
setListener
(
activity
:
Activity
)
{
private
fun
setListener
(
activity
:
Activity
)
{
...
@@ -47,7 +43,6 @@ object AdMaxInterstitialUtils {
...
@@ -47,7 +43,6 @@ object AdMaxInterstitialUtils {
loadingListener
=
null
loadingListener
=
null
interLoadTime
=
System
.
currentTimeMillis
()
interLoadTime
=
System
.
currentTimeMillis
()
retryAttempt
=
0
val
reqId
=
UUID
.
randomUUID
().
toString
()
val
reqId
=
UUID
.
randomUUID
().
toString
()
AdMaxEvent
.
pullAd
(
p0
,
"interAd"
,
reqId
=
reqId
)
AdMaxEvent
.
pullAd
(
p0
,
"interAd"
,
reqId
=
reqId
)
}
}
...
@@ -57,14 +52,9 @@ object AdMaxInterstitialUtils {
...
@@ -57,14 +52,9 @@ object AdMaxInterstitialUtils {
val
reqId
=
UUID
.
randomUUID
().
toString
()
val
reqId
=
UUID
.
randomUUID
().
toString
()
AdMaxEvent
.
pullAd
(
null
,
"interAd"
,
reqId
=
reqId
,
error
=
p1
.
message
,
code
=
p1
.
code
)
AdMaxEvent
.
pullAd
(
null
,
"interAd"
,
reqId
=
reqId
,
error
=
p1
.
message
,
code
=
p1
.
code
)
AdDisplayUtils
.
getInstance
().
incrementAdRequestFailCount
()
AdDisplayUtils
.
getInstance
().
incrementAdRequestFailCount
()
retryAttempt
++
LogEx
.
logDebug
(
TAG
,
"onAdLoadFailed retryAttempt=$retryAttempt"
)
loadingListener
?.
invoke
()
if
(
retryAttempt
==
1
)
{
loadingListener
=
null
customDialog
?.
dismiss
()
onHidden
?.
invoke
()
onHidden
=
null
retryAttempt
=
0
}
}
}
override
fun
onAdDisplayed
(
p0
:
MaxAd
)
{
override
fun
onAdDisplayed
(
p0
:
MaxAd
)
{
...
@@ -90,6 +80,8 @@ object AdMaxInterstitialUtils {
...
@@ -90,6 +80,8 @@ object AdMaxInterstitialUtils {
override
fun
onAdDisplayFailed
(
p0
:
MaxAd
,
p1
:
MaxError
)
{
override
fun
onAdDisplayFailed
(
p0
:
MaxAd
,
p1
:
MaxError
)
{
LogEx
.
logDebug
(
TAG
,
"onAdDisplayFailed"
)
LogEx
.
logDebug
(
TAG
,
"onAdDisplayFailed"
)
onHidden
?.
invoke
()
onHidden
=
null
val
obj2
=
JSONObject
()
val
obj2
=
JSONObject
()
obj2
.
put
(
"code"
,
p1
.
code
)
obj2
.
put
(
"code"
,
p1
.
code
)
obj2
.
put
(
"reason"
,
p1
.
message
)
obj2
.
put
(
"reason"
,
p1
.
message
)
...
@@ -129,9 +121,9 @@ object AdMaxInterstitialUtils {
...
@@ -129,9 +121,9 @@ object AdMaxInterstitialUtils {
obj1
.
put
(
"ad_unit"
,
"interAd"
)
obj1
.
put
(
"ad_unit"
,
"interAd"
)
EventUtils
.
event
(
"ad_prepare_show"
,
ext
=
obj1
)
EventUtils
.
event
(
"ad_prepare_show"
,
ext
=
obj1
)
this
.
onHidden
=
onHidden
if
(
interstitialAd
?.
isReady
==
true
)
{
if
(
interstitialAd
?.
isReady
==
true
)
{
LogEx
.
logDebug
(
TAG
,
"有缓存直接播放。"
)
LogEx
.
logDebug
(
TAG
,
"有缓存直接播放。"
)
this
.
onHidden
=
onHidden
interstitialAd
?.
showAd
(
activity
)
interstitialAd
?.
showAd
(
activity
)
}
else
{
}
else
{
LogEx
.
logDebug
(
TAG
,
"展示广告时,没有缓存,需要拉取。"
)
LogEx
.
logDebug
(
TAG
,
"展示广告时,没有缓存,需要拉取。"
)
...
@@ -139,9 +131,22 @@ object AdMaxInterstitialUtils {
...
@@ -139,9 +131,22 @@ object AdMaxInterstitialUtils {
obj2
.
put
(
"reason"
,
"no ad"
)
obj2
.
put
(
"reason"
,
"no ad"
)
obj2
.
put
(
"ad_unit"
,
"interAd"
)
obj2
.
put
(
"ad_unit"
,
"interAd"
)
EventUtils
.
event
(
"ad_show_error"
,
ext
=
obj2
)
EventUtils
.
event
(
"ad_show_error"
,
ext
=
obj2
)
loadInterstitialAd
(
activity
)
val
loaded
=
loadInterstitialAd
(
activity
)
LogEx
.
logDebug
(
TAG
,
"isReady=false"
)
if
(
loaded
)
{
showAdDialogAndLoadInterstitial
(
activity
)
LogEx
.
logDebug
(
TAG
,
"loaded=true"
)
val
dialog
=
showAdDialogAndLoadInterstitial
(
activity
)
loadingListener
=
{
dialog
?.
dismiss
()
if
(
interstitialAd
?.
isReady
==
true
)
{
interstitialAd
?.
showAd
(
activity
)
}
else
{
onHidden
?.
invoke
()
}
}
}
else
{
LogEx
.
logDebug
(
TAG
,
"loaded=false"
)
onHidden
?.
invoke
()
}
}
}
}
}
...
@@ -153,27 +158,24 @@ object AdMaxInterstitialUtils {
...
@@ -153,27 +158,24 @@ object AdMaxInterstitialUtils {
private
fun
showAdDialogAndLoadInterstitial
(
private
fun
showAdDialogAndLoadInterstitial
(
activity
:
Activity
,
activity
:
Activity
,
)
{
):
Dialog
?
{
var
customDialog
:
Dialog
?
=
null
if
(!
activity
.
isFinishing
&&
!
activity
.
isDestroyed
)
{
if
(!
activity
.
isFinishing
&&
!
activity
.
isDestroyed
)
{
customDialog
=
CustomDialog
(
activity
,
R
.
layout
.
dialog_ad_loading
)
customDialog
=
CustomDialog
(
activity
,
R
.
layout
.
dialog_ad_loading
)
// 设置对话框的样式和内容
// 设置对话框的样式和内容
customDialog
?
.
show
()
customDialog
.
show
()
}
}
loadingListener
=
{
return
customDialog
customDialog
?.
dismiss
()
interstitialAd
?.
showAd
(
activity
)
}
}
}
fun
loadInterstitialAd
(
activity
:
Activity
)
{
fun
loadInterstitialAd
(
activity
:
Activity
)
:
Boolean
{
setListener
(
activity
)
setListener
(
activity
)
if
(!
AdDisplayUtils
.
getInstance
().
shouldShowAd
(
"interAd"
))
{
if
(!
AdDisplayUtils
.
getInstance
().
shouldShowAd
(
"interAd"
))
{
return
return
false
}
}
if
(
interstitialAd
?.
isReady
==
true
)
{
if
(
interstitialAd
?.
isReady
==
true
)
{
return
return
false
}
}
if
(
isAdInit
.
get
())
{
if
(
isAdInit
.
get
())
{
LogEx
.
logDebug
(
TAG
,
"loadInterstitialAd"
)
LogEx
.
logDebug
(
TAG
,
"loadInterstitialAd"
)
...
@@ -183,7 +185,9 @@ object AdMaxInterstitialUtils {
...
@@ -183,7 +185,9 @@ object AdMaxInterstitialUtils {
obj
.
put
(
"ad_type"
,
"interAd"
)
obj
.
put
(
"ad_type"
,
"interAd"
)
EventUtils
.
event
(
"ad_pull_start"
,
ext
=
obj
)
EventUtils
.
event
(
"ad_pull_start"
,
ext
=
obj
)
interstitialAd
?.
loadAd
()
interstitialAd
?.
loadAd
()
return
true
}
}
return
false
}
}
...
...
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