mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 14:37:59 +01:00
update media thumbnails grid decoration only when needed
This commit is contained in:
parent
159588a4d1
commit
b8e63ae74e
1 changed files with 14 additions and 6 deletions
|
@ -742,17 +742,25 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleGridSpacing() {
|
private fun handleGridSpacing() {
|
||||||
if (media_grid.itemDecorationCount > 0) {
|
|
||||||
media_grid.removeItemDecorationAt(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
val viewType = config.getFolderViewType(if (mShowAll) SHOW_ALL else mPath)
|
val viewType = config.getFolderViewType(if (mShowAll) SHOW_ALL else mPath)
|
||||||
if (viewType == VIEW_TYPE_GRID) {
|
if (viewType == VIEW_TYPE_GRID) {
|
||||||
val spanCount = config.mediaColumnCnt
|
val spanCount = config.mediaColumnCnt
|
||||||
val spacing = config.thumbnailSpacing
|
val spacing = config.thumbnailSpacing
|
||||||
val useGridPosition = mMedia.firstOrNull() is ThumbnailSection
|
val useGridPosition = mMedia.firstOrNull() is ThumbnailSection
|
||||||
val decoration = GridSpacingItemDecoration(spanCount, spacing, config.scrollHorizontally, config.fileRoundedCorners, mMedia, useGridPosition)
|
|
||||||
media_grid.addItemDecoration(decoration)
|
var currentGridDecoration: GridSpacingItemDecoration? = null
|
||||||
|
if (media_grid.itemDecorationCount > 0) {
|
||||||
|
currentGridDecoration = media_grid.getItemDecorationAt(0) as GridSpacingItemDecoration
|
||||||
|
currentGridDecoration.items = mMedia
|
||||||
|
}
|
||||||
|
|
||||||
|
val newGridDecoration = GridSpacingItemDecoration(spanCount, spacing, config.scrollHorizontally, config.fileRoundedCorners, mMedia, useGridPosition)
|
||||||
|
if (currentGridDecoration.toString() != newGridDecoration.toString()) {
|
||||||
|
if (currentGridDecoration != null) {
|
||||||
|
media_grid.removeItemDecoration(currentGridDecoration)
|
||||||
|
}
|
||||||
|
media_grid.addItemDecoration(newGridDecoration)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue