@Override
  public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
    super.onScrolled(recyclerView, dx, dy);

    // first solution (simple)

    // if (!recyclerView.canScrollVertically(1)) {
    // onScrolledToEnd();
    // }
    // end of first solution

    // second solution
    visibleItemCount = recyclerView.getChildCount();
    totalItemCount = sglm.getItemCount();
    firstVisibleItem = sglm.findFirstVisibleItemPositions(null);

    if (loading) {
      if (totalItemCount > previousTotal) {
        loading = false;
        previousTotal = totalItemCount;
      }
    }
    if (!loading
        && (totalItemCount - visibleItemCount) <= (firstVisibleItem[0] + visibleThreshold)) {

      onLoadMore();

      loading = true;
    }
    // End second solution
  }
 @Override
 public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
   super.onScrollStateChanged(recyclerView, newState);
   switch (newState) {
     case android.widget.AbsListView.OnScrollListener.SCROLL_STATE_IDLE:
       adapter.onResume();
       break;
     case android.widget.AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
       // adapter.pause();
       adapter.onResume();
       break;
     case android.widget.AbsListView.OnScrollListener.SCROLL_STATE_FLING:
       adapter.onPause();
       break;
   }
   if (listener2 != null) listener2.onScrollStateChanged(recyclerView, newState);
 }
Ejemplo n.º 3
0
 public void onScrolled(RecyclerView recyclerView, int i, int i2) {
   super.onScrolled(recyclerView, i, i2);
   if (this.f7834a.f7818f && i2 > this.f7834a.f7819g) {
     this.f7834a.f7818f = false;
     this.f7834a.f7817e.m10328n();
   } else if (!this.f7834a.f7818f && i2 < (-this.f7834a.f7819g)) {
     this.f7834a.f7818f = true;
     this.f7834a.f7817e.m10327m();
   }
 }
  @Override
  public void onScrolled(RecyclerView recyclerView, int dx, int dy) {

    super.onScrolled(recyclerView, dx, dy);
    if (listener2 != null) listener2.onScrolled(recyclerView, dx, dy);
  }