4

I want to implement endless scrolling with FirebaseRecyclerAdapter. But I don't know how to add more items to my FirebaseRecyclerAdapter.

My adapter initialization code:

mAdapter = new FirebaseRecyclerAdapter<RowStorage, MusicItemHolder>(RowStorage.class,
                R.layout.music_list_element, MusicItemHolder.class, databaseMusicReference) {
            @Override
            protected void populateViewHolder(MusicItemHolder musicHolder,
                                              RowStorage model, int position) {
                musicHolder.setMusicTitle(model.getTitle());
                musicHolder.setArtistName(model.getArtist());
                musicHolder.setMusicIcon(model.getIcon());
            }
};
mRecyclerView.setAdapter(mAdapter);

And my onScrollListener code:

mRecyclerView.addOnScrollListener(new EndlessRecyclerViewScrollListener(mLayoutManager) {
            @Override
            public void onLoadMore(int page, int totalItemsCount) {
                // how can I add (not overwrite) more items here?
            }
});

Is there any any way to add items to existing FirebaseRecyclerAdapter?

Update

Is there any way to return from functions startAt() and endAt() sorted by key range of values? For example:

I have this database:

"globalNode" : {
   "node1" : {
      some values
   }
   "node2" : {
      some values
   }
   "node3" : {
      some values
   }
   "node4" : {
      some values
   }
}

And I want to retrieve at first 1 2 nodes and then 3 and 4 nodes onScroll. How can I do this with functions startAt() and endAt() if nodes in database ordered by key (it's important for my solution) and I want to retrieve them in that order?

Irvin Bridge
  • 303
  • 5
  • 11
  • 1
    Maybe this will help https://github.com/firebase/FirebaseUI-Android/pull/26 – Rohit Navarathna Jul 15 '16 at 17:18
  • 1
    Pagination/endless scroll is currently not a supported feature for FirebaseUI. Unless you are willing to build it yourself, this is not really a question for Stack Overfow but more a +1 on [this Github issue](https://github.com/firebase/FirebaseUI-Android/issues/17) – Frank van Puffelen Jul 15 '16 at 18:22
  • @IrvinBridge have a look at this https://stackoverflow.com/questions/62617913/load-more-items-on-scroll-from-firebase-using-firebaserecycleradapter – Android Jun 28 '20 at 05:25

0 Answers0