private ItemInfo infoForCurrentScrollPositionVertical() { final int height = getClientHeight(); final float scrollOffset = height > 0 ? (float) getScrollY() / height : 0; final float marginOffset = height > 0 ? (float) mPageMargin / height : 0;
final int scrollY = getScrollY();
int oldY = getScrollY(); int x = mScroller.getCurrX(); int y = mScroller.getCurrY();
int oldY = getScrollY(); int x = mScroller.getCurrX(); int y = mScroller.getCurrY();
final int scrollY = getScrollY();
scrollTo((int) scrollX, getScrollY()); pageScrolledHorizontal((int) scrollX); return needsInvalidate;
mLastMotionY = y; float oldScrollY = getScrollY(); float scrollY = oldScrollY + deltaY; final int height = getClientHeight();
final int scrollY = getScrollY(); int paddingTop = getPaddingTop(); int paddingBottom = getPaddingBottom(); final int scrollY = getScrollY(); final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) {
if (!mScroller.isFinished() && mScroller.computeScrollOffset()) { int oldX = getScrollX(); int oldY = getScrollY(); int x = mScroller.getCurrX(); int y = mScroller.getCurrY();
} else { sy = getScrollY();
int sy = getScrollY(); int dx = x - sx; int dy = y - sy;
private void recomputeScrollPositionHorizontal(int width, int oldWidth, int margin, int oldMargin) { if (oldWidth > 0 && !mItems.isEmpty()) { if (!mScroller.isFinished()) { mScroller.setFinalX(getCurrentItem() * getClientWidth()); } else { final int widthWithMargin = width - getPaddingLeft() - getPaddingRight() + margin; final int oldWidthWithMargin = oldWidth - getPaddingLeft() - getPaddingRight() + oldMargin; final int xpos = getScrollX(); final float pageOffset = (float) xpos / oldWidthWithMargin; final int newOffsetPixels = (int) (pageOffset * widthWithMargin); scrollTo(newOffsetPixels, getScrollY()); } } else { final YViewPager.ItemInfo ii = infoForPosition(mCurItem); final float scrollOffset = ii != null ? Math.min(ii.offset, mLastOffset) : 0; final int scrollPos = (int) (scrollOffset * (width - getPaddingLeft() - getPaddingRight())); if (scrollPos != getScrollX()) { completeScrollHorizontal(false); scrollTo(scrollPos, getScrollY()); } } }
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); } } }
final int scrollY = getScrollY();