I'm currently using the scrollListener to enable endless scroll - you can find my question and Vilen's answer here:
Adding items to Endless Scroll RecyclerView with ProgressBar at bottom
This works wonders when you have the same dataset size each time you activate your adapter when you scroll For example, in Vilen's code, he is increasing the size of the dataset by the same amount, 15, each time he scrolls.
However, in the real world, this is often not the case. You have dissimilar dataset sizes all the time. In my example, I would like to do the following:
I would like to implement a geospatial search so that it returns a list of places closest to me. Now, if I'm sitting in a desert, my REST API call would return the places within 10km of me and this could just be 4 places (the camel hut, the pyramids, the watering hole and the coconut tree).
Populating 4 items in a recyclerview will not make the recyclerview long enough to allow the it to scroll further so that my app will trigger the API call again to find more places closer to me. The next 10km (20km from my current location) could be a town with lots more places to return, but because the recyclerview is not long enough to scroll, the API call is not made.
I have also made a tiny repo to demonstrate that the scroll listener is not triggered when the recyclerview is too short:
https://github.com/Winghin2517/DissimilarDataSetSizeRV.git
How can I get around this problem?
I almost feel like the scrolllistener should be triggered until the recyclerview fills up the screen but how can I determine when the screen will be filled up as there is no callback for recyclerview-fill-up-screen, as far as I know.
I had tried to stop changing the boolean loading
to see that would help but without the boolean checking the status of the load, the progressBar will not necessarily be removed leading to this type of effect: