From f7d774a4392f49fb8fb21a837ebb6b28ef4c23cf Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 25 Dec 2016 21:20:55 +0100 Subject: [PATCH] add a helper function for getting the proper view in adapters --- .../gallery/adapters/DirectoryAdapter.kt | 12 ++++++++---- .../gallery/adapters/MediaAdapter.kt | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 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 805434399..9b803b21c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/DirectoryAdapter.kt @@ -42,10 +42,7 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList() fun toggleItemSelection(itemView: View, select: Boolean, pos: Int = -1) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) - itemView.dir_frame.isSelected = select - else - itemView.dir_thumbnail.isSelected = select + getProperView(itemView).isSelected = select if (pos == -1) return @@ -55,6 +52,13 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList, val markedItems = HashSet() fun toggleItemSelection(itemView: View, select: Boolean, pos: Int = -1) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) - itemView.medium_thumbnail_holder.isSelected = select - else - itemView.medium_thumbnail.isSelected = select + getProperView(itemView).isSelected = select if (pos == -1) return @@ -55,6 +52,13 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList, else markedItems.remove(pos) } + + fun getProperView(itemView: View): View { + return if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) + itemView.medium_thumbnail_holder + else + itemView.medium_thumbnail + } } val multiSelectorMode = object : ModalMultiSelectorCallback(multiSelector) {