From b05919f7ec04ecc03644183ede1ef80b06d7695c Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 1 Jul 2018 11:40:42 +0200 Subject: [PATCH] fix a crash at getting selected media --- .../com/simplemobiletools/gallery/adapters/MediaAdapter.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 0bb214d3e..860316b9b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt @@ -331,7 +331,9 @@ class MediaAdapter(activity: BaseSimpleActivity, var media: MutableList { val selectedMedia = ArrayList(selectedPositions.size) selectedPositions.forEach { - selectedMedia.add(media[it] as Medium) + (media.getOrNull(it) as? Medium)?.apply { + selectedMedia.add(this) + } } return selectedMedia }