lucasr / twoway-view

[DEPRECATED] RecyclerView made simple
5.23k stars 1.02k forks source link

Endless scrolling feature #241

Closed pablobaldez closed 8 years ago

pablobaldez commented 8 years ago

There is anyway to implement the endless scrolling feature, when any listener would load more itens when the user scroll its list to the end?

With linear LinearLayoutManager I'm used to use the findFirstVisibleItemPosition() method to help me in this implementation, but this method doesn't exists in yours LayoutManager.

How can i do this now?

bemusementpark commented 8 years ago

either in your adapter when you getView the last view, or in your RecyclerView when you've scrolled to/near the bottom.

pablobaldez commented 8 years ago

ok but how can i find the first visible position? where is this method or something like this?

KoMinkyu commented 8 years ago

I implemented like this.

if (twoWayView.getLastVisiblePosition() < twoWayView.getAdapter().getItemCount() - 1) {
    // load next page
}
pablobaldez commented 8 years ago

nice! thank you

summers314 commented 7 years ago

@KoMinkyu Another solution is mentioned here. Which one is better?

https://github.com/lucasr/twoway-view/issues/49

KoMinkyu commented 7 years ago

@summers314 that solution makes performance issue. We have to avoid calling notifyDataSetChanged() with RecyclerView, specially in onScrolled(). But making loading state can help us to create more clear HTTP requests when scrolling.