HistoryViewHolder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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