Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
F
File Recovery RecycleBin
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
File Recovery RecycleBin
Commits
851ff8db
Commit
851ff8db
authored
Jul 16, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
开屏预加载
parent
6caecc70
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
39 deletions
+54
-39
SplashActivity.kt
...om/base/filerecoveryrecyclebin/activity/SplashActivity.kt
+6
-5
AdMaxInterstitialUtils.kt
.../filerecoveryrecyclebin/ads/max/AdMaxInterstitialUtils.kt
+17
-16
AdMaxOpenUtils.kt
...com/base/filerecoveryrecyclebin/ads/max/AdMaxOpenUtils.kt
+31
-18
No files found.
app/src/main/java/com/base/filerecoveryrecyclebin/activity/SplashActivity.kt
View file @
851ff8db
...
...
@@ -72,17 +72,18 @@ class SplashActivity : BaseActivity<ActivitySplashBinding>() {
actionId
=
intent
?.
extras
?.
getInt
(
"actionId"
)
?:
-
1
closeNotification
()
if
(
ConfigHelper
.
admobTrueMaxFlase
)
{
AdmobNativeUtils
.
loadNativeAd
()
AdmobInterstitialUtils
.
loadInterstitialAd
(
this
)
}
progressCollect
()
if
(
ifAgreePrivacy
)
{
job
=
startProgress
()
binding
.
llStart
.
visibility
=
View
.
GONE
binding
.
llProgress
.
visibility
=
View
.
VISIBLE
if
(
ConfigHelper
.
admobTrueMaxFlase
)
{
AdmobNativeUtils
.
loadNativeAd
()
AdmobInterstitialUtils
.
loadInterstitialAd
(
this
)
}
else
{
AdMaxOpenUtils
.
loadAppOpenAd
(
this
)
}
}
else
{
binding
.
llStart
.
visibility
=
View
.
VISIBLE
binding
.
llProgress
.
visibility
=
View
.
GONE
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/ads/max/AdMaxInterstitialUtils.kt
View file @
851ff8db
...
...
@@ -47,32 +47,39 @@ object AdMaxInterstitialUtils {
interstitialAd
?.
setListener
(
object
:
MaxAdListener
{
override
fun
onAdLoaded
(
p0
:
MaxAd
)
{
LogEx
.
logDebug
(
TAG
,
"onAdLoaded"
)
loadingListener
?.
invoke
()
interLoadTime
=
System
.
currentTimeMillis
()
retryAttempt
=
0
}
override
fun
onAdLoadFailed
(
p0
:
String
,
p1
:
MaxError
)
{
LogEx
.
logDebug
(
TAG
,
"onAdLoadFailed"
)
retryAttempt
++
val
delayMillis
=
TimeUnit
.
SECONDS
.
toMillis
(
2.0
.
pow
(
min
(
6
,
retryAttempt
)).
toLong
())
MainScope
().
launch
{
delay
(
delayMillis
)
interstitialAd
?.
loadAd
()
}
}
override
fun
onAdDisplayed
(
p0
:
MaxAd
)
{
LogEx
.
logDebug
(
TAG
,
"onAdDisplayed"
)
}
override
fun
onAdHidden
(
p0
:
MaxAd
)
{
LogEx
.
logDebug
(
TAG
,
"onAdHidden"
)
onHidden
?.
invoke
()
}
override
fun
onAdClicked
(
p0
:
MaxAd
)
{
LogEx
.
logDebug
(
TAG
,
"onAdClicked"
)
}
override
fun
onAdLoadFailed
(
p0
:
String
,
p1
:
MaxError
)
{
retryAttempt
++
val
delayMillis
=
TimeUnit
.
SECONDS
.
toMillis
(
2.0
.
pow
(
min
(
6
,
retryAttempt
)).
toLong
())
MainScope
().
launch
{
delay
(
delayMillis
)
interstitialAd
?.
loadAd
()
}
}
override
fun
onAdDisplayFailed
(
p0
:
MaxAd
,
p1
:
MaxError
)
{
LogEx
.
logDebug
(
TAG
,
"onAdDisplayFailed"
)
}
})
}
...
...
@@ -114,7 +121,7 @@ object AdMaxInterstitialUtils {
}
else
{
interstitialAd
?.
loadAd
()
LogEx
.
logDebug
(
TAG
,
"isReady=false"
)
showAdDialogAndLoadInterstitial
(
activity
,
isReLoadAd
,
isShowDialog
,
onHidden
)
showAdDialogAndLoadInterstitial
(
activity
,
isReLoadAd
)
}
}
...
...
@@ -160,9 +167,7 @@ object AdMaxInterstitialUtils {
private
fun
showAdDialogAndLoadInterstitial
(
activity
:
Activity
,
isReLoadAd
:
Boolean
,
isShowDialog
:
Boolean
,
onHidden
:
(()
->
Unit
)?
)
{
if
(!
isShowDialog
)
{
return
...
...
@@ -180,10 +185,6 @@ object AdMaxInterstitialUtils {
loadingListener
=
null
}
// if (isReLoadAd) {
// mDialog?.dismiss()
// onHidden?.invoke()
// }
}
...
...
app/src/main/java/com/base/filerecoveryrecyclebin/ads/max/AdMaxOpenUtils.kt
View file @
851ff8db
...
...
@@ -17,6 +17,7 @@ import com.base.filerecoveryrecyclebin.utils.LogEx
import
kotlinx.coroutines.MainScope
import
kotlinx.coroutines.delay
import
kotlinx.coroutines.launch
import
org.jacoco.core.internal.analysis.filter.IFilter
import
org.json.JSONObject
import
java.util.concurrent.TimeUnit
import
kotlin.math.min
...
...
@@ -28,8 +29,8 @@ object AdMaxOpenUtils {
private
var
openLoadTime
=
Long
.
MAX_VALUE
private
var
onHidden
:
(()
->
Unit
)?
=
null
private
var
loadingListener
:
(()
->
Unit
)?
=
null
private
var
retryAttempt
=
0
private
var
maxRetryAttempt
=
8
private
fun
setListener
(
context
:
Context
)
{
if
(
appOpenAd
==
null
)
{
...
...
@@ -43,19 +44,23 @@ object AdMaxOpenUtils {
}
override
fun
onAdLoadFailed
(
p0
:
String
,
p1
:
MaxError
)
{
retryAttempt
++
val
delayMillis
=
TimeUnit
.
SECONDS
.
toMillis
(
2.0
.
pow
(
min
(
6
,
retryAttempt
)).
toLong
())
LogEx
.
logDebug
(
TAG
,
"onAdLoadFailed retryAttempt=$retryAttempt delayMillis=$delayMillis"
)
if
(
retryAttempt
==
2
)
{
LogEx
.
logDebug
(
TAG
,
"onAdLoadFailed onHidden"
)
onHidden
?.
invoke
()
}
MainScope
().
launch
{
delay
(
delayMillis
)
appOpenAd
?.
loadAd
()
}
// retryAttempt++
// val delayMillis = TimeUnit.SECONDS.toMillis(2.0.pow(min(6, retryAttempt)).toLong())
// LogEx.logDebug(TAG, "onAdLoadFailed retryAttempt=$retryAttempt delayMillis=$delayMillis")
// if (retryAttempt == 2) {
// LogEx.logDebug(TAG, "onAdLoadFailed onHidden")
// onHidden?.invoke()
// }
//
// if (retryAttempt <= maxRetryAttempt) {
// MainScope().launch {
// delay(delayMillis)
// appOpenAd?.loadAd()
// }
// } else {
// retryAttempt = 0
// }
onHidden
?.
invoke
()
}
...
...
@@ -127,20 +132,28 @@ object AdMaxOpenUtils {
LogEx
.
logDebug
(
TAG
,
"showAppOpenAd continue"
)
this
.
onHidden
=
onHidden
if
(
appOpenAd
?.
isReady
!=
true
)
{
LogEx
.
logDebug
(
TAG
,
"isReady=false"
)
appOpenAd
?.
loadAd
()
loadingListener
=
{
this
.
onHidden
=
onHidden
LogEx
.
logDebug
(
TAG
,
"loadingListener callback"
)
loaded
?.
invoke
()
val
obj1
=
JSONObject
()
obj1
.
put
(
"ad_unit"
,
"openAd"
)
EventUtils
.
event
(
"ad_prepare_show"
,
ext
=
obj1
)
appOpenAd
?.
showAd
()
appOpenAd
?.
loadAd
()
}
}
else
{
onHidden
?.
invoke
()
appOpenAd
?.
loadAd
()
}
}
fun
loadAppOpenAd
(
activity
:
Activity
)
{
setListener
(
activity
)
if
(
AdMaxInit
.
isAdMaxInit
)
{
appOpenAd
?.
loadAd
()
}
}
...
...
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