FIRST_PAGE = 0; public final static int COFFE_PAGE = 10; public final static int UNSURE_PAGE = 11; private static final String[] CARDS = new String[] { "0", "1", "2", "3", "5", "8", "13", "20", "40", "100", "", "?" }; public CardsPagerAdapter(FragmentManager fm) { super(fm); } @Override public Fragment getItem(int position) { PokerCardFragment fragment = new PokerCardFragment(); Bundle args = new Bundle(); args.putInt("position", position); args.putString("value", CARDS[position % CARDS.length]); fragment.setArguments(args); return fragment; } @Override public int getCount() { return CARDS.length; } }
public ScaleFadePageTransformer(Context context) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); mScreenXOffset = display.getWidth()/2; } @Override public void transformPage(View page, float position) { // Position of page relative to the current front-and-center position of the pager. // 0 is front and center. 1 is one full page position to the right, and -1 is one page position to the left. final float transformValue = Math.abs(Math.abs(position) - 1); page.setAlpha(transformValue); if (position > 0) { page.setScaleX(transformValue); page.setScaleY(transformValue); page.setPivotX(0.5f); final float translateValue = position * -mScreenXOffset; if (translateValue > -mScreenXOffset) { page.setTranslationX(translateValue); } else { page.setTranslationX(0); } } } }
CircularPagerAdapter(PagerAdapter adapter) { this.adapter = adapter; } @Override public int getCount() { return Integer.MAX_VALUE; } public int getRealCount() { return adapter.getCount(); } @Override public Object instantiateItem(ViewGroup container, int position) { int virtualPosition = position % getRealCount(); return adapter.instantiateItem(container, virtualPosition); } @Override public void destroyItem(ViewGroup container, int position, Object object) { int virtualPosition = position % getRealCount(); adapter.destroyItem(container, virtualPosition, object); } [...] // Chamar outros métodos associados a esse adapter }