Commit 7b2118f3 authored by wanglei's avatar wanglei

...ui

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