From c58811a8ce9fc98aff992131d4461a33c74c2d57 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 19 Nov 2016 21:01:31 +0100 Subject: [PATCH] update the getSelectedMedia function --- .../gallery/adapters/DirectoryAdapter.kt | 2 +- .../simplemobiletools/gallery/adapters/MediaAdapter.kt | 8 +++----- 2 files changed, 4 insertions(+), 6 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 302528a2e..ec4ef62e1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -193,7 +193,7 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList { val positions = multiSelector.selectedPositions - val paths = HashSet() + val paths = HashSet(positions.size) positions.forEach { paths.add(dirs[it].path) } return paths } 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 a3cd701d8..6dc93891d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/MediaAdapter.kt @@ -112,11 +112,9 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, } private fun getSelectedMedia(): List { - val selections = multiSelector.selectedPositions - val cnt = selections.size - val selectedMedia = (0..cnt - 1) - .map { media[selections[it]] } - + val positions = multiSelector.selectedPositions + val selectedMedia = ArrayList(positions.size) + positions.forEach { selectedMedia.add(media[it]) } return selectedMedia }