0

Android Paging library 3 (3.1.1)

I have implemented the paging3 library for Shortlisting posts. I am showing the shortlisted post in recycler view with paging, and it's working fine.

Now I want to remove a post from the list.

I looked at this issue on git but have not found any issue.

https://github.com/android/architecture-components-samples/issues/281

Help, please

Rahul Bh
  • 123
  • 2
  • 15
  • If you're using room it's easy otherwise you've to submit newlist or manage with notifyItemRemved – Gobu CSG Jul 06 '22 at 10:37
  • @GobuCSG if I submit a new list then it affects my pagination and I tried to manage with notifyItemRemoved but it didn't work. mainListAdapter.snapshot().toMutableList().apply { removeAt(position) } mainListAdapter.notifyItemRemoved(position) – Rahul Bh Jul 06 '22 at 12:03
  • toMutableList Make new list. – Gobu CSG Jul 06 '22 at 12:10
  • Snapshot() is an immutable list how to remove items from that? – Rahul Bh Jul 06 '22 at 12:56
  • Remove then submit the list to diffutill automatically update your view – Gobu CSG Jul 06 '22 at 14:46
  • every item when user unshort any post I need to submit list again ? – Rahul Bh Jul 06 '22 at 14:57
  • https://link.medium.com/IOWt4gULrrb try this – Gobu CSG Jul 06 '22 at 17:00
  • @GobuCSG notifyItemChanged is working for me also but when I try to use notifyItemRemoved it just removes the item and then adds a new one with the same attributes. – Rahul Bh Jul 08 '22 at 05:52
  • mainListAdapter.snapshot().toMutableList().apply { removeAt(position) then submit this list to your livedata } All the changes available in your data class mean Diffutill callback won't affect your changes.. – Gobu CSG Jul 08 '22 at 06:52

0 Answers0