Commit 98ed7b64 authored by wanglei's avatar wanglei

...

parent 71da967f
......@@ -7,6 +7,7 @@ import androidx.core.view.updatePadding
import androidx.lifecycle.lifecycleScope
import com.base.datarecovery.adapter.MediaAdapter
import com.base.datarecovery.ads.AdmobInterstitialUtils
import com.base.datarecovery.ads.AdmobInterstitialUtils.showInterAdSp
import com.base.datarecovery.ads.AdmobNativeUtils
import com.base.datarecovery.bean.MediaBean
import com.base.datarecovery.bean.MediaTimeBean
......@@ -90,18 +91,27 @@ class RepeatActivity : BaseActivity<ActivityRepeatBinding>() {
}
binding.tvClean.setOnClickListener {
showDeletePermanentlyDialog {
AdmobInterstitialUtils.showInterstitialAd(this) {
lifecycleScope.launch(Dispatchers.IO) {
mediaAdapter.getSelectData().second.forEach {
runCatching {
val file = File(it.path)
file.delete()
}
}
initData()
if (showInterAdSp()) {
AdmobInterstitialUtils.showInterstitialAd(this) {
cleanFile()
}
} else {
cleanFile()
}
}
}
}
private fun cleanFile() {
lifecycleScope.launch(Dispatchers.IO) {
mediaAdapter.getSelectData().second.forEach {
runCatching {
val file = File(it.path)
file.delete()
}
}
initData()
}
}
......
......@@ -8,6 +8,7 @@ import androidx.core.view.updatePadding
import androidx.lifecycle.lifecycleScope
import com.base.datarecovery.adapter.ScreenShotAdapter
import com.base.datarecovery.ads.AdmobInterstitialUtils
import com.base.datarecovery.ads.AdmobInterstitialUtils.showInterAdSp
import com.base.datarecovery.ads.AdmobNativeUtils
import com.base.datarecovery.bean.ScreenPhotoBean
import com.base.datarecovery.bean.ScreenshotBean
......@@ -118,32 +119,40 @@ class ScreenShotActivity : BaseActivity<ActivityScreenShotBinding>() {
setCleanUpUi(size)
}
binding.tvClean.setOnClickListener {
val files = screenShotAdapter.getSelectData()
showDeletePermanentlyDialog {
AdmobInterstitialUtils.showInterstitialAd(this) {
lifecycleScope.launch(Dispatchers.IO) {
async {
files.forEach { screenFile ->
runCatching {
val file = screenFile.file
if (file.exists()) file.delete()
}
}
}.await()
launch(Dispatchers.Main) {
binding.tvClean.text = "CLEAN"
screenShotAdapter.removeData(files)
val split = screenShotAdapter.getAllData().sumOf { it.file.length() }.toFormatSize().split(" ")
binding.tvSize.text = split[0]
binding.tvUnit.text = split[1]
setCleanUpUi(0)
}
if (showInterAdSp()) {
AdmobInterstitialUtils.showInterstitialAd(this) {
cleanFile()
}
} else {
cleanFile()
}
}
}
}
}
private fun cleanFile() {
val files = screenShotAdapter.getSelectData()
lifecycleScope.launch(Dispatchers.IO) {
async {
files.forEach { screenFile ->
runCatching {
val file = screenFile.file
if (file.exists()) file.delete()
}
}
}.await()
launch(Dispatchers.Main) {
binding.tvClean.text = "CLEAN"
screenShotAdapter.removeData(files)
val split = screenShotAdapter.getAllData().sumOf { it.file.length() }.toFormatSize().split(" ")
binding.tvSize.text = split[0]
binding.tvUnit.text = split[1]
setCleanUpUi(0)
}
}
}
private fun getScreenshotBean(): ArrayList<ScreenshotBean> {
......
......@@ -13,6 +13,7 @@ import com.base.datarecovery.ads.AdmobEvent.pullAd
import com.base.datarecovery.ads.AdmobEvent.showAd
import com.base.datarecovery.help.BaseApplication
import com.base.datarecovery.help.ConfigHelper
import com.base.datarecovery.utils.AppPreferences
import com.base.datarecovery.utils.EventUtils
import com.base.datarecovery.view.CustomDialog
import com.google.android.gms.ads.AdError
......@@ -38,12 +39,19 @@ object AdmobInterstitialUtils {
return System.currentTimeMillis() - interLoadTime > 1000 * 60 * 60
}
fun showInterAdSp(): Boolean {
val isDeleteInterAd = AppPreferences.getInstance().getString("isDeleteInterAd", "0").toInt()
//1要看插屏 0不看
return isDeleteInterAd == 1
}
fun showInterstitialAd(
activity: Activity,
isReLoadAd: Boolean = false,
isShowDialog: Boolean = true,
onHidden: (() -> Unit)? = null
) {
if (activity.isFinishing || activity.isDestroyed) {
return
}
......
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