0

I'm trying to get data from bottom to top (from the last item uploaded to the first item uploaded like Instagram) but I couldn't make this. I searched a lot and found this answer here.

I made it with firebaseRecyclerAdapter and worked fine but with custom Adapter I couldn't do it!

here is the method I used:

@Override
    public ItemsRecyclerView getItem(int pos){
        return super.getItem(getCount() - 1 - pos);
    }
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Did you also try the first solution given in that answer (which svi.data also answered below)? Since that solution only depends on Android's layout mechanism, it seems more fit for a case where you're not using FirebaseUI. – Frank van Puffelen Jun 27 '18 at 13:40
  • What does your DB structure look like and how are you querying/fetching the data? – Parth Bhoiwala Jun 27 '18 at 13:45

1 Answers1

0

What you should be doing is reversing the recyclerview, forget about the method that you used above.

And do this when you set your recycler view:

LinearLayoutManager manager = new LinearLayoutManager(context);
manager.setReverseLayout(true);
manager.setStackFromEnd(true);
recycler_View.setLayoutManager(manager);

Possible solution:

try this:

Maybe try to reverse the list that you pass to your adapter like this:

//your list
List<model> your_list = new ArrayList()<>;

//before you pass it to the adapter do this
Collections.reverse(your_list);

//now your list is reversed, pass it to the adapter
Adapter adapter = new Adapter (your_list,.....,....);
Hasan Bou Taam
  • 4,017
  • 2
  • 12
  • 22