mikepenz / FastAdapter

The bullet proof, fast and easy to use adapter library, which minimizes developing time to a fraction...
https://mikepenz.dev
Apache License 2.0
3.85k stars 493 forks source link

EndlessRecyclerOnScrollListener load top #65

Closed brittonjg closed 8 years ago

brittonjg commented 8 years ago

Request for enhancement: With the current EndlessRecyclerOnScrollListenerit is possible to add more items to the bottom of the list. Would it be possible to add a onLoadMoreTop to EndlessRecyclerOnScrollListener, so that we know when the users reaches the threshold at the top of the list?

Rainer-Lang commented 8 years ago

Try a SwipeRefreshLayout http://developer.android.com/intl/es/training/swipe/add-swipe-interface.html

mikepenz commented 8 years ago

@brittonjg you might want to check out the source of the EndlessRecyclerOnScrollListener should be possible to alter it, but would require some time.

If you do it, you can open a PR if you want ;)

brittonjg commented 8 years ago

@Rainer-Lang I am not sure what you mean, I have specifically removed swipe to refresh for this feature. Once the users reaches the top of the list, I am going to add new items above that once they have been retrieved from the server. This is a non standard UI feature.

@mikepenz Not an issue ;) I have completed the change in my project, but I haven't dealt with the current page implementation that you have. I'm not sure it makes much sense when scrolling up the list, because they would be negative, unless I always call it 0 and increase the total number.

I use getAdapterItem which has an ID that I pass to the server to load previous content, but that is totally out of scope of FastAdapter.

Rainer-Lang commented 8 years ago

@brittonjg Then you load previous items from a server when user reaches top?

brittonjg commented 8 years ago

@Rainer-Lang I load a different set of items.

In my case I have a set of game fixtures. The list starts at today's games and scrolls down for future games and up for previous games. So I have the potential to load future games at the bottom of the list and past games when the user reaches the top. Have I explained that better now?

Rainer-Lang commented 8 years ago

@brittonjg Yes this explains it. :) So SwipeToRefresh is no option for you - I see.

Rainer-Lang commented 8 years ago

@FabianTerhorst Maybe you could give a tip?

brittonjg commented 8 years ago

@Rainer-Lang I have it working now as per @mikepenz instructions, it's just the page number count and how you want that to work before I create a PR

Rainer-Lang commented 8 years ago

@brittonjg I'm glad you did it :+1: perfect!

mikepenz commented 8 years ago

@brittonjg you can open the PR with the current implementation and we can have a discussion direct on the code. If you do the branch on a separate branch and create the PR from it, it is really easy to add additional commits to this PR

brittonjg commented 8 years ago

@mikepenz Will do. Maybe something for Monday though :)

jidesoft commented 8 years ago

@brittonjg did you by any chance finding a solution? I have the same requirement as you. Thanks.

FabianTerhorst commented 8 years ago

For this i think we have to create another class with opposite logic.

jidesoft commented 8 years ago

@FabianTerhorst I tried but noticed RecyclerView.OnScrollListener#onScrolled was not called when user tries to scroll beyond the top. I probably can workaround it by adding extra items to both beginning of the list and the end of the list so that onScrolled is always triggered in either case. But just want to ask you guys first to find out if there is already a solution.

FabianTerhorst commented 8 years ago

The new support lib version adds a new fling listener. Haven´t looked into it, but maybe its useful for that.