Glimpse: Use itemView in ThumbnailViewHolder
Also set the click listener only once we have the data binded Change-Id: Id74c564f5f1a44f4c44b386b3e1ed57d7f3dc676
This commit is contained in:
parent
cf2046c092
commit
4b0abb7cf4
|
@ -127,27 +127,25 @@ class ThumbnailAdapter(
|
|||
}
|
||||
|
||||
class ThumbnailViewHolder(
|
||||
private val view: View,
|
||||
view: View,
|
||||
private val onItemSelected: (media: Media, position: Int) -> Unit,
|
||||
) : RecyclerView.ViewHolder(view) {
|
||||
// Views
|
||||
private val videoOverlayImageView =
|
||||
view.findViewById<ImageView>(R.id.videoOverlayImageView)!!
|
||||
private val thumbnailImageView = view.findViewById<ImageView>(R.id.thumbnailImageView)!!
|
||||
itemView.findViewById<ImageView>(R.id.videoOverlayImageView)!!
|
||||
private val thumbnailImageView = itemView.findViewById<ImageView>(R.id.thumbnailImageView)!!
|
||||
|
||||
private lateinit var media: Media
|
||||
private var position = -1
|
||||
|
||||
init {
|
||||
view.setOnClickListener {
|
||||
onItemSelected(media, position)
|
||||
}
|
||||
}
|
||||
|
||||
fun bind(media: Media, position: Int) {
|
||||
this.media = media
|
||||
this.position = position
|
||||
|
||||
itemView.setOnClickListener {
|
||||
onItemSelected(media, position)
|
||||
}
|
||||
|
||||
thumbnailImageView.load(media.externalContentUri) {
|
||||
memoryCacheKey("thumbnail_${media.id}")
|
||||
size(DisplayAwareGridLayoutManager.MAX_THUMBNAIL_SIZE)
|
||||
|
|
Loading…
Reference in New Issue