My Hexaville
Spead the Word

Android Simple RecyclerView New Features

 Designed by Freepik


Few posts ago I introduced a SimpleRecyclerView library which has a clean API for implementing fetch more listener, default ProgressBar footer while fetching, nothing found text. I think the result was pretty clean and I decided to keep working on this library

What I want today is display initial ProgressBar by default and handling fetch more listener inside NestedScrollView

Initial ProgressBar

I enabled default progress bar, it’s visible until you call SimpleRecyclerView#setDoneFetching() first time. Here’s example of how it works

If you don’t fetch anything from the web, but just setting list data right up – you still need to call setDoneFetching method after adding items to the list

And if you want to disable default ProgressBar – use this attribute

Inside NestedScrollView

Sometimes you’d want to put your RecyclerView inside of NestedScrollView. In cases of there’s other items in the list besides RecyclerView

First tip: add this attribute to NestedScrollView

Without one NestedScrollView won’t match_parent when there’s no items in the list. And will stick to the top of the screen, hence initial ProgressBar is not centered on screen, but on top like in YouTube app

And of course then you’d disable nested scrolling for RecyclerView, because scrolling is kind of snatchy when RecyclerView is inside NestedScrollView

Also there’s an issue with RecyclerView scroll listener, when it’s inside of NestedScrollView, for onFetchMore listener. So you just need to call this method to fix it


So that’s it for now I think, one of the next features I want is seamless integration of different list item layouts. Because I cut the user control over view holder type for the purpose of easy progress footer implementation

You can get the full installation instructions on this library here. Let me know if you like it and find simple and what features you think should be next in the list


About the Author Ihor Klimov

Formerly an Android developer, lately picked up some Flutter. This blog is everything that I find exciting about Android and Flutter development. Stay tuned and hope to see you again!