/** 结束下拉刷新 */ public void endRefreshing(boolean state) { if (mCurrentRefreshStatus == RefreshStatus.REFRESHING) { mCurrentRefreshStatus = RefreshStatus.IDLE; hiddenRefreshHeaderView(); handleRefreshStatusChanged(); mRefreshViewHolder.onEndRefreshing(state); } }
/** * 处理手指抬起事件 * * @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; }