@Override public boolean onInterceptTouchEvent(MotionEvent e) { int action = e.getAction(); if (mVelocityTracker == null) { mVelocityTracker = VelocityTracker.obtain(); } mVelocityTracker.addMovement(e); if (!mBounce) { switch (action) { case MotionEvent.ACTION_UP: handlerTracker(); break; } return false; } int y = (int) e.getRawY(); switch (action) { case MotionEvent.ACTION_DOWN: mLastY = y; break; case MotionEvent.ACTION_MOVE: int m = y - mLastY; boolean can = (m >= 0 ? m : -m) > mTouchSlop; if (m > 0 && !mBottomLoading && can && !mTopAutoRefresh) { if (topCanBounce()) { mIsTop = true; if (mTopNotify) { mBrwView.onBounceStateChange( EViewEntry.F_BOUNCE_TYPE_TOP, F_BOUNCEVIEW_STATE_PULL_RELOAD); } return true; } } else if (m < 0 && !mTopLoading && can) { if (bottomCanBounce()) { mIsBottom = true; if (mBottomNotify) { mBrwView.onBounceStateChange( EViewEntry.F_BOUNCE_TYPE_BOTTOM, F_BOUNCEVIEW_STATE_PULL_RELOAD); } return true; } } mLastY = y; break; case MotionEvent.ACTION_UP: handlerTracker(); break; } return false; }
private void topRefreshing() { if (mTopNotify) { mBrwView.onBounceStateChange(EViewEntry.F_BOUNCE_TYPE_TOP, F_BOUNCEVIEW_STATE_RELEASE_RELOAD); } mTopLoading = true; mTopState = F_VIEW_STATE_DRAG; int sy = getScrollY(); int dist = mTopBund - sy; if (mShowTopView) { mHeaderView.setArrowVisibility(GONE); mHeaderView.setProgressBarVisibility(VISIBLE); mHeaderView.setTextVisibility(VISIBLE); mHeaderView.showLoadingText(); } mScroller.startScroll(0, sy, 0, dist); postInvalidate(); if (mTopNotify) { mBrwView.onBounceStateChange(EViewEntry.F_BOUNCE_TYPE_TOP, F_BOUNCEVIEW_STATE_LOADING); } }
private void bottomRefreshing() { if (mBottomNotify) { mBrwView.onBounceStateChange( EViewEntry.F_BOUNCE_TYPE_BOTTOM, F_BOUNCEVIEW_STATE_RELEASE_RELOAD); } mBottomLoading = true; mBottomState = F_VIEW_STATE_DRAG; int sy = getScrollY(); int dist = sy - mBotomBund; if (mShowBottomView) { mTailView.setArrowVisibility(GONE); mTailView.setProgressBarVisibility(VISIBLE); mTailView.setTextVisibility(VISIBLE); mTailView.showLoadingText(); } mScroller.startScroll(0, -sy, 0, dist); postInvalidate(); if (mBottomNotify) { mBrwView.onBounceStateChange(EViewEntry.F_BOUNCE_TYPE_BOTTOM, F_BOUNCEVIEW_STATE_LOADING); } }
public void topBounceViewRefresh() { if (!mTopLoading) { scrollTo(0, mTopBund); if (mShowTopView) { mHeaderView.setArrowVisibility(GONE); mHeaderView.setProgressBarVisibility(VISIBLE); mHeaderView.setTextVisibility(VISIBLE); mHeaderView.showLoadingText(); } mTopAutoRefresh = true; mTopLoading = true; if (mTopNotify) { mBrwView.onBounceStateChange(EViewEntry.F_BOUNCE_TYPE_TOP, F_BOUNCEVIEW_STATE_LOADING); } } }