Skip to content

Instantly share code, notes, and snippets.

@BuiVanNam
Created December 2, 2020 15:31
Show Gist options
  • Save BuiVanNam/2695b8e35ad5a234d2fbbf6c4f5fd4e5 to your computer and use it in GitHub Desktop.
Save BuiVanNam/2695b8e35ad5a234d2fbbf6c4f5fd4e5 to your computer and use it in GitHub Desktop.
private val mBookAdapter: BookAdapter by lazy {
BookAdapter().apply {
setListenerEventItemBook(object : EventItemBook {
override fun addFavoriteBook(book: Book) {
Log.d("TODO", "addFavoriteBook: ")
}
override fun removeFavoriteBook(book: Book) {
Log.d("TODO", "removeFavoriteBook: ")
}
override fun actionOpenBook(book: Book) {
Log.d("TODO", "actionOpenBook: ")
}
override fun openMenuBook(book: Book) {
Log.d("TODO", "openMenuBook: ")
}
})
}
}
---------setup bind adapter in Activity/Fragment---------
private val mListBook = findViewById(R.id.list_book)
mListBook.run {
layoutManager = LinearLayoutManager(context)
adapter = mBookAdapter
addItemDecoration(DividerItemDecoration(context, VERTICAL))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment