mirror of
https://github.com/SimpleMobileTools/Simple-Gallery.git
synced 2025-02-17 20:40:38 +01:00
update the current portrait photo on click
This commit is contained in:
parent
420a6459e7
commit
687b8697c8
@ -35,6 +35,14 @@ class PortraitPhotosAdapter(val context: Context, val photos: ArrayList<String>,
|
|||||||
|
|
||||||
fun getCurrentPhoto() = currentSelection
|
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) {
|
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||||
fun bindView(photo: String, position: Int): View {
|
fun bindView(photo: String, position: Int): View {
|
||||||
itemView.apply {
|
itemView.apply {
|
||||||
@ -64,6 +72,7 @@ class PortraitPhotosAdapter(val context: Context, val photos: ArrayList<String>,
|
|||||||
if (photo.isNotEmpty()) {
|
if (photo.isNotEmpty()) {
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
itemClick(position, x.toInt())
|
itemClick(position, x.toInt())
|
||||||
|
setCurrentPhoto(position)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setOnClickListener(null)
|
setOnClickListener(null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user