Skip to content

Endless Loader

Prashant Solanki edited this page Dec 14, 2015 · 2 revisions

How to implement Endless RecyclerView Adapter?

No need! It's already there in both SnapAdapter and SnapMultiAdapter

####Usage


Just call adapter.setEndlessLoader. It take RecycelerView,int the item visibility threshold, EndlessLoader as parameters.

Override loadMore and onScrolled.

  • loadMore: is called when the threshold limit is reached. It's used to load data to the adapter.
  • onScrolled is the simple OnScrollListener method. You it as you please.
multiAdapter.setEndlessLoader(recyclerView, 5, new EndlessLoader() {
            Handler handler = new Handler();

            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                // Any other OnScrollListener implementation.
            }

            @Override
            public void loadMore(final AbstractSnapMultiAdapter adapter,final int pageNo) {
                Toast.makeText(adapter.getContext(),"Loading Page: "+pageNo,Toast.LENGTH_SHORT).show();
                    //Load More Data from DB or Do a network call.
            }
        });

TADA! It's Done.

Clone this wiki locally