Commit 589ec952 authored by wanglei's avatar wanglei

...

parent 535874b4
......@@ -12,7 +12,9 @@ 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
......@@ -28,7 +30,6 @@ object AdMaxInterstitialUtils {
private var onHidden: (() -> Unit)? = null
private var loadingListener: (() -> Unit)? = null
private var retryAttempt = 0
private var maxRetryAttempt = 3
@SuppressLint("StaticFieldLeak")
private var customDialog: CustomDialog? = null
......@@ -56,14 +57,11 @@ object AdMaxInterstitialUtils {
onHidden?.invoke()
customDialog?.dismiss()
}
if (retryAttempt <= maxRetryAttempt) {
MainScope().launch {
delay(delayMillis)
interstitialAd?.loadAd()
}
} else {
retryAttempt = 0
}
MainScope().async {
interstitialAd?.loadAd()
delay(delayMillis)
}.onAwait
}
......@@ -92,8 +90,6 @@ object AdMaxInterstitialUtils {
fun showInterstitialAd(
activity: Activity,
isReLoadAd: Boolean = false,
isShowDialog: Boolean = true,
onHidden: (() -> Unit)? = null
) {
setListener(activity)
......@@ -123,11 +119,11 @@ object AdMaxInterstitialUtils {
this.onHidden = onHidden
if (interstitialAd?.isReady == true) {
LogEx.logDebug(TAG, "isReady=true")
showIntervalDialogAndShowAd(activity, isShowDialog, onHidden, 2)
interstitialAd?.showAd()
} else {
interstitialAd?.loadAd()
LogEx.logDebug(TAG, "isReady=false")
showAdDialogAndLoadInterstitial(activity, isShowDialog)
showAdDialogAndLoadInterstitial(activity)
}
}
......@@ -164,7 +160,7 @@ object AdMaxInterstitialUtils {
// }
// customDialog = null
// LogEx.logDebug(TAG, "onFinish")
interstitialAd?.showAd()
// interstitialAd?.showAd()
// }
// }
// countdownTimer.start()
......@@ -173,12 +169,7 @@ object AdMaxInterstitialUtils {
private fun showAdDialogAndLoadInterstitial(
activity: Activity,
isShowDialog: Boolean,
) {
if (!isShowDialog) {
return
}
if (!activity.isFinishing && !activity.isDestroyed) {
customDialog = CustomDialog(activity, R.layout.dialog_ad_loading)
// 设置对话框的样式和内容
......
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