pwittchen / InfiniteScroll

Infinite Scroll (Endless Scrolling) for RecyclerView in Android
Apache License 2.0
189 stars 26 forks source link

does not work with swipe to refresh layout #11

Open sharmaraju352 opened 7 years ago

sharmaraju352 commented 7 years ago

it works great on single use. but when i scroll down and go up again to refresh the contents then recyclerview starts from random index instead of starting from 0th index. while refreshing i am calling the same methods again these are items = createItems(); initRecyclerView();

pwittchen commented 7 years ago

Hi @sharmaraju352,

Thanks for reporting that issue. I'll take a look on that when I have some time.

sharmaraju352 commented 7 years ago

and one more thing..why it needs number_of_items to be in the table of MAX_ITEMS_PER_REQUEST. it crashes if i assign the number which is not in the table.

pwittchen commented 7 years ago

"Max items per request" is a number of items per single "page". The library needs to know how many items it should load on start and when scroll reaches the bottom of the list of currently loaded items.

sharmaraju352 commented 7 years ago

yes i got that.but i am fetching my notifications from server and the number of notifications on the server is unknown initially.i am keeping MAX_ITEMS_PER_REQUEST=20 initially. if i detect that the number of notifications from server is less than MAX_ITEMS_PER_REQUEST then i am assingning the number of notification from server to MAX_ITEMS_PER_REQUEST.it is working flawlessly until this point.but the problem is if i have 21 notifications on my server then it will load first 20 but as soon as i scroll down it crashes.i am not able to change the value of MAX_ITEMS_PER_REQUEST dynamically.i want to assign MAX_ITEMS_PER_REQUEST=no_of_notifications_on_server%MAX_ITEMS_PER_REQUEST;

sharmaraju352 commented 7 years ago

how do i tell adapter about this change

pwittchen commented 7 years ago

It's a separate problem. Please, create another issue for that.

Quick answer:

Now the library is not able to do that.

We can extend the library to allow to set max items per request inside InfiniteScrollListener, but it will reduce code immutability. After that, you can listen to notifications from the server and set max items per request dynamically for the listener whenever you'll receive notification from the server.