@Override
 public void onScrollStateChanged(AbsListView absListView, int scrollState) {
   if ((scrollState == SCROLL_STATE_IDLE || scrollState == SCROLL_STATE_FLING)
       && mRefreshLayout != null
       && mRefreshLayout.shouldHandleAbsListViewLoadingMore(absListView)) {
     mRefreshLayout.beginLoadingMore();
   }
 }
 @Override
 public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
   if ((newState == RecyclerView.SCROLL_STATE_IDLE
           || newState == RecyclerView.SCROLL_STATE_SETTLING)
       && mRefreshLayout != null
       && mRefreshLayout.shouldHandleRecyclerViewLoadingMore(recyclerView)) {
     mRefreshLayout.beginLoadingMore();
   }
 }
Ejemplo n.º 3
0
  /**
   * 处理手指抬起事件
   *
   * @return true表示自己消耗掉该事件,false表示不消耗该事件
   */
  private boolean handleActionUpOrCancel(MotionEvent event) {
    boolean isReturnTrue = false;
    // 如果当前头部刷新控件没有完全隐藏,则需要返回true,自己消耗ACTION_UP事件
    if ((mCustomHeaderView == null || (mCustomHeaderView != null && !mIsCustomHeaderViewScrollable))
        && mWholeHeaderView.getPaddingTop() != mMinWholeHeaderViewPaddingTop) {
      isReturnTrue = true;
    }

    if (mCurrentRefreshStatus == RefreshStatus.PULL_DOWN
        || mCurrentRefreshStatus == RefreshStatus.IDLE) {
      // 处于下拉刷新状态,松手时隐藏下拉刷新控件
      if (mCustomHeaderView == null
          || (mCustomHeaderView != null
              && mWholeHeaderView.getPaddingTop() < 0
              && mWholeHeaderView.getPaddingTop() > mMinWholeHeaderViewPaddingTop)) {
        hiddenRefreshHeaderView();
      }
      mCurrentRefreshStatus = RefreshStatus.IDLE;
      handleRefreshStatusChanged();
    } else if (mCurrentRefreshStatus == RefreshStatus.RELEASE_REFRESH) {
      // 处于松开进入刷新状态,松手时完全显示下拉刷新控件,进入正在刷新状态
      beginRefreshing();
    }

    if (mRefreshDownY == -1) {
      mRefreshDownY = (int) event.getY();
    }
    int diffY = (int) event.getY() - mRefreshDownY;
    if (shouldHandleLoadingMore() && diffY <= 0) {
      // 处理上拉加载更多,需要返回true,自己消耗ACTION_UP事件
      isReturnTrue = true;
      beginLoadingMore();
    }

    mWholeHeaderDownY = -1;
    mRefreshDownY = -1;
    return isReturnTrue;
  }