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)