PrettyListView
Because Life is too short for duplicating Recyclerview code, PrettylistView introduce a very simple generic adapter, pagination handling with customized views (Error,loading) and updating via diffUtils.
Enough talking let's see how to use it .
Installation
-
Step 1. Add the JitPack repository to your build file
-
Step 2. Add the dependency
Usage :
- Get your view
- Build your adapter using
-
Make instance of class implementing
MainHolderInterface<T>
to set your adapter specification in .Note : Don't use (-30 , -31) as Item view types constants Because they are already taken for Loading & Error items of pagination
-
Then set your
holderInterface
instance to your adapter builder -
For using pagination
-
Configure your pagination
-
Get your final adapter
-
Set list and pagination calls & callbacks :
setListCallBacks
Used to notify if items count in recycler view changed :
-
setPaginationListener
Used for pagination callbacks : -
Pagination Calls
-
mAdapter.paginatedDataAdded()
used when new paginated data added. -
mAdapter.paginationDone()
used when there is no more items for pagination. -
mAdapter.paginationError()
used to show pagination error item. -
mAdapter.paginationNormalState()
used to hide loading or error pagination item. -
mAdapter.paginationLoading()
used to show pagination loading item.
-
-
You have 3 ways to update your list
-
You can make change to
testListData
returned in themainHolderInstance
then callmAdatper.updateList()
e.g : -
You can use Observable list instead of your list instance and any change happened in it will be updated automatically .
e.g : -
You can use update list with just passing a list from the same type in order not to change your original data in
testListData
. It could be useful for filtering or searching.
e.g:
-