@Override protected void onCreate(Bundle savedInstanceState) { mConfiguration = configuration(); // overridePendingTransition(R.anim.fade_in, R.anim.fade_out); super.setTheme(mConfiguration.getThemeResId()); /* Passing null for savedInstanceState fixes issue with fragments in list not matching the displayed ones after the screen was rotated. (Parallax animations would stop working) TODO: Look into this more */ super.onCreate(null); setContentView(R.layout.activity_welcome); AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); mAdapter = new WelcomeFragmentPagerAdapter(getSupportFragmentManager()); mViewPager = (ViewPager) findViewById(R.id.view_pager); mViewPager.setAdapter(mAdapter); if (mConfiguration.getShowActionBarBackButton()) { ActionBar actionBar = getSupportActionBar(); if (actionBar != null) actionBar.setDisplayHomeAsUpEnabled(true); } SkipButton skip = new SkipButton(findViewById(R.id.button_skip), mConfiguration.getCanSkip()); skip.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { completeWelcomeScreen(); } }); PreviousButton prev = new PreviousButton(findViewById(R.id.button_prev)); prev.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { scrollToPreviousPage(); } }); NextButton next = new NextButton(findViewById(R.id.button_next)); next.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { scrollToNextPage(); } }); DoneButton done = new DoneButton(findViewById(R.id.button_done)); done.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { completeWelcomeScreen(); } }); WelcomeScreenViewPagerIndicator indicator = (WelcomeScreenViewPagerIndicator) findViewById(R.id.pager_indicator); WelcomeScreenBackgroundView background = (WelcomeScreenBackgroundView) findViewById(R.id.background_view); WelcomeScreenHider hider = new WelcomeScreenHider(findViewById(R.id.root)); hider.setOnViewHiddenListener( new WelcomeScreenHider.OnViewHiddenListener() { @Override public void onViewHidden() { completeWelcomeScreen(); } }); mItems = new WelcomeScreenItemList( background, indicator, skip, prev, next, done, hider, mConfiguration.getPages()); mViewPager.addOnPageChangeListener(mItems); mViewPager.setCurrentItem(mConfiguration.firstPageIndex()); mItems.setup(mConfiguration); mItems.onPageSelected(mViewPager.getCurrentItem()); }
private boolean canScrollToPreviousPage() { return mConfiguration.isRtl() ? getPreviousPageIndex() <= mConfiguration.firstPageIndex() : getPreviousPageIndex() >= mConfiguration.firstPageIndex(); }