properly handle grid updating if a thumbnail gets deleted
This commit is contained in:
parent
58a9150db0
commit
7f2db07892
|
@ -46,6 +46,7 @@ import kotlinx.android.synthetic.main.activity_media.*
|
|||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||
private val LAST_MEDIA_CHECK_PERIOD = 3000L
|
||||
|
@ -989,6 +990,22 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
|||
finish()
|
||||
}
|
||||
|
||||
override fun updateMediaGridDecoration(media: ArrayList<ThumbnailItem>) {
|
||||
var currentGridPosition = 0
|
||||
media.forEach {
|
||||
if (it is Medium) {
|
||||
it.gridPosition = currentGridPosition++
|
||||
} else if (it is ThumbnailSection) {
|
||||
currentGridPosition = 0
|
||||
}
|
||||
}
|
||||
|
||||
if (media_grid.itemDecorationCount > 0) {
|
||||
val currentGridDecoration = media_grid.getItemDecorationAt(0) as GridSpacingItemDecoration
|
||||
currentGridDecoration.items = media
|
||||
}
|
||||
}
|
||||
|
||||
private fun setAsDefaultFolder() {
|
||||
config.defaultFolder = mPath
|
||||
invalidateOptionsMenu()
|
||||
|
|
|
@ -379,4 +379,7 @@ class SearchActivity : SimpleActivity(), MediaOperationsListener {
|
|||
|
||||
override fun selectedPaths(paths: ArrayList<String>) {
|
||||
}
|
||||
|
||||
override fun updateMediaGridDecoration(media: ArrayList<ThumbnailItem>) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -439,6 +439,7 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: ArrayList<ThumbnailI
|
|||
|
||||
media.removeAll(removeMedia)
|
||||
listener?.tryDeleteFiles(fileDirItems)
|
||||
listener?.updateMediaGridDecoration(media)
|
||||
removeSelectedItems(positions)
|
||||
currentMediaHash = media.hashCode()
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.simplemobiletools.gallery.pro.interfaces
|
||||
|
||||
import com.simplemobiletools.commons.models.FileDirItem
|
||||
import com.simplemobiletools.gallery.pro.models.ThumbnailItem
|
||||
|
||||
interface MediaOperationsListener {
|
||||
fun refreshItems()
|
||||
|
@ -8,4 +9,6 @@ interface MediaOperationsListener {
|
|||
fun tryDeleteFiles(fileDirItems: ArrayList<FileDirItem>)
|
||||
|
||||
fun selectedPaths(paths: ArrayList<String>)
|
||||
|
||||
fun updateMediaGridDecoration(media: ArrayList<ThumbnailItem>)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue