add some animations at item deleting
This commit is contained in:
parent
7fe6d616c0
commit
ca62b62bec
2 changed files with 12 additions and 18 deletions
|
@ -199,7 +199,6 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
}
|
||||
|
||||
override fun deleteFiles(files: ArrayList<File>) {
|
||||
var deletedCnt = 0
|
||||
files.filter { it.exists() && it.isImageVideoGif() }
|
||||
.forEach {
|
||||
if (needsStupidWritePermissions(it.absolutePath)) {
|
||||
|
@ -216,27 +215,12 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
it.delete()
|
||||
}
|
||||
|
||||
if (deleteFromMediaStore(it))
|
||||
deletedCnt++
|
||||
deleteFromMediaStore(it)
|
||||
}
|
||||
|
||||
if (deletedCnt == files.size) {
|
||||
updateMediaView()
|
||||
} else {
|
||||
scanFiles(files) {
|
||||
updateMediaView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateMediaView() {
|
||||
if (mMedia.isEmpty()) {
|
||||
finish()
|
||||
}
|
||||
|
||||
if (!isDirEmpty()) {
|
||||
getMedia()
|
||||
}
|
||||
}
|
||||
|
||||
private fun isSetWallpaperIntent() = intent.getBooleanExtra(SET_WALLPAPER_INTENT, false)
|
||||
|
|
|
@ -191,7 +191,17 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
|||
private fun deleteFiles() {
|
||||
val selections = multiSelector.selectedPositions
|
||||
val files = ArrayList<File>(selections.size)
|
||||
selections.forEach { files.add(File(media[it].path)) }
|
||||
val removeMedia = ArrayList<Medium>(selections.size)
|
||||
|
||||
selections.reverse()
|
||||
selections.forEach {
|
||||
val medium = media[it]
|
||||
files.add(File(medium.path))
|
||||
removeMedia.add(medium)
|
||||
notifyItemRemoved(it)
|
||||
}
|
||||
|
||||
media.removeAll(removeMedia)
|
||||
listener?.deleteFiles(files)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue