2

I am using the android paging library to show a list of posts in the recycler view, my data source loads data from inMemory list which I add and remove from it then invalidate the data source to refresh the PagedListAdapter, everything is working well, but the problem is that when I scroll through pages, for example, page #5, and delete some item and call invalidate(), the data source will be re-initialized and will invoke the callbacks again, which re-loads the items in the recycler view, and jump to the first page. The question is: How to refresh the items without jumping to the first page, and stick in the selected position?

Thanks.

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
  • I think it's better to share your code. Maybe you forgot something or you mistaken somewhere :) . Please check this doc maybe it will help you : https://medium.com/@sharmadhiraj.np/android-paging-library-step-by-step-implementation-guide-75417753d9b9 – DINA TAKLIT Nov 30 '18 at 14:29
  • 2
    invalidate will redraw all items in the list, when removing item use notifyItemRemoved() method – Ahmed.ess Nov 30 '18 at 14:31
  • thanks, it is working :) – Mohammad amarneh Nov 30 '18 at 16:19

0 Answers0