I want to update one item calling asynchronous call to server API inside onBindViewHolder
. I send item at position + position into the callback. Response call arrives in 20 seconds into callback funcion. Into the callback function is returned response and position. Then I call notifyItemChanged(pos, response)
. And inside payload onBindViewHolder
I update item on that position and its View. Problem is that if async request takes 20 seconds and user will scroll quickly throught RecyclerView
it will update wrong item View
because that view at position could be unbound or could be bound to other item from list.
Is there any way how to track which item at which position is unbound to cancel request? I have to update this one info after adapter is created, because if I will do that before, user will not see any recyclerView item for almost 2 minutes till my list is ready. (only this one call is taking so long).