Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with endless scrolling and LOAD_MORE_RESET delay #184

Closed
borisdamato opened this issue Oct 5, 2016 · 6 comments
Closed

Problem with endless scrolling and LOAD_MORE_RESET delay #184

borisdamato opened this issue Oct 5, 2016 · 6 comments

Comments

@borisdamato
Copy link
Contributor

Working with the endless scrolling feature and items limit per page in server replies, I found out that if the limit is small enough for whatever reason, the adapter loads just the first page (other than the initial one, so 2 pages).

This happens because the adapter's onLoadMoreComplete method sends the LOAD_MORE_RESET message to the handler with a delay of 200L (not editable) and before this delay has passed, the viewholder calls the adapter's onLoadMore but finds the mLoading boolean to be true (because the handler is in charge of setting it to false upon receiving the LOAD_MORE_RESET message) and does nothing.

At this point it's unable to re-trigger the onLoadMore method because there are few elements in the list for each pag so the recyclerview is not scrollable, the elements can't be recycled and the built-in onBindViewHolder method (which calls the adapter's onLoadMore) can't be re-executed when the delay of the LOAD_MORE_RESET has passed.

I know this can be tricky to read but hope everything is clear. If something is not, please ask.

Is this actually a bug or am mis-implementing something?

@davideas

@davideas
Copy link
Owner

davideas commented Oct 5, 2016

@Aselox, I get your point, so it's because the RV can't be scrolled due to few elements? Indeed, if 2 bindings are executed in less than 200ms, you loose the chain.

But how many items the first load more processes?
The response that generates the items, it not supposed to generate few items in the first load more, it means the pagination is too short, you should load/receive more items, if you have them in the queue, I think.
I don't see the reason to call a remote service 2 or more times for few elements, you should receive enough elements with 1 call only, if there are no elements left it means "no more to load".

On the other hand, I need to think a different solution to reset the flag.

@davideas
Copy link
Owner

davideas commented Oct 5, 2016

Maybe I can remove the delay. It might work anyway, but I'm not sure.
I can try to reset the loading flag immediately, at the end of onLoadMoreComplete(), and see what happens.

@borisdamato
Copy link
Contributor Author

borisdamato commented Oct 5, 2016

@davideas yes, I agree that the server response should not return few items (i reduced the server pagination limit on purpose to test this case) but I think we shoud not rely on the fact that each page should contain enough items that, once rendeded on screen, will make the recyclerview scrollable.

Take the case of a tablet with hidpi. The vertical "space" wil be more that the one on a regular smartphone and if 2 pages fit on its screen, the endless scroll is broken. The current solution is not scalable.

@borisdamato
Copy link
Contributor Author

@davideas yes, I would try that too. Why is there a delay to that message?

@davideas davideas added the bug label Oct 6, 2016
@davideas
Copy link
Owner

davideas commented Oct 6, 2016

@Aselox, I removed the delay, but I had to modify the code in more points. I will commit in rc1 branch and i will create a SNAPSHOT this evening or tomorrow evening.
Now, the loading more automatically fills the screen even one by one, until it's full or no load more, then you need to scroll down to trigger again the listener.

@davideas
Copy link
Owner

davideas commented Nov 28, 2016

@borisdamato, please be aware that, Endless Scrolling is going to be changed very soon. In order to support the new features and a better logic, the behaviors and callbacks methods will be refactored.

Please check issue #233 for the latest developments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants