add some animations at item deleting

This commit is contained in:
tibbi 2016-12-08 22:46:28 +01:00
parent 7fe6d616c0
commit ca62b62bec
2 changed files with 12 additions and 18 deletions

View file

@ -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)

View file

@ -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)
}