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>) {
|
override fun deleteFiles(files: ArrayList<File>) {
|
||||||
var deletedCnt = 0
|
|
||||||
files.filter { it.exists() && it.isImageVideoGif() }
|
files.filter { it.exists() && it.isImageVideoGif() }
|
||||||
.forEach {
|
.forEach {
|
||||||
if (needsStupidWritePermissions(it.absolutePath)) {
|
if (needsStupidWritePermissions(it.absolutePath)) {
|
||||||
|
@ -216,27 +215,12 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
it.delete()
|
it.delete()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deleteFromMediaStore(it))
|
deleteFromMediaStore(it)
|
||||||
deletedCnt++
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deletedCnt == files.size) {
|
|
||||||
updateMediaView()
|
|
||||||
} else {
|
|
||||||
scanFiles(files) {
|
|
||||||
updateMediaView()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun updateMediaView() {
|
|
||||||
if (mMedia.isEmpty()) {
|
if (mMedia.isEmpty()) {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isDirEmpty()) {
|
|
||||||
getMedia()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isSetWallpaperIntent() = intent.getBooleanExtra(SET_WALLPAPER_INTENT, false)
|
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() {
|
private fun deleteFiles() {
|
||||||
val selections = multiSelector.selectedPositions
|
val selections = multiSelector.selectedPositions
|
||||||
val files = ArrayList<File>(selections.size)
|
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)
|
listener?.deleteFiles(files)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue