MarkoMilos / Paginate

Library for creating simple pagination functionality upon RecyclerView and AbsListView
Apache License 2.0
1.35k stars 225 forks source link

problem when implementing with swipe refresh layout #24

Closed PhanPirang closed 4 years ago

PhanPirang commented 7 years ago

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 ?

zholmesCG commented 7 years ago

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

kenneth2008 commented 7 years ago

"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.

MarkoMilos commented 4 years ago

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.