Commit 7b2118f3 authored by wanglei's avatar wanglei

...ui

parent 12e1fd6c
......@@ -8,6 +8,7 @@ import androidx.core.view.updatePadding
import androidx.lifecycle.lifecycleScope
import com.base.datarecovery.adapter.MediaAdapter
import com.base.datarecovery.adapter.MediaSubAdapter
import com.base.datarecovery.ads.AdmobInterstitialUtils
import com.base.datarecovery.bean.MediaBean
import com.base.datarecovery.bean.MediaTimeBean
import com.base.datarecovery.databinding.ActivityRepeatBinding
......@@ -18,6 +19,7 @@ import com.base.datarecovery.help.MediaStoreHelp.getImageMedia
import com.base.datarecovery.help.PermissionHelp.checkStorePermission
import com.base.datarecovery.help.PermissionHelp.requestStorePermission
import com.base.datarecovery.utils.BarUtils
import com.base.datarecovery.view.DialogViews.showDeletePermanentlyDialog
import com.base.datarecovery.view.DialogViews.showGerPermission
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
......@@ -68,7 +70,7 @@ class RepeatActivity : BaseActivity<ActivityRepeatBinding>() {
override fun initListener() {
onBackPressedDispatcher.addCallback {
finishToMain()
}
binding.flBack.setOnClickListener {
onBackPressedDispatcher.onBackPressed()
......@@ -77,10 +79,24 @@ class RepeatActivity : BaseActivity<ActivityRepeatBinding>() {
binding.ivSelectAll.isSelected = !binding.ivSelectAll.isSelected
mediaAdapter.toggleAllSelect(binding.ivSelectAll.isSelected)
}
binding.tvClean.setOnClickListener {
AdmobInterstitialUtils.showInterstitialAd(this, isShowInterVal = false){
showDeletePermanentlyDialog {
lifecycleScope.launch(Dispatchers.IO) {
mediaAdapter.getSelectData().second.forEach {
runCatching {
val file = File(it.path)
file.delete()
}
}
initData()
}
}
}
}
}
private fun initData() {
binding.progressBar.visibility = View.VISIBLE
lifecycleScope.launch(Dispatchers.IO) {
val list = arrayListOf<MediaBean>()
......
......@@ -17,6 +17,7 @@ import com.base.datarecovery.help.KotlinExt.toFormatSize
import com.base.datarecovery.help.PermissionHelp.checkStorePermission
import com.base.datarecovery.help.PermissionHelp.requestStorePermission
import com.base.datarecovery.utils.BarUtils
import com.base.datarecovery.view.DialogViews.showDeletePermanentlyDialog
import com.base.datarecovery.view.DialogViews.showGerPermission
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
......@@ -90,7 +91,7 @@ class ScreenShotActivity : BaseActivity<ActivityScreenShotBinding>() {
onBackPressedDispatcher.onBackPressed()
}
onBackPressedDispatcher.addCallback {
AdmobInterstitialUtils.showInterstitialAd(this@ScreenShotActivity) {
AdmobInterstitialUtils.showInterstitialAd(this@ScreenShotActivity, isShowInterVal = false) {
finishToMain()
}
}
......@@ -104,18 +105,20 @@ class ScreenShotActivity : BaseActivity<ActivityScreenShotBinding>() {
}
binding.tvClean.setOnClickListener {
val files = screenShotAdapter.getSelectData()
AdmobInterstitialUtils.showInterstitialAd(this) {
lifecycleScope.launch(Dispatchers.IO) {
async {
files.forEach { screenFile ->
runCatching {
val file = screenFile.file
if (file.exists()) file.delete()
AdmobInterstitialUtils.showInterstitialAd(this, isShowInterVal = false) {
showDeletePermanentlyDialog {
lifecycleScope.launch(Dispatchers.IO) {
async {
files.forEach { screenFile ->
runCatching {
val file = screenFile.file
if (file.exists()) file.delete()
}
}
}.await()
launch(Dispatchers.Main) {
screenShotAdapter.removeData(files)
}
}.await()
launch(Dispatchers.Main) {
screenShotAdapter.removeData(files)
}
}
}
......
......@@ -85,7 +85,7 @@ class CleanJunkActivity : BaseActivity<ActivityLayoutCleanJunkBinding>() {
}
onBackPressedDispatcher.addCallback(object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
AdmobInterstitialUtils.showInterstitialAd(this@CleanJunkActivity) {
AdmobInterstitialUtils.showInterstitialAd(this@CleanJunkActivity, isShowInterVal = false) {
finishToMain()
}
}
......
......@@ -71,7 +71,7 @@ class MediaAdapter(private val clickAction: (Pair<Boolean, List<MediaBean>>) ->
clickAction.invoke(getSelectData())
}
private fun getSelectData(): Pair<Boolean, List<MediaBean>> {
fun getSelectData(): Pair<Boolean, List<MediaBean>> {
val flatMap = beanList.flatMap { it.beans }
val allSelect = flatMap.all { it.isSelect }
val pathList = flatMap.filter { it.isSelect }
......@@ -92,6 +92,7 @@ class MediaAdapter(private val clickAction: (Pair<Boolean, List<MediaBean>>) ->
beanList.clear()
beanList.addAll(list)
notifyDataSetChanged()
clickAction.invoke(getSelectData())
}
}
\ No newline at end of file
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