From 6ca5191500e7590071fb6cb18f2d3754f8fb4f0b Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 13 May 2018 21:30:24 +0200 Subject: [PATCH] add some IndexOutOfBoundsException checks at adapters --- .../com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt | 2 +- .../com/simplemobiletools/gallery/adapters/MediaAdapter.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt index 759f35730..e1faec46d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -61,7 +61,7 @@ class DirectoryAdapter(activity: BaseSimpleActivity, var dirs: ArrayList setupView(itemView, dir) } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt index 41a55951c..731a02623 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt @@ -64,7 +64,7 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList, } override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) { - val medium = media[position] + val medium = media.getOrNull(position) ?: return visibleItemPaths.add(medium.path) val view = holder.bindView(medium, !allowMultiplePicks) { itemView, adapterPosition -> setupView(itemView, medium)