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
42a8efa0
Commit
42a8efa0
authored
Jul 16, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...
parent
6dd20caa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
79 deletions
+38
-79
ResultActivity.kt
...ain/java/com/base/datarecovery/activity/ResultActivity.kt
+0
-1
AdMaxInterstitialUtils.kt
...a/com/base/datarecovery/ads/max/AdMaxInterstitialUtils.kt
+38
-78
No files found.
app/src/main/java/com/base/datarecovery/activity/ResultActivity.kt
View file @
42a8efa0
...
...
@@ -126,7 +126,6 @@ class ResultActivity : BaseActivity<ActivityLayoutResultBinding>() {
binding
.
ivBack
.
setOnClickListener
{
onBackPressedDispatcher
.
onBackPressed
()
}
AdmobNativeUtils
.
showNativeAd
(
this
@ResultActivity
,
binding
.
flAd
,
R
.
layout
.
layout_native_custom_white
)
}
...
...
app/src/main/java/com/base/datarecovery/ads/max/AdMaxInterstitialUtils.kt
View file @
42a8efa0
...
...
@@ -12,11 +12,6 @@ import com.base.datarecovery.help.ConfigHelper
import
com.base.datarecovery.utils.EventUtils
import
com.base.datarecovery.utils.LogEx
import
com.base.datarecovery.view.CustomDialog
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.MainScope
import
kotlinx.coroutines.async
import
kotlinx.coroutines.delay
import
kotlinx.coroutines.launch
import
org.json.JSONObject
import
java.util.concurrent.TimeUnit
import
kotlin.math.min
...
...
@@ -37,56 +32,55 @@ object AdMaxInterstitialUtils {
private
fun
setListener
(
activity
:
Activity
)
{
if
(
interstitialAd
==
null
)
{
interstitialAd
=
MaxInterstitialAd
(
ConfigHelper
.
interAdMaxId
,
activity
)
}
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"
)
AdDisplayUtils
.
getInstance
().
incrementAdRequestFailCount
()
retryAttempt
++
val
delayMillis
=
TimeUnit
.
SECONDS
.
toMillis
(
2.0
.
pow
(
min
(
6
,
retryAttempt
)).
toLong
())
LogEx
.
logDebug
(
TAG
,
"onAdLoadFailed retryAttempt=$retryAttempt delayMillis=$delayMillis"
)
if
(
retryAttempt
==
2
)
{
onHidden
?.
invoke
()
customDialog
?.
dismiss
()
interstitialAd
?.
setListener
(
object
:
MaxAdListener
{
override
fun
onAdLoaded
(
p0
:
MaxAd
)
{
LogEx
.
logDebug
(
TAG
,
"onAdLoaded"
)
loadingListener
?.
invoke
()
interLoadTime
=
System
.
currentTimeMillis
()
retryAttempt
=
0
}
else
{
interstitialAd
?.
loadAd
()
}
override
fun
onAdLoadFailed
(
p0
:
String
,
p1
:
MaxError
)
{
LogEx
.
logDebug
(
TAG
,
"onAdLoadFailed"
)
AdDisplayUtils
.
getInstance
().
incrementAdRequestFailCount
()
retryAttempt
++
val
delayMillis
=
TimeUnit
.
SECONDS
.
toMillis
(
2.0
.
pow
(
min
(
6
,
retryAttempt
)).
toLong
())
LogEx
.
logDebug
(
TAG
,
"onAdLoadFailed retryAttempt=$retryAttempt delayMillis=$delayMillis"
)
if
(
retryAttempt
==
2
)
{
onHidden
?.
invoke
()
customDialog
?.
dismiss
()
retryAttempt
=
0
}
else
{
interstitialAd
?.
loadAd
()
// MainScope().async {
// interstitialAd?.loadAd()
// delay(delayMillis)
// }.onAwait
}
}
}
override
fun
onAdDisplayed
(
p0
:
MaxAd
)
{
LogEx
.
logDebug
(
TAG
,
"onAdDisplayed"
)
AdDisplayUtils
.
getInstance
().
incrementAdDisplayCount
()
}
override
fun
onAdDisplayed
(
p0
:
MaxAd
)
{
LogEx
.
logDebug
(
TAG
,
"onAdDisplayed"
)
AdDisplayUtils
.
getInstance
().
incrementAdDisplayCount
()
}
override
fun
onAdHidden
(
p0
:
MaxAd
)
{
LogEx
.
logDebug
(
TAG
,
"onAdHidden"
)
onHidden
?.
invoke
()
interstitialAd
?.
loadAd
()
}
override
fun
onAdHidden
(
p0
:
MaxAd
)
{
LogEx
.
logDebug
(
TAG
,
"onAdHidden"
)
onHidden
?.
invoke
()
interstitialAd
?.
loadAd
()
}
override
fun
onAdClicked
(
p0
:
MaxAd
)
{
LogEx
.
logDebug
(
TAG
,
"onAdClicked"
)
AdDisplayUtils
.
getInstance
().
incrementAdClickCount
()
}
override
fun
onAdClicked
(
p0
:
MaxAd
)
{
LogEx
.
logDebug
(
TAG
,
"onAdClicked"
)
AdDisplayUtils
.
getInstance
().
incrementAdClickCount
()
}
override
fun
onAdDisplayFailed
(
p0
:
MaxAd
,
p1
:
MaxError
)
{
LogEx
.
logDebug
(
TAG
,
"onAdDisplayFailed"
)
}
})
override
fun
onAdDisplayFailed
(
p0
:
MaxAd
,
p1
:
MaxError
)
{
LogEx
.
logDebug
(
TAG
,
"onAdDisplayFailed"
)
}
})
}
}
fun
showInterstitialAd
(
...
...
@@ -133,40 +127,6 @@ object AdMaxInterstitialUtils {
return
System
.
currentTimeMillis
()
-
interLoadTime
>
1000
*
60
*
60
}
private
fun
showIntervalDialogAndShowAd
(
activity
:
Activity
,
isShowDialog
:
Boolean
,
onHidden
:
(()
->
Unit
)?,
interval
:
Int
)
{
// if (!isShowDialog) {
// return
// }
//
// if (customDialog != null && customDialog?.isShowing == true) {
// return // 如果对话框已经显示,则不再显示
// }
//
// customDialog = CustomDialog(activity, R.layout.dialog_ad_loading)
// customDialog?.setCountdownText(R.id.dialog_ad_loading_text)
// val countdownTimer = object : CountDownTimer((interval * 1000).toLong(), 1000) {
// override fun onTick(millisUntilFinished: Long) {
// val seconds = (millisUntilFinished / 1000).toInt()
// customDialog?.updateCountdownText("Advertising in preparation ($seconds" + "s)...")
// }
//
// override fun onFinish() {
// if (!activity.isDestroyed && !activity.isFinishing) {
// customDialog?.dismiss()
// }
// customDialog = null
// LogEx.logDebug(TAG, "onFinish")
// interstitialAd?.showAd()
// }
// }
// countdownTimer.start()
// customDialog?.show()
}
private
fun
showAdDialogAndLoadInterstitial
(
activity
:
Activity
,
...
...
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