Browse Source

GalleryAdapter: cleanup index out of bounds

Álvaro Brey 3 years ago
parent
commit
0767e4fe43

+ 3 - 5
app/src/main/java/com/owncloud/android/ui/adapter/GalleryAdapter.kt

@@ -180,11 +180,9 @@ class GalleryAdapter(
 
     fun getItem(position: Int): OCFile? {
         val itemCoord = getRelativePosition(position)
-        return try {
-            files[itemCoord.section()].files[itemCoord.relativePos()]
-        } catch (e: ArrayIndexOutOfBoundsException) {
-            null
-        }
+        return files
+            .getOrNull(itemCoord.section())?.files
+            ?.getOrNull(itemCoord.relativePos())
     }
 
     override fun isMultiSelect(): Boolean {