/** * Scroll to the child at the position passed. * * @param childPosition the child's position * @return if scrolling to the child is starting, false otherwise */ private boolean scrollToChild(final int childPosition) { final View child = getChildAt(childPosition); if (child != null) { final int distance = getGalleryLockPoint() - getLeftOfView(child); mFlingRunnable.startUsingDistance(distance); return true; } return false; }
/** * Scrolls the items so that the selected item is in its 'slot' (its center is the Gallery's * center). * * <p>Note: modifed to snap the left of a view rather than the center */ private void scrollIntoSlots() { if (getChildCount() == 0 || mSelectedChild == null) { return; } final int selectedCenter = getLeftOfView(mSelectedChild); final int targetCenter = getGalleryLockPoint(); final int scrollAmount = targetCenter - selectedCenter; if (scrollAmount != 0) { mFlingRunnable.startUsingDistance(scrollAmount); } else { onFinishedMovement(); } }