Created
December 2, 2020 15:30
-
-
Save BuiVanNam/cb601cdfc145c9d3d8843d77c4b2ce37 to your computer and use it in GitHub Desktop.
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 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