https://kotlinlang.org logo
#android
Title
# android
q

quver

11/18/2019, 3:21 PM
Hello, guys. does anyone use/love
Android Paging Library
? Personally I think that mostly people wish to get rid of boilerplate code and get simpler solution. And now it looks kinda overhead because you need to write more that just
DiffUtil
+`LoadMorelistener`. Any thoughts about it, does it really worth it?
c

Christophe Smet

11/18/2019, 3:46 PM
Internally we had a simpeler solution, its simpeler but has less features. Their solution covers more cases but I prefer less code.
q

quver

11/18/2019, 3:49 PM
Could you please tell me what features of this library do you use now?
c

Christophe Smet

11/18/2019, 3:51 PM
It just emits the next page. We post it on the rx stream. The activity then refreshes the list with an adapter that has a diffutil impl
q

quver

11/18/2019, 3:52 PM
I see. Because now I don't see a really big reason to use it.
w

wasyl

11/18/2019, 4:07 PM
Same, I implemented it and then migrated away because it was pretty inflexible when it came to things like mapping the resulting list into anything else. To me it’s only worth it for prototyping, when connecting Room directly to the UI, which is not that great of an idea anyway
q

quver

11/18/2019, 4:12 PM
@wasyl Could you please more detailed share what to what you tried to map?
w

wasyl

11/18/2019, 4:15 PM
I have two sources that merge to one list on the screen. For simplicity: a list comes from the API and I want to modify each element to also have some status from local persistence for example. Some items I want to remove from the list based on this local persistence, too
I think at some point
map
was added to the paged list, but no
flatMap
, so my second requirement was difficult to meet
q

quver

11/18/2019, 4:43 PM
Maybe
MediatorLiveData
could be a solution in your case?
w

wasyl

11/18/2019, 4:45 PM
Well I use RxJava and I’ve already solved my problem, but with PagingLibrary it was impossible. Since I was given a
PagedList
which didn’t support flatMapping, no matter how I’d want to merge the data, I wasn’t able to modify the list I was given from the paging library
q

quver

11/18/2019, 4:46 PM
Got it, thank you for the feedback.
Also I think that deal with errors more complicated with paging library.
c

Christophe Smet

11/18/2019, 9:25 PM
If you ask yourself if you really need to use one of the components (that goes for the list of AAC) AND you can write simpeler code. Then I think you know that you don’t need it. All those things are fancy and new, but judge for yourself if they are usefull. Using all the components doesn’t make quality code. I’ve seen a lot of shit code, just cause people refuse to divert from the latest google libs 🤦‍♂️
👍 2
3 Views