Hi, how to remove item at specific position in RecyclerView using paging library 3?
😶 6
m
MarinJuricev
11/16/2021, 12:59 PM
I assume that you expose some kind of onClick listener that’d execute that remove logic.
For instance a lambda which takes the itemId:
(String) -> Unit
Then delegate that action to your ViewModel ( assuming you use MVVM ), and use the
filter
operator the
PagingData<T>
to return a new PagingData without that ID.
Additionally if you use room or any kind of other local persistence, and you get your
Paging<T>
from a local source then just delete that item in the local persistence. ( assuming you expose a observable from the local persistence )
h
haris mehmood
11/16/2021, 1:04 PM
Yes but next time i clicked on item second time but its position is wrong
m
MarinJuricev
11/16/2021, 1:09 PM
How do you keep track of the position, if the 2nd time it doesn’t work that means you have a stale dataset.
Instead of the position try using an ID, but still look into this ☝️
h
haris mehmood
11/17/2021, 4:22 AM
When i refresh list then its create problem with position