@SuppressLint("ClickableViewAccessibility")
	@Override
	public boolean onTouchEvent(MotionEvent ev) {
		if (!mIsPagingEnabled)
			return false;

		if (mVelocityTracker == null) {
			mVelocityTracker = VelocityTracker.obtain();
		}
		mVelocityTracker.addMovement(ev);

		final int action = ev.getAction();
		final float x = ev.getX();
		final float y = ev.getY();

		switch (action) {
		case MotionEvent.ACTION_DOWN:
			/*
			 * If being flinged and user touches, stop the fling. isFinished
			 * will be false if being flinged.
			 */
			if (!mScroller.isFinished()) {
				mScroller.abortAnimation();
			}

			// Remember where the motion event started
			mLastMotionY = y;
			break;
		case MotionEvent.ACTION_MOVE:
			if (mTouchState == TOUCH_STATE_REST) {
				checkStartScroll(y, x);
			} else if (mTouchState == TOUCH_STATE_SCROLLING) {
				// Scroll to follow the motion event
				int deltaY = (int) (mLastMotionY - y);
				mLastMotionY = y;

				// Apply friction to scrolling past boundaries.
				final int count = getChildCount();
				if (getScrollY() < 0
						|| getScrollY() + pageHeight > getChildAt(count - 1)
								.getBottom()) {
					deltaY /= 2;
				}

				scrollBy(0, deltaY);
			}
			break;
		case MotionEvent.ACTION_UP:
			if (mTouchState == TOUCH_STATE_SCROLLING) {
				final VelocityTracker velocityTracker = mVelocityTracker;
				velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
				int velocityY = (int) velocityTracker.getYVelocity();

				final int count = getChildCount();

				// check scrolling past first or last page?
				if (getScrollY() < 0) {
					snapToPage(0);
				} else if (getScrollY() > measuredHeight - pageHeight) {
					snapToPage(count - 1, BOTTOM, PAGE_SNAP_DURATION_DEFAULT);
				} else {
					for (int i = 0; i < count; i++) {
						final View child = getChildAt(i);
						if (child.getTop() < getScrollY()
								&& child.getBottom() > getScrollY()
										+ pageHeight) {
							// we're inside a page, fling that bitch
							mNextPage = i;
							mScroller.fling(getScrollX(), getScrollY(), 0,
									-velocityY, 0, 0, child.getTop(),
									child.getBottom() - getHeight());
							invalidate();
							break;
						} else if (child.getBottom() > getScrollY()
								&& child.getBottom() < getScrollY()
										+ getHeight()) {
							// stuck in between pages, oh snap!
							if (velocityY < -SNAP_VELOCITY) {
								snapToPage(i + 1);
							} else if (velocityY > SNAP_VELOCITY) {
								snapToPage(i, BOTTOM,
										PAGE_SNAP_DURATION_DEFAULT);
							} else if (getScrollY() + pageHeight / 2 > child
									.getBottom()) {
								snapToPage(i + 1);
							} else {
								snapToPage(i, BOTTOM,
										PAGE_SNAP_DURATION_DEFAULT);
							}
							break;
						}
					}
				}

				if (mVelocityTracker != null) {
					mVelocityTracker.recycle();
					mVelocityTracker = null;
				}
			}
			mTouchState = TOUCH_STATE_REST;
			break;
		case MotionEvent.ACTION_CANCEL:
			mTouchState = TOUCH_STATE_REST;
		}

		return true;
	}
@return true - if pages switching enabled, false - otherwise.
app/src/main/java/pro/alexzaitsev/freepager/library/view/core/VerticalPager.java