From 687b8697c8c701fa36eee1c6d65de75a947d008c Mon Sep 17 00:00:00 2001 From: tibbi Date: Wed, 2 Oct 2019 19:53:12 +0200 Subject: [PATCH] update the current portrait photo on click --- .../gallery/pro/adapters/PortraitPhotosAdapter.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/PortraitPhotosAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/PortraitPhotosAdapter.kt index aa4666cbf..829c9d341 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/PortraitPhotosAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/PortraitPhotosAdapter.kt @@ -35,6 +35,14 @@ class PortraitPhotosAdapter(val context: Context, val photos: ArrayList, fun getCurrentPhoto() = currentSelection + private fun setCurrentPhoto(position: Int) { + val newPhoto = photos.getOrNull(position) ?: return + if (currentSelection != newPhoto) { + currentSelection = newPhoto + notifyDataSetChanged() + } + } + inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) { fun bindView(photo: String, position: Int): View { itemView.apply { @@ -64,6 +72,7 @@ class PortraitPhotosAdapter(val context: Context, val photos: ArrayList, if (photo.isNotEmpty()) { setOnClickListener { itemClick(position, x.toInt()) + setCurrentPhoto(position) } } else { setOnClickListener(null)