private void scrollToItem(int item, boolean smoothScroll, int velocity,
                              boolean dispatchSelected) {
        final ItemInfo curInfo = infoForPosition(item);
        int destX = 0;
        if (curInfo != null) {
            final int width = getClientWidth();
            destX = (int) (width * Math.max(mFirstOffset,
                    Math.min(curInfo.offset, mLastOffset)));
        }
        if (smoothScroll) {
            smoothScrollTo(destX, 0, velocity);
            if (dispatchSelected) {
                triggerOnPageChangeEvent(item);
            }
        } else {
            if (dispatchSelected) {
                triggerOnPageChangeEvent(item);
            }
            completeScroll(false);
            scrollTo(destX, 0);
            pageScrolled(destX);
        }
    }
Set the currently selected page.

@param item Item index to select
@param smoothScroll True to smoothly scroll to the new item, false to transition immediately
library/src/main/java/com/daimajia/slider/library/Tricks/ViewPagerEx.java