From ca62b62bec5e940bd1f49093d36d25a8e631d249 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 8 Dec 2016 22:46:28 +0100 Subject: [PATCH] add some animations at item deleting --- .../gallery/activities/MediaActivity.kt | 18 +----------------- .../gallery/adapters/MediaAdapter.kt | 12 +++++++++++- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt index 2563d84bf..e7c49630e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/MediaActivity.kt @@ -199,7 +199,6 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener { } override fun deleteFiles(files: ArrayList) { - 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) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt index 80073046e..efbf713fb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt @@ -191,7 +191,17 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, private fun deleteFiles() { val selections = multiSelector.selectedPositions val files = ArrayList(selections.size) - selections.forEach { files.add(File(media[it].path)) } + val removeMedia = ArrayList(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) }