0

I need a endless recyclerview to top, like messager apps.

So I add:

final LinearLayoutManager layoutManager = new LinearLayoutManager(this);
layoutManager.setStackFromEnd(true);

to start my list in the end.

I add the new values on top:

listL.add(0, PostObj);

but I can't read the first position on my recyclerview.

findFirstVisibleItemPosition is not getting the first item

   private boolean isFirstItemDisplaying(RecyclerView recyclerView) {
        if (recyclerView.getAdapter().getItemCount() != 0) {
            int firstVisibleItemPosition = ((LinearLayoutManager) recyclerView.getLayoutManager()).findFirstVisibleItemPosition();
            if (firstVisibleItemPosition != RecyclerView.NO_POSITION
                    && firstVisibleItemPosition == recyclerView.getAdapter().getItemCount() - 1)
                return true;
        }
        return false;
}

I changed it from my old code that works in a endless recyclerview scroll to bottom. Maybe I miss something?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Gabriela Dias
  • 349
  • 2
  • 12

1 Answers1

0

I have answered a question about same concern.

Please refer EndlessScrollListener