diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt index 9c86330da..4eb5b7b06 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/MediaActivity.kt @@ -739,7 +739,7 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener { if (viewType == VIEW_TYPE_GRID) { val spanCount = config.mediaColumnCnt val spacing = config.thumbnailSpacing - media_grid.addItemDecoration(GridSpacingItemDecoration(spanCount, spacing, config.scrollHorizontally)) + media_grid.addItemDecoration(GridSpacingItemDecoration(spanCount, spacing, config.scrollHorizontally, config.fileRoundedCorners)) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/GridSpacingItemDecoration.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/GridSpacingItemDecoration.kt index 07aa1cc43..f690443ec 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/GridSpacingItemDecoration.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/GridSpacingItemDecoration.kt @@ -4,23 +4,43 @@ import android.graphics.Rect import android.view.View import androidx.recyclerview.widget.RecyclerView -class GridSpacingItemDecoration(val spanCount: Int, val spacing: Int, val isScrollingHorizontally: Boolean) : RecyclerView.ItemDecoration() { +class GridSpacingItemDecoration(val spanCount: Int, val spacing: Int, val isScrollingHorizontally: Boolean, val addSideSpacing: Boolean) : RecyclerView.ItemDecoration() { override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) { val position = parent.getChildAdapterPosition(view) val column = position % spanCount if (isScrollingHorizontally) { - outRect.top = column * spacing / spanCount - outRect.bottom = spacing - (column + 1) * spacing / spanCount - if (position >= spanCount) { - outRect.left = spacing + if (addSideSpacing) { + outRect.top = spacing - column * spacing / spanCount + outRect.bottom = (column + 1) * spacing / spanCount + outRect.right = spacing + + if (position < spanCount) { + outRect.left = spacing + } + } else { + outRect.top = column * spacing / spanCount + outRect.bottom = spacing - (column + 1) * spacing / spanCount + if (position >= spanCount) { + outRect.left = spacing + } } } else { - outRect.left = column * spacing / spanCount - outRect.right = spacing - (column + 1) * spacing / spanCount - if (position >= spanCount) { - outRect.top = spacing + if (addSideSpacing) { + outRect.left = spacing - column * spacing / spanCount + outRect.right = (column + 1) * spacing / spanCount + outRect.bottom = spacing + + if (position < spanCount) { + outRect.top = spacing + } + } else { + outRect.left = column * spacing / spanCount + outRect.right = spacing - (column + 1) * spacing / spanCount + if (position >= spanCount) { + outRect.top = spacing + } } } }