@Override public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs) { return new YViewPager.LayoutParams(getContext(), attrs); }
/** * Set a drawable that will be used to fill the margin between pages. * * @param d Drawable to display between pages */ public void setPageMarginDrawable(Drawable d) { mMarginDrawable = d; if (d != null) refreshDrawableState(); setWillNotDraw(d == null); invalidate(); }
public YViewPager(Context context, AttributeSet attrs) { super(context, attrs); initStyle(context, attrs); initViewPager(); }
boolean pageRight() { if (mAdapter != null && mCurItem < (getAdapterCount() - 1)) { setCurrentItem(mCurItem + 1, true); return true; } return false; }
@Override public Parcelable onSaveInstanceState() { Parcelable superState = super.onSaveInstanceState(); YViewPager.SavedState ss = new YViewPager.SavedState(superState); ss.position = mCurItem; if (mAdapter != null) { ss.adapterState = mAdapter.saveState(); } return ss; }
private int getAdapterCount() { if (isCirculatory) { return mAdapterCirculatoryCount; } else { return mAdapter.getCount(); } }
@Override public void run() { setScrollState(SCROLL_STATE_IDLE); if (isVertical) { populateVertical(); } else { populateHorizontal(); } } };
private void setScrollState(int newState) { if (mScrollState == newState) { return; } mScrollState = newState; if (mPageTransformer != null) { // PageTransformers can do complex things that benefit from hardware layers. enableLayers(newState != SCROLL_STATE_IDLE); } dispatchOnScrollStateChanged(newState); }
boolean pageLeft() { if (mCurItem > 0) { setCurrentItem(mCurItem - 1, true); return true; } return false; }
/** * Called when a change in the shown pages is going to start being made. * * @param container The containing View which is displaying this adapter's * page views. */ public void startUpdate(ViewGroup container) { startUpdate((View) container); }
/** * Called to inform the adapter of which item is currently considered to * be the "primary", that is the one show to the user as the current page. * * @param container The containing View from which the page will be removed. * @param position The page position that is now the primary. * @param object The same object that was returned by * {@link #instantiateItem(View, int)}. */ public void setPrimaryItem(ViewGroup container, int position, Object object) { setPrimaryItem((View) container, position, object); }
/** * Called when the a change in the shown pages has been completed. At this * point you must ensure that all of the pages have actually been added or * removed from the container as appropriate. * * @param container The containing View which is displaying this adapter's * page views. */ public void finishUpdate(ViewGroup container) { finishUpdate((View) container); }
@Override public void onClick(View view) { mViewPager.setDirection(YViewPager.VERTICAL); } });
public void setDirection(int direction) { if (direction == HORIZONTAL && isVertical) { isVertical = false; } else if (direction == VERTICAL && !isVertical) { isVertical = true; } requestLayout(); }
@Override public void onInvalidated() { dataSetChanged(); } }
@Override protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) { return generateDefaultLayoutParams(); }
@Override public YViewPager.SavedState createFromParcel(Parcel in, ClassLoader loader) { return new YViewPager.SavedState(in, loader); }
public YViewPager(Context context) { super(context); initStyle(context, null); initViewPager(); }
private boolean canScroll() { return (mAdapter != null) && (mAdapter.getCount() > 1); } }
@Override public void onClick(View view) { mViewPager.setDirection(YViewPager.HORIZONTAL); } });