From 7ad578ec2e13587011e8213aabe03b3d698d607f Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 24 Oct 2017 22:20:50 +0200 Subject: [PATCH] make sure we are selecting existing indexes at media and directory adapters --- .../simplemobiletools/gallery/adapters/DirectoryAdapter.kt | 6 ++++-- .../com/simplemobiletools/gallery/adapters/MediaAdapter.kt | 6 ++++-- 2 files changed, 8 insertions(+), 4 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 8edb4c9b5..7f36dfd26 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -45,8 +45,10 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList, fun toggleItemSelection(select: Boolean, pos: Int) { if (select) { - itemViews[pos]?.medium_check?.background?.setColorFilter(primaryColor, PorterDuff.Mode.SRC_IN) - selectedPositions.add(pos) + if (itemViews[pos] != null) { + itemViews[pos].medium_check?.background?.setColorFilter(primaryColor, PorterDuff.Mode.SRC_IN) + selectedPositions.add(pos) + } } else { selectedPositions.remove(pos) }