From 146cb1a052df9acb09412195d0f3c70edbc22250 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 18 Jan 2021 23:25:22 +0100 Subject: [PATCH] add a null check at grid spacing decorator --- .../gallery/pro/helpers/GridSpacingItemDecoration.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 d9150bd1b..d6d0f7ca7 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 @@ -11,7 +11,7 @@ class GridSpacingItemDecoration(val spanCount: Int, val spacing: Int, val isScro override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) { val position = parent.getChildAdapterPosition(view) - val medium = items[position] as? Medium ?: return + val medium = items.getOrNull(position) as? Medium ?: return val gridPositionToUse = if (useGridPosition) medium.gridPosition else position val column = gridPositionToUse % spanCount