Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
HistoryViewHolder
class HistoryViewHolder(view: View, val delegate: Delegate) : BaseViewHolder(view) {
interface Delegate {
fun onItemClicked(history: History)
fun onDeleteHistory(history: History)
}
private lateinit var history: History
private val binding by lazy { DataBindingUtil.bind<ItemHistoryBinding>(view) }
@Throws(Exception::class)
override fun bindData(data: Any) {
if(data is History) {
history = data
drawItemView()
}
}
private fun drawItemView() {
itemView.run {
binding.history = history
binding.executePendingBindings()
item_history_delete.setOnClickListener { delegate.onDeleteHistory(history) }
}
}
override fun onClick(view: View) {
delegate.onItemClicked(history)
}
override fun onLongClick(view: View): Boolean {
return false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.