-
-
Notifications
You must be signed in to change notification settings - Fork 3
Getting Started
Yogesh Choudhary Paliyal edited this page Oct 12, 2021
·
1 revision
private val mAdapter by lazy {
UniversalRecyclerAdapter.Builder<UserModel>(
lifecycleOwner = this,
content = UniversalAdapterViewType.Content(resource = R.layout.item_user,
object : BasicListener<UserModel> {
override fun onClick(model: UserModel) {
Toast.makeText(this@LoadingListingActivity, model.name, Toast.LENGTH_SHORT)
.show()
}
}),
loading = UniversalAdapterViewType.Loading(
resourceLoading = R.layout.layout_loading_full_page,
defaultLoadingItems = 1
),
error = UniversalAdapterViewType.Error(errorLayout = R.layout.item_error),
loadingFooter = UniversalAdapterViewType.LoadingFooter(loaderFooter = R.layout.item_loading_more)
).build()
}
binding.recyclerView.adapter = mAdapter.getAdapter()
Note : All the parameters in UniversalRecyclerAdapter.Builder
are optional, use only those you want to use
lifecycleOwner = This will be used to notify your view to update on data change.
content = Your primary list element.
- resource = Element layout id.
- listener = Pass the interface you want to send to your item layout
loading = Your loading list element. (like shimmer or just a loader).
- resourceLoading = loading layout id.
- defaultLoadingItems = Items you want to show while loading.
error = Layout to be shown when Status == Status.ERROR
- errorLayout = error layout id.
- listener = Pass the interface you want to send to your error layout.