private void setFlipDistance(float flipDistance) {

        if (mPageCount < 1) {
            mFlipDistance = 0;
            mCurrentPageIndex = INVALID_PAGE_POSITION;
            mCurrentPageId = -1;
            recycleActiveViews();
            return;
        }

        if (flipDistance == mFlipDistance) {
            return;
        }

        mFlipDistance = flipDistance;

        final int currentPageIndex = (int) Math.round(mFlipDistance
                / FLIP_DISTANCE_PER_PAGE);

        if (mCurrentPageIndex != currentPageIndex) {
            mCurrentPageIndex = currentPageIndex;
            mCurrentPageId = mAdapter.getItemId(mCurrentPageIndex);

            // TODO be smarter about this. Dont remove a view that will be added
            // again on the next line.
            recycleActiveViews();

            // add the new active views
            if (mCurrentPageIndex > 0) {
                fillPageForIndex(mPreviousPage, mCurrentPageIndex - 1);
                addView(mPreviousPage.v);
            }
            if (mCurrentPageIndex >= 0 && mCurrentPageIndex < mPageCount) {
                fillPageForIndex(mCurrentPage, mCurrentPageIndex);
                addView(mCurrentPage.v);
            }
            if (mCurrentPageIndex < mPageCount - 1) {
                fillPageForIndex(mNextPage, mCurrentPageIndex + 1);
                addView(mNextPage.v);
            }
        }

        invalidate();
    }
@author emilsjolander
        <p>
        Class to hold a view and its corresponding info
app/src/main/java/home/smart/fly/animations/customview/flipview/FlipView.java