Grid Layout Manager Scroll Load More

private GridLayoutManager mLayoutManager;
int pastVisiblesItems, visibleItemCount, totalItemCount;
mLayoutManager = new GridLayoutManager(getActivity(), 3);
mList.addOnScrollListener(new RecyclerView.OnScrollListener() {
 @Override
 public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
 super.onScrollStateChanged(recyclerView, newState);
 }
@Override
 public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
 super.onScrolled(recyclerView, dx, dy);
 if (dy > 0) { // scroll down
 visibleItemCount = mLayoutManager.getChildCount();
 totalItemCount = mLayoutManager.getItemCount();
 pastVisiblesItems = mLayoutManager.findFirstVisibleItemPosition();

if (isLoadData()) {
 if ((visibleItemCount + pastVisiblesItems) >= totalItemCount) {
// action
 }
 }
 }
 }
 });