Skip to content

Instantly share code, notes, and snippets.

@yogeshpaliyal
Created October 29, 2020 15:57
Embed
What would you like to do?
Universal RecyclerView Adapters Initialize
private val mAdapter by lazy {
UniversalRecyclerAdapter<UserModel>(
R.layout.item_user,
resourceShimmer = R.layout.layout_loading_full_page,
defaultShimmerItems = 1,
mListener = object : BasicListener<UserModel> {
override fun onClick(model: UserModel) {
Toast.makeText(this@LoadingListingActivity, model.name, Toast.LENGTH_SHORT)
.show()
}
})
}
private val mAdapter by lazy {
UniversalRecyclerAdapter<MultiSelectModel>(
R.layout.item_multi_select,
mListener = object : BasicListener<MultiSelectModel> {
override fun onClick(model: MultiSelectModel) {
mViewModel.logData()
}
})
}
private val mAdapter by lazy {
UniversalRecyclerAdapter<UserModel>(
R.layout.item_user,
resourceShimmer = R.layout.item_user_shimmer,
defaultShimmerItems = 5,
loaderFooter = R.layout.item_loading_more,
mListener = object : BasicListener<UserModel> {
override fun onClick(model: UserModel) {
Toast.makeText(this@PaginationListingActivity, model.name, Toast.LENGTH_SHORT)
.show()
}
})
}
private val mAdapter by lazy {
UniversalRecyclerAdapter<UserModel>(
R.layout.item_user, resourceShimmer = R.layout.item_user_shimmer,
defaultShimmerItems = 5,
mListener = object : BasicListener<UserModel> {
override fun onClick(model: UserModel) {
Toast.makeText(this@ShimmerListingActivity, model.name, Toast.LENGTH_SHORT)
.show()
}
})
}
private val mAdapter by lazy {
UniversalRecyclerAdapter<BasicModel>(
R.layout.item_simple,
mListener = object : BasicListener<BasicModel> {
override fun onClick(model: BasicModel) {
Toast.makeText(this@BasicListingActivity, model.name, Toast.LENGTH_SHORT).show()
}
})
}
private val mAdapter by lazy {
UniversalRecyclerAdapter<UserModel>(
R.layout.item_user,
mListener = object : BasicListener<UserModel> {
override fun onClick(model: UserModel) {
Toast.makeText(this@UserListingActivity, model.name, Toast.LENGTH_SHORT).show()
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment