I have a RecyclerView.ViewHolder implementation in my app and I wanted a reference to the adapter which bound this view holder. As per the docs, I see a getBindingAdapter() in the RecyclerView.ViewHolder which returns a reference to the adapter. However, when I do this.getBindingAdapter(), I get a compile error saying Unresolved reference: getBindingAdapter. this in the above code references a direct sub-class of RecyclerView.ViewHolder. I'm not sure what did I do wrong?
class VideoViewHolder private constructor(private val binding: WidgetVideoViewBinding) :
RecyclerView.ViewHolder(binding.root) {
// Other methods here...
override fun checkIfValid(video: Video) {
this.getBindingAdapter() // Compile error here
}
companion object {
fun from(parent: ViewGroup): VideoViewHolder {
val inflater = LayoutInflater.from(parent.context)
return VideoViewHolder(WidgetVideoViewBinding.inflate(inflater, parent, false))
}
}
}