I am loading items from API using the Paging 3 library. I would like to add an item to a specific position in the recyclerview.
If I am using normal adapter I would just use
mArrayList.add(position, item);
notifyItemInserted(position);
But I am using the PagingDataAdapter and I have tried this
val newPostResponse = response?.responseBody
homeAdapter.snapshot().items.toMutableList().add(0, newPostResponse)
homeAdapter.notifyItemInserted(0)
I have also tried
val newPostResponse = response?.responseBody
homeAdapter.snapshot().items.toMutableList().add(0, newPostResponse)
homeAdapter.notifyDataSetChanged()
None of these is working. Someone help me know the right way to do it.