mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
refresh media thumbnails if only the grouping changes
This commit is contained in:
parent
2a23632333
commit
f47190b9e1
1 changed files with 8 additions and 5 deletions
|
@ -39,6 +39,7 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Medium>,
|
|||
private var loadImageInstantly = false
|
||||
private var delayHandler = Handler(Looper.getMainLooper())
|
||||
private var currentMediaHash = media.hashCode()
|
||||
private var currentGrouping = GROUP_BY_NONE
|
||||
private val hasOTGConnected = activity.hasOTGConnected()
|
||||
private var mediumGroups = LinkedHashMap<String, ArrayList<Medium>>()
|
||||
|
||||
|
@ -291,7 +292,7 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Medium>,
|
|||
}
|
||||
|
||||
fun updateMedia(newMedia: ArrayList<Medium>) {
|
||||
if (newMedia.hashCode() != currentMediaHash) {
|
||||
if (newMedia.hashCode() != currentMediaHash || currentGrouping != getCurrentFolderGrouping()) {
|
||||
currentMediaHash = newMedia.hashCode()
|
||||
Handler().postDelayed({
|
||||
media = newMedia
|
||||
|
@ -333,20 +334,20 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Medium>,
|
|||
}
|
||||
|
||||
private fun groupMedia() {
|
||||
val grouping = activity.config.getFolderGrouping(path)
|
||||
if (grouping and GROUP_BY_NONE != 0) {
|
||||
currentGrouping = getCurrentFolderGrouping()
|
||||
if (currentGrouping and GROUP_BY_NONE != 0) {
|
||||
return
|
||||
}
|
||||
|
||||
media.forEach {
|
||||
val key = it.getGroupingKey(grouping)
|
||||
val key = it.getGroupingKey(currentGrouping)
|
||||
if (!mediumGroups.containsKey(key)) {
|
||||
mediumGroups[key] = ArrayList()
|
||||
}
|
||||
mediumGroups[key]!!.add(it)
|
||||
}
|
||||
|
||||
val sortDescending = grouping and GROUP_DESCENDING != 0
|
||||
val sortDescending = currentGrouping and GROUP_DESCENDING != 0
|
||||
val sorted = mediumGroups.toSortedMap(if (sortDescending) compareByDescending { it } else compareBy { it })
|
||||
mediumGroups.clear()
|
||||
sorted.forEach { key, value ->
|
||||
|
@ -354,6 +355,8 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList<Medium>,
|
|||
}
|
||||
}
|
||||
|
||||
private fun getCurrentFolderGrouping() = activity.config.getFolderGrouping(path)
|
||||
|
||||
private fun setupView(view: View, medium: Medium) {
|
||||
view.apply {
|
||||
play_outline.beVisibleIf(medium.isVideo())
|
||||
|
|
Loading…
Reference in a new issue