MarkoMilos / Paginate

Library for creating simple pagination functionality upon RecyclerView and AbsListView

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

problem when implementing with swipe refresh layout

PhanPirang opened this issue · comments

Hello, thanks for your helpful library, anyway I have some problem when i implemented swipe refresh layout with your library. My code is that when refresh call back execute, I request to REST API to retrieve data as Pagination, but recyclerview not scroll to first item. Do you have any idea about it ?

In your onRefresh, try something like this:
mRecyclerView.scrollToPosition(0);

"mRecyclerView.scrollToPosition(0);"
This is not working. Even before of after the adapter data list updated.
The only way to be success, is clear all of the data before initial Paginate again, after an pull to refresh action.

The con is, the UX is very bad.

I think the key is, we need a function to tell the Paginate reload data, force to do. with out remove data, only change data.

I'm afraid that I don't understand your question.

If you want to swap data in the adapter you can do so by replacing the backing list (or any other structure that you might have) and call notifyDataSetChanged(). This will "scroll to the top" aka start rendering from the first item in the adapter. This is expected behavior and has nothing to do with this library.

However, if you want to scroll to a certain item position in the list you can write that code as well just like you would if you are not using this library.

I'm closing this issue for now. Let me know if I'm missing something here and reopen the issue with code/snippet example.