title: pagination in android with recyclerView
body: <p>i am making android app in which i am performing pagination with recyclerView. Basically i have two recylerView in my fragment. I am performing pagination with recylerview addOnScrollListener with one recyclerView. but it is not working fine. when i make this condition </p>
  
  <pre><code>if(dy &gt; 0 ){
  
  }
  </code></pre>
  
  <p>then
  this condition become false nothing implements and when i remove this condition then all pages loaded without scrolling. how i can do this. i want this when i scroll down a recyclerview then next page will be  load.
  here is my code:</p>
  
  <pre><code>private void recyclerPagination() {
      rvRecProduct.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 &gt; 0) {
                  linearLayoutManager = (GridLayoutManager) rvRecProduct.getLayoutManager();
                  visibleItemCount = recyclerView.getChildCount();
                  totalItemCount = linearLayoutManager
                          .getItemCount();
                  firstVisibleItem = linearLayoutManager.findFirstVisibleItemPosition();
                  if (loading) {
                      if (totalItemCount &gt; previousTotal) {
                          previousTotal = totalItemCount;
                          page++;
                          loading = false;
                      }
                  }
                  if (page &lt;= limit) {
                      if (!loading &amp;&amp; (firstVisibleItem + visibleThreshold + visibleItemCount) &gt;= totalItemCount) {
                          loading = true;
                          getPagination();
                          Log.e("PageNO",String.valueOf(page));
                      }
                  }
              }
          }
      });
  }
  </code></pre>