Skip to content

Instantly share code, notes, and snippets.

@BuiVanNam
Created December 2, 2020 15:30
Show Gist options
  • Save BuiVanNam/cb601cdfc145c9d3d8843d77c4b2ce37 to your computer and use it in GitHub Desktop.
Save BuiVanNam/cb601cdfc145c9d3d8843d77c4b2ce37 to your computer and use it in GitHub Desktop.
class BookAdapter : RecyclerView.Adapter<BookViewHolder() {
private var mEventItemBook: EventItemBook? = null
fun setListenerEventItemBook(eventItemBook: EventItemBook) {
this.mEventItemBook = eventItemBook
}
///////
inner class BookViewHolder(): RecyclerView.ViewHolder(itemView) {
val mIconFavorite= itemView.findViewById(R.id.favorite)
init {
mIconFavorite.setOnClickListener {
if (isFavorite) {
mEventItemBook?.removeFavoriteBook(mBook)
} else {
mEventItemBook?.addFavoriteBook(mBook)
}
}
itemView.setOnClickListener {
mEventItemBook?.actionOpenBook(mBook)
}
itemView.setOnLongClickListener {
mEventItemBook?.openMenuBook(mBook)
false
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment