swroll



recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
    @Override
    public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
        super.onScrollStateChanged(recyclerView, newState);

       // int lastvisibleitemposition = gaggeredGridLayoutManager.findLastVisibleItemPosition();        int lastvisibleitemposition =9;// gaggeredGridLayoutManager.getChildCount();        int[] firstVisibleItems = gaggeredGridLayoutManager.findFirstVisibleItemPositions(null);
        if (lastvisibleitemposition == homeAdapter.getItemCount() - 1) {

            if (!loading && !isLastPage) {

                loading = true;
                page_no =page_no+1;
                gethomeData();
               // fetchData((++pageCount));                // Increment the pagecount everytime we scroll to fetch data from the next page                // make loading = false once the data is loaded                // call mAdapter.notifyDataSetChanged() to refresh the Adapter and Layout                homeAdapter.notifyDataSetChanged();
                //AdapterStaggreGrid.itemList.clear();            }


        }
    }
});

8888888888888888888888888888888

private SwipeRefreshLayout swipeRefreshLayout;
private int offSet = 0;

swipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_layout);
swipeRefreshLayout.setOnRefreshListener(this);

/** * Showing Swipe Refresh animation on activity create * As animation won't start on onCreate, post runnable is used */swipeRefreshLayout.post(new Runnable() {
                            @Override                            public void run() {
                                swipeRefreshLayout.setRefreshing(true);

                                gethomeData();
                            }
                        }
);

@Overridepublic void onRefresh() {
   // page_no =page_no+1;    gethomeData();
}
Share:

No comments:

Post a Comment

Powered by Blogger.

Recent Posts

Unordered List

  • Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
  • Aliquam tincidunt mauris eu risus.
  • Vestibulum auctor dapibus neque.

Theme Support

Need our help to upload or customize this blogger template? Contact me with details about the theme customization you need.