private void startScolling() { mVelocityTracker.computeCurrentVelocity(1000, mMaxFlingVelocity); int velocity = (int) mVelocityTracker.getYVelocity(); if (!mScroller.isFinished()) { mScroller.forceFinished(true); } int progress = mProgressManager.getCurrentHeight(); int end; if (Math.abs(velocity) > mMinFlingVelocity) { if (velocity > 0) { end = mProgressManager.getEndSize() - progress; } else { end = -progress; } } else { int endSize = mProgressManager.getEndSize(); if (endSize / 2 <= progress) { end = endSize - progress; } else { end = -progress; } } mScroller.startScroll(0, progress, 0, end); mCalendarView.postInvalidate(); mState = State.SETTLING; }
public void onDraw() { if (!mScroller.isFinished()) { mScroller.computeScrollOffset(); float position = mScroller.getCurrY() * 1f / mProgressManager.getEndSize(); mProgressManager.apply(position); mCalendarView.postInvalidate(); } else if (mState == State.SETTLING) { mState = State.IDLE; float position = mScroller.getCurrY() * 1f / mProgressManager.getEndSize(); mProgressManager.finish(position > 0); mProgressManager = null; } }