详情删除和批量删除后返回页面继续进行删除或者恢复

This commit is contained in:
litingting 2025-10-17 18:07:02 +08:00
parent 37e894ad47
commit 587636c7a5
20 changed files with 652 additions and 181 deletions

View File

@ -13,13 +13,16 @@ import androidx.fragment.app.DialogFragment
import com.ux.video.file.filerecovery.databinding.DialogRecoveringBinding
abstract class BaseIngDialogFragment(var total: Int, var complete: () -> Unit) : DialogFragment() {
abstract class BaseIngDialogFragment() : DialogFragment() {
var total: Int = 0
var completeListener: ((number: Int) -> Unit)? = null
private lateinit var binding: DialogRecoveringBinding
override fun onStart() {
super.onStart()
dialog?.setCanceledOnTouchOutside(false)
isCancelable = false
dialog?.window?.apply {
setLayout(
ViewGroup.LayoutParams.MATCH_PARENT,
@ -42,7 +45,7 @@ abstract class BaseIngDialogFragment(var total: Int, var complete: () -> Unit) :
object : CountDownTimer(defaultTimer, 200) {
override fun onFinish() {
progressBar.progress = 100
complete.invoke()
completeListener?.invoke(total)
}
override fun onTick(millisUntilFinished: Long) {
@ -75,7 +78,7 @@ abstract class BaseIngDialogFragment(var total: Int, var complete: () -> Unit) :
binding.progressBar.progress = progress
if (progress == 100) {
complete.invoke()
completeListener?.invoke(number)
}
}

View File

@ -24,7 +24,7 @@ abstract class NewBaseAdapter<K>(
items?.let { data.addAll(it) }
notifyDataSetChanged()
}
fun getCurrentData() = data
override fun getItemCount(): Int = data.size
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {

View File

@ -0,0 +1,45 @@
package com.ux.video.file.filerecovery.photo
import android.graphics.Color
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.graphics.drawable.toDrawable
import androidx.fragment.app.DialogFragment
import com.ux.video.file.filerecovery.databinding.DialogDeleteBinding
/**
* 删除确认弹窗
*/
class ConfirmDeleteDialogFragment() : DialogFragment() {
var onClickDelete: (() -> Unit)? = null
private lateinit var binding: DialogDeleteBinding
override fun onStart() {
super.onStart()
dialog?.window?.apply {
setLayout(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
)
setBackgroundDrawable(Color.TRANSPARENT.toDrawable())
}
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = DialogDeleteBinding.inflate(inflater)
binding.run {
tvCancel.setOnClickListener { dismiss() }
tvDelete.setOnClickListener {
onClickDelete?.invoke()
dismiss()
}
}
return binding.root
}
}

View File

@ -8,7 +8,7 @@ import com.ux.video.file.filerecovery.databinding.DialogRecoveringBinding
/**
* 删除中弹窗
*/
class DeletingDialogFragment(total: Int, complete:()-> Unit) : BaseIngDialogFragment(total,complete) {
class DeletingDialogFragment() : BaseIngDialogFragment() {
override fun initUi(binding: DialogRecoveringBinding) {
binding.run {

View File

@ -25,7 +25,7 @@ class PhotoDisplayDateAdapter(
private var allSelected: Boolean? = null
// private var hideThumbnails = false
override fun getViewBinding(parent: ViewGroup): PhotoDisplayDateAdapterBinding =
PhotoDisplayDateAdapterBinding.inflate(
LayoutInflater.from(parent.context),
@ -33,10 +33,7 @@ class PhotoDisplayDateAdapter(
false
)
fun updateHideThumbnails(isChecked: Boolean) {
// hideThumbnails = isChecked
notifyDataSetChanged()
}
/**
* 返回所有嵌套的数据量总数
@ -97,14 +94,6 @@ class PhotoDisplayDateAdapter(
},clickItem
).apply { setData(files) }
// if (hideThumbnails && files.filter { !it.isThumbnail }.isEmpty()) {
// holder.vb.root.isVisible = false
// return
// }else{
// holder.vb.root.isVisible = true
// childAdapter.updateHideThumbnails(hideThumbnails)
// }
allSelected?.let {
childAdapter.setAllSelected(it)
}

View File

@ -43,27 +43,16 @@ class PhotoDisplayDateChildAdapter(
) :
NewBaseAdapter<ResultPhotosFiles>(mContext) {
// private var hideThumbnails: Boolean? = null
//日期组某一天的数据选择状态维护
val dateSelectedMap = mutableSetOf<ResultPhotosFiles>()
//实际显示数据集合(包含隐藏的缩略图)
// val visibleList = data.toMutableSet()
companion object {
private const val TYPE_TWO = 2
private const val TYPE_THREE = 3
private const val TYPE_FOUR = 4
}
// fun getVisibleList() = visibleList
fun updateHideThumbnails(isChecked: Boolean){
// hideThumbnails = isChecked
notifyDataSetChanged()
hideThumbnailsUpdate.invoke(getVisibleCount(dateSelectedMap.toMutableList(),isChecked) == getVisibleCount(data,isChecked))
}
fun setAllSelected(isAdd: Boolean) {
data.forEach {
addOrRemove(it, isAdd)
@ -132,12 +121,12 @@ class PhotoDisplayDateChildAdapter(
when (holder) {
is TwoHolder -> holder.vb.run {
// root.isVisible = !(hideThumbnails == true && item.isThumbnail)
initDateView(rootLayout, imageSelect, textSize, imageThumbnail, item)
}
is ThreeHolder -> holder.vb.run {
// root.isVisible = !(hideThumbnails == true && item.isThumbnail)
initDateView(rootLayout, imageSelect, textSize, imageThumbnail, item)
}
}
@ -218,16 +207,11 @@ class PhotoDisplayDateChildAdapter(
dateSelectedMap.remove(resultPhotosFiles)
}
onSelectedUpdate.invoke(resultPhotosFiles, boolean, dateSelectedMap.size == data.size)
// updateSelected(resultPhotosFiles,boolean)
}
private fun updateSelected(resultPhotosFiles: ResultPhotosFiles,boolean: Boolean){
// hideThumbnails?.let {
// onSelectedUpdate.invoke(resultPhotosFiles, boolean, getVisibleCount(dateSelectedMap.toMutableList(),it) == getVisibleCount(data,it))
// }
}
fun getVisibleCount(list: MutableList<ResultPhotosFiles> = data, hideThumbnails: Boolean): Int {
if(hideThumbnails){
return list.filter { !it.isThumbnail }.size

View File

@ -1,5 +1,6 @@
package com.ux.video.file.filerecovery.photo
import android.content.Intent
import android.graphics.drawable.Drawable
import android.os.Build
import android.os.Bundle
@ -8,6 +9,7 @@ import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.lifecycle.lifecycleScope
import com.bumptech.glide.Glide
import com.bumptech.glide.load.DataSource
import com.bumptech.glide.load.engine.GlideException
@ -20,6 +22,8 @@ import com.ux.video.file.filerecovery.R
import com.ux.video.file.filerecovery.base.BaseActivity
import com.ux.video.file.filerecovery.databinding.ActivityPhotoInfoBinding
import com.ux.video.file.filerecovery.databinding.ActivityPhotoSortingBinding
import com.ux.video.file.filerecovery.photo.PhotoSortingActivity
import com.ux.video.file.filerecovery.success.RecoverySuccessActivity
import com.ux.video.file.filerecovery.utils.Common
import com.ux.video.file.filerecovery.utils.ExtendFunctions.dpToPx
import com.ux.video.file.filerecovery.utils.ScanManager
@ -43,17 +47,17 @@ class PhotoInfoActivity : BaseActivity<ActivityPhotoInfoBinding>() {
@Suppress("DEPRECATION")
intent.getParcelableExtra("MY_KEY")
}
binding.run {
myData?.let {
imageViewBack.setOnClickListener { finish() }
myData?.let { resultPhotosFiles->
tvName.text = it.name
tvPath.text = it.path
tvDate.text = Common.getFormatDate(it.lastModified)
tvResolution.text = it.resolution
tvName.text = resultPhotosFiles.name
tvPath.text = resultPhotosFiles.path
tvDate.text = Common.getFormatDate(resultPhotosFiles.lastModified)
tvResolution.text = resultPhotosFiles.resolution
Glide.with(this@PhotoInfoActivity)
.load(it.targetFile)
.load(resultPhotosFiles.targetFile)
.apply(
RequestOptions()
.transform(
@ -84,9 +88,33 @@ class PhotoInfoActivity : BaseActivity<ActivityPhotoInfoBinding>() {
})
.into(image)
layoutBottom.tvLeft.run {
text = resources.getString(R.string.delete)
setOnClickListener {
RecoverOrDeleteManager.showConfirmDeleteDialog(true,supportFragmentManager,lifecycleScope,setOf(resultPhotosFiles)){count->
complete(count,1)
}
}
}
layoutBottom.tvRight.run {
text = resources.getString(R.string.recover)
setOnClickListener {
RecoverOrDeleteManager.showRecoveringDialog(supportFragmentManager,lifecycleScope,setOf(resultPhotosFiles)){count->
complete(count,0)
}
}
}
}
}
}
private fun complete(number: Int,type: Int) {
finish()
startActivity(Intent(this@PhotoInfoActivity, RecoverySuccessActivity::class.java).apply {
putExtra(RecoverySuccessActivity.KEY_SUCCESS_COUNT,number)
putExtra(RecoverySuccessActivity.KEY_SUCCESS_TYPE,type)
})
}
}

View File

@ -23,12 +23,15 @@ import com.ux.video.file.filerecovery.utils.ExtendFunctions.filterWithinDateRang
import com.ux.video.file.filerecovery.utils.ExtendFunctions.filterWithinDateRangeList
import com.ux.video.file.filerecovery.utils.ExtendFunctions.getParcelableArrayListExtraCompat
import com.ux.video.file.filerecovery.utils.ExtendFunctions.mbToBytes
import com.ux.video.file.filerecovery.utils.ExtendFunctions.removeItem
import com.ux.video.file.filerecovery.utils.GridSpacingItemDecoration
import com.ux.video.file.filerecovery.utils.ScanManager
import com.ux.video.file.filerecovery.utils.ScanManager.copySelectedFilesAsync
import com.ux.video.file.filerecovery.utils.ScanManager.deleteFilesAsync
import com.ux.video.file.filerecovery.utils.ScanRepository
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.util.Date
class PhotoSortingActivity : BaseActivity<ActivityPhotoSortingBinding>() {
@ -61,9 +64,6 @@ class PhotoSortingActivity : BaseActivity<ActivityPhotoSortingBinding>() {
//文件大小排序使用的适配器
private var sizeSortAdapter: PhotoDisplayDateChildAdapter? = null
private var dialogRecovering: RecoveringDialogFragment? = null
private var dialogDeleting: DeletingDialogFragment? = null
private var dialogCustomerDateStart: DatePickerDialogFragment? = null
private var dialogCustomerDateEnd: DatePickerDialogFragment? = null
@ -180,6 +180,7 @@ class PhotoSortingActivity : BaseActivity<ActivityPhotoSortingBinding>() {
resetCurrentDateList(sortByDateReverse)
}
setDateAdapter()
setSingleDelete()
setFilter()
binding.run {
imageViewBack.setOnClickListener { finish() }
@ -219,36 +220,24 @@ class PhotoSortingActivity : BaseActivity<ActivityPhotoSortingBinding>() {
}
tvRecover.setOnClickListener {
showRecoveringDialog()
lifecycleScope.copySelectedFilesAsync(
selectedSet = filterSelectedSetList,
folder = Common.recoveryPhotoDir,
onProgress = { currentCounts: Int, fileName: String, success: Boolean ->
ScanManager.showLog(
"--------恢复图片 ",
"----------${currentCounts} ${fileName}"
)
dialogRecovering?.updateProgress(currentCounts)
}) { counts ->
dialogRecovering?.updateProgress(counts)
ScanManager.showLog("--------恢复图片 ", "----------恢复完成 ${counts}")
// showRecoveringDialog()
RecoverOrDeleteManager.showRecoveringDialog(
supportFragmentManager,
lifecycleScope,
filterSelectedSetList
) { count ->
complete(count, 0)
}
}
tvDelete.setOnClickListener {
showDeletingDialog()
lifecycleScope.deleteFilesAsync(
selectedSet = filterSelectedSetList,
onProgress = { currentCounts: Int, path: String, success: Boolean ->
ScanManager.showLog(
"--------删除图片 ",
"----------${currentCounts} ${path}"
)
dialogDeleting?.updateProgress(currentCounts)
}) { counts ->
dialogDeleting?.updateProgress(counts)
ScanManager.showLog("--------恢复图片 ", "----------恢复完成 ${counts}")
// showConfirmDeleteDialog()
RecoverOrDeleteManager.showConfirmDeleteDialog(
fragmentManager = supportFragmentManager,
scope = lifecycleScope,
selectedSetList = filterSelectedSetList
) { count ->
complete(count, 1)
}
}
@ -277,7 +266,8 @@ class PhotoSortingActivity : BaseActivity<ActivityPhotoSortingBinding>() {
initGetCurrentDateList().let {
val filterThumbnailsAsync =
if (switchHideThumbnails.isChecked) it.filterThumbnailsAsync() else it
val sortByDayNewToOld = Common.getSortByDayNewToOld(filterThumbnailsAsync)
val sortByDayNewToOld =
Common.getSortByDayNewToOld(filterThumbnailsAsync)
dateAdapter?.setData(sortByDayNewToOld)
resetCurrentDateList(sortByDayNewToOld)
}
@ -323,8 +313,28 @@ class PhotoSortingActivity : BaseActivity<ActivityPhotoSortingBinding>() {
//全选按钮 只对当前显示的数据有效
tvSelectAll.setOnClickListener {
it.isSelected = !it.isSelected
when (binding.recyclerView.adapter) {
is PhotoDisplayDateAdapter -> {
dateAdapter?.setAllSelected(it.isSelected)
dateAdapter?.getCurrentData()?.let {
it as List<Pair<String, List<ResultPhotosFiles>>>
if (it.size > 0)
Common.showLog("------------全选按钮 日期-${it.size} ${it[0].second[0].path}")
}
}
is PhotoDisplayDateChildAdapter -> {
sizeSortAdapter?.setAllSelected(it.isSelected)
sizeSortAdapter?.getCurrentData()?.let {
it as List<ResultPhotosFiles>
if (it.size > 0)
Common.showLog("------------全选按钮 大小-${it.size} ${it[0].path}")
}
}
}
}
}
@ -339,14 +349,22 @@ class PhotoSortingActivity : BaseActivity<ActivityPhotoSortingBinding>() {
when (binding.recyclerView.adapter) {
is PhotoDisplayDateAdapter -> {
val adapter = binding.recyclerView.adapter as PhotoDisplayDateAdapter
if (it > 0) {
binding.tvSelectAll.isSelected = it == adapter.getTotalChildCount(false)
} else {
binding.tvSelectAll.isSelected = false
}
}
is PhotoDisplayDateChildAdapter -> {
val adapter = binding.recyclerView.adapter as PhotoDisplayDateChildAdapter
if (it > 0) {
binding.tvSelectAll.isSelected =
it == adapter.itemCount
} else {
binding.tvSelectAll.isSelected = false
}
}
}
}
@ -358,19 +376,29 @@ class PhotoSortingActivity : BaseActivity<ActivityPhotoSortingBinding>() {
currentSizeList = currentSizeList ?: currentDateList?.flatMap { it.second }
return currentSizeList!!
}
private fun resetCurrentSizeList(currentList: List<ResultPhotosFiles>) {
currentSizeList = currentList
currentDateList = null
binding.tvThumbnailCounts.text =
getString(R.string.hide_thumbnails, currentList.filter { it.isThumbnail }.size)
}
private fun initGetCurrentDateList(): List<Pair<String, List<ResultPhotosFiles>>> {
currentDateList = currentDateList ?: Common.getSortByDayNewToOldInit(currentSizeList!!)
return currentDateList!!
}
private fun resetCurrentDateList(currentList: List<Pair<String, List<ResultPhotosFiles>>>) {
currentDateList = currentList
currentSizeList = null
val totalSelectedCount = currentList.sumOf { pair ->
pair.second.filter { it.isThumbnail }.size
}
binding.tvThumbnailCounts.text =
getString(R.string.hide_thumbnails, totalSelectedCount)
}
@ -649,11 +677,9 @@ class PhotoSortingActivity : BaseActivity<ActivityPhotoSortingBinding>() {
}
onPickerChooseListener = { selectedDate ->
filterStartDate = selectedDate
// filterDatePopupWindows?.updateStartEndDate(start = selectedDate)
Log.d("showStartDateDialog", "isFirst=${isNeedSetSelected}--------")
showEndDateDialog(isNeedSetSelected, null)
}
onClickCancel = {
@ -701,34 +727,115 @@ class PhotoSortingActivity : BaseActivity<ActivityPhotoSortingBinding>() {
}
/**
* 显示恢复中弹窗
*/
private fun showRecoveringDialog() {
dialogRecovering =
dialogRecovering ?: RecoveringDialogFragment(filterSelectedSetList.size) {
complete()
}
dialogRecovering?.show(supportFragmentManager, "")
}
/**
* 显示删除中弹窗
*/
private fun showDeletingDialog() {
dialogDeleting = dialogDeleting ?: DeletingDialogFragment(filterSelectedSetList.size) {
complete()
}
dialogDeleting?.show(supportFragmentManager, "")
}
/**
* 删除或者恢复完成
* @param type 0 恢复 1 删除
*/
private fun complete() {
dialogDeleting?.dismiss()
dialogRecovering?.dismiss()
startActivity(Intent(this@PhotoSortingActivity, RecoverySuccessActivity::class.java))
private fun complete(number: Int, type: Int) {
startActivity(Intent(this@PhotoSortingActivity, RecoverySuccessActivity::class.java).apply {
putExtra(RecoverySuccessActivity.KEY_SUCCESS_COUNT, number)
putExtra(RecoverySuccessActivity.KEY_SUCCESS_TYPE, type)
})
if (type == 1) {
lifecycleScope.launch {
val deferredResults = withContext(Dispatchers.Default) {
filterSelectedSetList.let { deletedData ->
//删除后,处理当前实际显示的数据
val newSizeList = currentSizeList?.let {
Common.removeSelectedFromSizeList(
it,
deletedData
)
}
val newDateList = currentDateList?.let {
Common.removeSelectedFromList(it, deletedData)
}
//后续用于筛选的原始数据更新
sortBySizeBigToSmall =
Common.removeSelectedFromSizeList(sortBySizeBigToSmall, deletedData)
sortBySizeSmallToBig =
Common.removeSelectedFromSizeList(sortBySizeSmallToBig, deletedData)
sortByDateReverse =
Common.removeSelectedFromList(sortByDateReverse, deletedData)
sortedByDatePositive =
Common.removeSelectedFromList(sortedByDatePositive, deletedData)
// 一次性返回结果
mapOf(
"sizeList" to newSizeList,
"dateList" to newDateList,
)
}
}
withContext(Dispatchers.Main) {
//选中集合的更新
viewModel.afterDeleted()
deferredResults["sizeList"]?.let { list ->
list as List<ResultPhotosFiles>
Common.showLog("---------更新 sizeList = ${list.size}")
sizeSortAdapter?.setData(list)
resetCurrentSizeList(list)
}
deferredResults["dateList"]?.let { list ->
list as List<Pair<String, List<ResultPhotosFiles>>>
Common.showLog("---------更新 dateList = ${list.size}")
dateAdapter?.setData(list)
resetCurrentDateList(list)
}
}
}
}
}
private fun setSingleDelete() {
RecoverOrDeleteManager.setOnSingleDeleteCompleteListener { deletedData ->
lifecycleScope.launch {
val deferredResults = withContext(Dispatchers.Default) {
//删除后,处理当前实际显示的数据
val newSizeList = currentSizeList?.let {
it.filterNot { it == deletedData }
}
val newDateList = currentDateList?.removeItem(deletedData)
//后续用于筛选的原始数据更新
sortBySizeBigToSmall = sortBySizeBigToSmall.filterNot { it == deletedData }
sortBySizeSmallToBig = sortBySizeSmallToBig.filterNot { it == deletedData }
sortByDateReverse = sortByDateReverse.removeItem(deletedData)
sortedByDatePositive = sortedByDatePositive.removeItem(deletedData)
// 一次性返回结果
mapOf(
"sizeList" to newSizeList,
"dateList" to newDateList,
)
}
withContext(Dispatchers.Main) {
//选中集合的更新
viewModel.afterSingleDeleted(deletedData)
deferredResults["sizeList"]?.let { list ->
list as List<ResultPhotosFiles>
Common.showLog("---------更新 sizeList = ${list.size}")
sizeSortAdapter?.setData(list)
resetCurrentSizeList(list)
}
deferredResults["dateList"]?.let { list ->
list as List<Pair<String, List<ResultPhotosFiles>>>
Common.showLog("---------更新 dateList = ${list.size}")
dateAdapter?.setData(list)
resetCurrentDateList(list)
}
}
}
}
}
}

View File

@ -0,0 +1,114 @@
package com.ux.video.file.filerecovery.photo
import android.app.Activity
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.lifecycleScope
import com.ux.video.file.filerecovery.utils.Common
import com.ux.video.file.filerecovery.utils.ScanManager
import com.ux.video.file.filerecovery.utils.ScanManager.copySelectedFilesAsync
import com.ux.video.file.filerecovery.utils.ScanManager.deleteFilesAsync
import kotlinx.coroutines.CoroutineScope
object RecoverOrDeleteManager {
private var dialogRecovering: RecoveringDialogFragment? = null
private var dialogDeleting: DeletingDialogFragment? = null
private var dialogConfirmDelete: ConfirmDeleteDialogFragment? = null
//详情页面进行删除操作的监听
private var onSingleDeletedCompleteListener: ((ResultPhotosFiles) -> Unit)? = null
fun setOnSingleDeleteCompleteListener(listener: (ResultPhotosFiles) -> Unit) {
onSingleDeletedCompleteListener = listener
}
/**
* 显示恢复中弹窗
*/
fun showRecoveringDialog(
fragmentManager: FragmentManager,
scope: CoroutineScope,
selectedSetList: Set<ResultPhotosFiles>,
onComplete: (number: Int) -> Unit
) {
scope.copySelectedFilesAsync(
selectedSet = selectedSetList,
folder = Common.recoveryPhotoDir,
onProgress = { currentCounts: Int, fileName: String, success: Boolean ->
ScanManager.showLog("--------恢复图片 ", "----------${currentCounts} ${fileName}")
dialogRecovering?.updateProgress(currentCounts)
}) { counts ->
dialogRecovering?.updateProgress(counts)
ScanManager.showLog("--------恢复图片 ", "----------恢复完成 ${counts}")
}
dialogRecovering = dialogRecovering ?: RecoveringDialogFragment()
dialogRecovering?.run {
total = selectedSetList.size
completeListener = { number ->
onComplete(number)
dialogRecovering?.dismiss()
}
show(fragmentManager, "")
}
}
/**
* 显示删除中弹窗
*/
fun showConfirmDeleteDialog(
isInfoDelete: Boolean = false,
fragmentManager: FragmentManager,
scope: CoroutineScope,
selectedSetList: Set<ResultPhotosFiles>,
onComplete: (number: Int) -> Unit
) {
dialogConfirmDelete = dialogConfirmDelete ?: ConfirmDeleteDialogFragment()
dialogConfirmDelete?.run {
onClickDelete = {
showDeletingDialog(
isInfoDelete,
fragmentManager,
scope,
selectedSetList,
onComplete
)
}
show(fragmentManager, "")
}
}
private fun showDeletingDialog(
isInfoDelete: Boolean = false,
fragmentManager: FragmentManager,
scope: CoroutineScope,
selectedSetList: Set<ResultPhotosFiles>,
onComplete: (number: Int) -> Unit
) {
scope.deleteFilesAsync(
selectedSet = selectedSetList,
onProgress = { currentCounts: Int, path: String, success: Boolean ->
ScanManager.showLog("--------删除图片 ", "----------${currentCounts} ${path}")
dialogDeleting?.updateProgress(currentCounts)
}) { counts ->
dialogDeleting?.updateProgress(counts)
ScanManager.showLog("--------恢复图片 ", "----------恢复完成 ${counts}")
}
dialogDeleting = dialogDeleting ?: DeletingDialogFragment()
dialogDeleting?.run {
total = selectedSetList.size
completeListener = { number ->
dialogDeleting?.dismiss()
onComplete(number)
if (isInfoDelete && selectedSetList.size == 1) {
onSingleDeletedCompleteListener?.invoke(selectedSetList.first())
}
}
show(fragmentManager, "")
}
}
}

View File

@ -8,7 +8,7 @@ import com.ux.video.file.filerecovery.databinding.DialogRecoveringBinding
/**
* 恢复中弹窗
*/
class RecoveringDialogFragment(total: Int, complete:()-> Unit) : BaseIngDialogFragment(total,complete) {
class RecoveringDialogFragment() : BaseIngDialogFragment() {
override fun initUi(binding: DialogRecoveringBinding) {
binding.run {
relativeLayout.setBackgroundResource(R.drawable.bg_rectangle_0048fd_top_20)

View File

@ -3,16 +3,19 @@ package com.ux.video.file.filerecovery.success
import android.content.Intent
import android.os.Environment
import android.view.LayoutInflater
import androidx.core.view.isVisible
import androidx.lifecycle.lifecycleScope
import com.ux.video.file.filerecovery.R
import com.ux.video.file.filerecovery.base.BaseActivity
import com.ux.video.file.filerecovery.databinding.ActivityRecoverOrDeletedSuccessBinding
import com.ux.video.file.filerecovery.databinding.ActivityScanningBinding
import com.ux.video.file.filerecovery.main.MainActivity
import com.ux.video.file.filerecovery.main.ScanSelectTypeActivity.Companion.VALUE_AUDIO
import com.ux.video.file.filerecovery.main.ScanSelectTypeActivity.Companion.VALUE_DOCUMENT
import com.ux.video.file.filerecovery.main.ScanSelectTypeActivity.Companion.VALUE_PHOTO
import com.ux.video.file.filerecovery.main.ScanSelectTypeActivity.Companion.VALUE_VIDEO
import com.ux.video.file.filerecovery.result.ScanResultDisplayActivity
import com.ux.video.file.filerecovery.utils.Common
import com.ux.video.file.filerecovery.utils.Common.KEY_SCAN_TYPE
import com.ux.video.file.filerecovery.utils.Common.VALUE_SCAN_TYPE_audio
import com.ux.video.file.filerecovery.utils.Common.VALUE_SCAN_TYPE_deleted_audio
@ -32,17 +35,87 @@ import kotlinx.coroutines.launch
class RecoverySuccessActivity : BaseActivity<ActivityRecoverOrDeletedSuccessBinding>() {
companion object {
// val KEY_SCAN_TYPE = "scan_type"
val KEY_SUCCESS_TYPE = "success_type"
val KEY_SUCCESS_COUNT = "success_count"
}
private var scanType: Int = VALUE_SCAN_TYPE_photo
//0 恢复成功 1 删除成功
private var successType = 0
override fun inflateBinding(inflater: LayoutInflater): ActivityRecoverOrDeletedSuccessBinding =
ActivityRecoverOrDeletedSuccessBinding.inflate(inflater)
override fun initData() {
super.initData()
scanType = intent.getIntExtra(KEY_SCAN_TYPE, VALUE_SCAN_TYPE_photo)
binding.imageViewBack.setOnClickListener { finish() }
successType = intent.getIntExtra(KEY_SUCCESS_TYPE, 0)
val counts = intent.getIntExtra(KEY_SUCCESS_COUNT, 0)
binding.run {
tvNumber.text = counts.toString()
bottomBtnRecoverLayout.run {
tvLeft.text = resources.getString(R.string.text_continue)
tvRight.text = resources.getString(R.string.view)
}
when (scanType) {
VALUE_SCAN_TYPE_photo, VALUE_SCAN_TYPE_deleted_photo -> tvFileType.text =
resources.getString(R.string.describe_photos)
VALUE_SCAN_TYPE_video, VALUE_SCAN_TYPE_deleted_video -> tvFileType.text =
resources.getString(R.string.describe_videos)
VALUE_SCAN_TYPE_audio, VALUE_SCAN_TYPE_deleted_audio -> tvFileType.text =
resources.getString(R.string.describe_audios)
VALUE_SCAN_TYPE_documents, VALUE_SCAN_TYPE_deleted_documents -> tvFileType.text =
resources.getString(R.string.describe_documents)
}
when (successType) {
0 -> {
imageCenter.setImageResource(R.drawable.image_recover_success)
tvNumber.setTextColor(
Common.getColorInt(
this@RecoverySuccessActivity,
R.color.main_text_blue
)
)
bottomBtnRecoverLayout.root.isVisible = true
tvContinue.isVisible = false
tvDescribe.text = resources.getString(R.string.recovered_success)
bottomBtnRecoverLayout.tvLeft.setOnClickListener { finish()}
bottomBtnRecoverLayout.tvRight.setOnClickListener {
//todo 跳转到所有恢复文件页面
}
}
1 -> {
imageCenter.setImageResource(R.drawable.image_deleted_success)
tvNumber.setTextColor(
Common.getColorInt(
this@RecoverySuccessActivity,
R.color.dialog_shape_delete
)
)
bottomBtnRecoverLayout.root.isVisible = false
tvContinue.isVisible = true
tvDescribe.text = resources.getString(R.string.deleted_success)
tvContinue.setOnClickListener { finish()}
}
}
imageViewBack.setOnClickListener { finish() }
imageBackHome.setOnClickListener {
val intent = Intent(this@RecoverySuccessActivity, MainActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP
startActivity(intent)
finish()
}
}
}

View File

@ -8,6 +8,7 @@ import android.util.Log
import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.lifecycle.MutableLiveData
import com.ux.video.file.filerecovery.App
import com.ux.video.file.filerecovery.R
import com.ux.video.file.filerecovery.photo.ResultPhotosFiles
@ -61,7 +62,6 @@ object Common {
}
/**
* 按照日期排序 时间最早的排前面 升序
*
@ -247,6 +247,24 @@ object Common {
}
fun removeSelectedFromList(
list: List<Pair<String, List<ResultPhotosFiles>>>,
selectedLiveData: Set<ResultPhotosFiles>
): List<Pair<String, List<ResultPhotosFiles>>> {
return list.mapNotNull { (key, files) ->
val filtered = files.filterNot { it in selectedLiveData }
if (filtered.isNotEmpty()) key to filtered else null
}
}
fun removeSelectedFromSizeList(
list: List<ResultPhotosFiles>,
selectedLiveData: Set<ResultPhotosFiles>
): List<ResultPhotosFiles> {
return list.filterNot { it in selectedLiveData }
}
fun getFormatDate(time: Long): String {
return dateFormat.format(Date(time))
}

View File

@ -206,4 +206,14 @@ object ExtendFunctions {
}
fun List<Pair<String, List<ResultPhotosFiles>>>.removeItem(
target: ResultPhotosFiles
): List<Pair<String, List<ResultPhotosFiles>>> {
return this.mapNotNull { (key, files) ->
val updatedFiles = files.filterNot { it == target }
if (updatedFiles.isNotEmpty()) key to updatedFiles else null
}
}
}

View File

@ -31,7 +31,6 @@ class ScanRepository : ViewModel() {
val current = _selectedLiveData.value?.toMutableSet() ?: mutableSetOf()
val currentDisplay = _selectedDisplayLiveData.value?.toMutableSet() ?: mutableSetOf()
resultPhotosFiles.let {
if (isAdd) {
current.add(it)
currentDisplay.add(it)
@ -60,6 +59,34 @@ class ScanRepository : ViewModel() {
}
/**
* 删除操作完成过后对选中集合进行更新
*/
fun afterDeleted(){
val selected = _selectedLiveData.value.orEmpty().toMutableSet()
val display = _selectedDisplayLiveData.value.orEmpty()
selected.removeAll(display)
_selectedLiveData.value = selected
_selectedDisplayLiveData.value = emptySet()
}
/**
* 详情页删除完毕移除删除掉的数据
*/
fun afterSingleDeleted(deletedItem:ResultPhotosFiles){
val selected = _selectedLiveData.value.orEmpty().toMutableSet()
val display = _selectedDisplayLiveData.value.orEmpty().toMutableSet()
selected.remove(deletedItem)
display.remove(deletedItem)
_selectedLiveData.value = selected
_selectedDisplayLiveData.value = display
}
fun checkIsSelect(resultPhotosFiles: ResultPhotosFiles): Boolean {
val current = _selectedLiveData.value

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -157,44 +157,13 @@
</LinearLayout>
<include layout="@layout/common_bottom_btn"
<include
android:id="@+id/layout_bottom"
layout="@layout/common_bottom_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent" />
<!-- <com.ux.video.file.filerecovery.utils.CustomTextView-->
<!-- android:id="@+id/tv_delete"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="50dp"-->
<!-- android:layout_marginStart="16dp"-->
<!-- android:layout_marginBottom="21dp"-->
<!-- android:background="@drawable/bg_rectangle_white_left_8"-->
<!-- android:gravity="center"-->
<!-- android:text="@string/delete"-->
<!-- android:textColor="@color/main_text_blue"-->
<!-- android:textSize="16sp"-->
<!-- app:fontType="bold"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- app:layout_constraintHorizontal_weight="1"-->
<!-- app:layout_constraintLeft_toLeftOf="parent"-->
<!-- app:layout_constraintRight_toLeftOf="@id/tv_recover" />-->
<!-- <com.ux.video.file.filerecovery.utils.CustomTextView-->
<!-- android:id="@+id/tv_recover"-->
<!-- android:layout_width="0dp"-->
<!-- android:layout_height="50dp"-->
<!-- android:layout_marginEnd="16dp"-->
<!-- android:layout_marginBottom="21dp"-->
<!-- android:background="@drawable/bg_rectangle_blue_right_8"-->
<!-- android:gravity="center"-->
<!-- android:text="@string/recover"-->
<!-- android:textColor="@color/white"-->
<!-- android:textSize="16sp"-->
<!-- app:fontType="bold"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- app:layout_constraintHorizontal_weight="1"-->
<!-- app:layout_constraintLeft_toRightOf="@id/tv_delete"-->
<!-- app:layout_constraintRight_toRightOf="parent" />-->
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -32,6 +32,14 @@
android:textColor="@color/main_title"
android:textSize="16sp"
app:fontType="bold" />
<ImageView
android:id="@+id/image_back_home"
android:layout_width="44dp"
android:layout_height="44dp"
android:layout_marginEnd="10dp"
android:layout_alignParentEnd="true"
android:src="@drawable/icon_back_home" />
</RelativeLayout>
<ImageView
@ -43,63 +51,82 @@
android:layout_marginTop="60dp"
android:src="@drawable/image_recover_success" />
<com.ux.video.file.filerecovery.utils.CustomTextView
android:id="@+id/tv_number"
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/image_center"
android:layout_centerHorizontal="true"
android:layout_marginTop="46dp"
android:baselineAligned="true"
android:orientation="horizontal">
<com.ux.video.file.filerecovery.utils.CustomTextView
android:id="@+id/tv_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/main_text_blue"
android:textSize="48sp"
app:fontType="bold" />
app:fontType="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="1" />
<com.ux.video.file.filerecovery.utils.CustomTextView
android:id="@+id/tv_file_type"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/tv_number"
android:layout_marginStart="6dp"
android:layout_toEndOf="@id/tv_number"
android:textColor="@color/main_sub_title"
android:textSize="16sp"
app:fontType="bold" />
app:fontType="bold"
app:layout_constraintBaseline_toBaselineOf="@id/tv_number"
app:layout_constraintStart_toEndOf="@id/tv_number"
tools:text="Photo" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.ux.video.file.filerecovery.utils.CustomTextView
android:id="@+id/tv_describe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tv_number"
android:layout_below="@id/constraint"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="@string/recovered_success"
android:textColor="@color/main_sub_title"
android:textSize="20sp"
app:fontType="bold" />
app:fontType="bold"
tools:text="Photo" />
<include
layout="@layout/common_bottom_btn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:id="@+id/bottom_btn_recover_layout"
android:layout_alignParentBottom="true" />
<com.ux.video.file.filerecovery.utils.CustomTextView
android:id="@+id/tv_continue"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginBottom="21dp"
android:layout_marginHorizontal="16dp"
android:layout_alignParentBottom="true"
android:visibility="gone"
android:layout_marginHorizontal="16dp"
android:layout_marginBottom="21dp"
android:background="@drawable/bg_rectangle_fdad00_8"
android:gravity="center"
android:text="@string/text_continue"
android:textColor="@color/white"
android:textSize="16sp"
android:visibility="visible"
app:fontType="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/tv_recover" />
app:layout_constraintRight_toLeftOf="@id/bottom_btn_recover_layout" />
</RelativeLayout>

View File

@ -5,7 +5,7 @@
android:layout_height="wrap_content">
<com.ux.video.file.filerecovery.utils.CustomTextView
android:id="@+id/tv_delete"
android:id="@+id/tv_left"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_marginStart="16dp"
@ -19,10 +19,10 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/tv_recover" />
app:layout_constraintRight_toLeftOf="@id/tv_right" />
<com.ux.video.file.filerecovery.utils.CustomTextView
android:id="@+id/tv_recover"
android:id="@+id/tv_right"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_marginEnd="16dp"
@ -35,6 +35,6 @@
app:fontType="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_weight="1"
app:layout_constraintLeft_toRightOf="@id/tv_delete"
app:layout_constraintLeft_toRightOf="@id/tv_left"
app:layout_constraintRight_toRightOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:background="@drawable/bg_rectangle_white_20"
android:orientation="vertical"
android:paddingHorizontal="20dp"
android:paddingVertical="30dp">
<com.ux.video.file.filerecovery.utils.CustomTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/confirm_delete"
android:textSize="20sp"
app:fontType="bold" />
<com.ux.video.file.filerecovery.utils.CustomTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:lineSpacingExtra="2dp"
android:text="@string/confirm_delete_content"
android:textColor="@color/dialog_permission_content"
android:textSize="14sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="36dp"
android:layout_marginTop="26dp"
android:orientation="horizontal">
<com.ux.video.file.filerecovery.utils.CustomTextView
android:id="@+id/tv_cancel"
android:layout_width="match_parent"
android:layout_height="36dp"
android:layout_weight="1"
android:background="@drawable/bg_dialog_btn_cancel_stoke_8"
android:gravity="center"
android:text="@string/cancel"
android:textColor="@color/main_text_blue"
android:textSize="14sp"
app:fontType="bold" />
<com.ux.video.file.filerecovery.utils.CustomTextView
android:id="@+id/tv_delete"
android:layout_width="match_parent"
android:layout_height="36dp"
android:layout_marginStart="20dp"
android:layout_weight="1"
android:background="@drawable/bg_dialog_btn_allow_solid_8"
android:gravity="center"
android:text="@string/delete"
android:textColor="@color/white"
android:textSize="14sp"
app:fontType="bold" />
</LinearLayout>
</LinearLayout>
</FrameLayout>

View File

@ -75,6 +75,9 @@ wait..</string>
<string name="text_continue">Continue</string>
<string name="start_date">Start date</string>
<string name="end_date">End date</string>
<string name="confirm_delete_content">The file(s) will be completely deleted and cannot be recovered.</string>
<string name="confirm_delete">Confirm delete?</string>
<string name="view">View</string>
<string-array name="filter_date">
<item>All</item>