Recyclerview Pagination Using Asynctask Making Duplicate Pages?
Solution 1:
You are getting overlapping calls to FetchItemsTask
due to how onScrollStateChanged
works. If you swipe up and let things settle, here is how onScrollStateChanged
is invoked:
onScrollStateChanged: SCROLL_STATE_DRAGGING onScrollStateChanged: SCROLL_STATE_SETTLING onScrollStateChanged: SCROLL_STATE_IDLE
This is what you would expect. If, however, you swipe up and then swipe up again before the view settles, this is what happens:
onScrollStateChanged: SCROLL_STATE_DRAGGING onScrollStateChanged: SCROLL_STATE_SETTLING onScrollStateChanged: SCROLL_STATE_DRAGGING onScrollStateChanged: SCROLL_STATE_SETTLING onScrollStateChanged: SCROLL_STATE_IDLE
This may seem surprising at first, but it makes sense if you think about it.
You are also not doing any checks for the newState
in onScrollStateChanged
.
If you are trying to implement an endless RecyclerView
try searching for "endless recyclerview". There are many good resources on the web.
Post a Comment for "Recyclerview Pagination Using Asynctask Making Duplicate Pages?"