private void scrollToItemVertical(int item, boolean smoothScroll, int velocity, boolean dispatchSelected) { final ItemInfo curInfo = infoForPosition(item); int destY = 0; if (curInfo != null) { final int height = getClientHeight(); destY = (int) (height * Math.max(mFirstOffset, Math.min(curInfo.offset, mLastOffset))); mDestY = destY; } if (smoothScroll) { smoothScrollToVertical(0, destY, velocity); if (dispatchSelected) { dispatchOnPageSelected(item); } } else { if (dispatchSelected) { dispatchOnPageSelected(item); } completeScrollVertical(false); scrollTo(0, destY); pageScrolledVertical(destY); } }
if (dx == 0 && dy == 0) { completeScrollVertical(false); populateVertical(); setScrollState(SCROLL_STATE_IDLE);
completeScrollVertical(true); } else { completeScrollHorizontal(true);
setScrollState(SCROLL_STATE_DRAGGING); } else if (isVertical) { completeScrollVertical(false); mIsBeingDragged = false;
private void recomputeScrollPositionVertical(int height, int oldHeight, int margin, int oldMargin) { if (oldHeight > 0 && !mItems.isEmpty()) { if (!mScroller.isFinished()) { mScroller.setFinalY(getCurrentItem() * getClientHeight()); } else { final int heightWithMargin = height - getPaddingTop() - getPaddingBottom() + margin; final int oldHeightWithMargin = oldHeight - getPaddingTop() - getPaddingBottom() + oldMargin; final int ypos = getScrollY(); final float pageOffset = (float) ypos / oldHeightWithMargin; final int newOffsetPixels = (int) (pageOffset * heightWithMargin); scrollTo(getScrollX(), newOffsetPixels); } } else { final ItemInfo ii = infoForPosition(mCurItem); final float scrollOffset = ii != null ? Math.min(ii.offset, mLastOffset) : 0; final int scrollPos = (int) (scrollOffset * (height - getPaddingTop() - getPaddingBottom())); if (scrollPos != getScrollY()) { completeScrollVertical(false); scrollTo(getScrollX(), scrollPos); } } }