use of org.mozilla.focus.firstrun.FirstrunPagerAdapter in project Rocket by mozilla-tw.
the class FirstrunFragment method findPagerAdapter.
private PagerAdapter findPagerAdapter(Context context, View.OnClickListener onClickListener) {
final PagerAdapter pagerAdapter;
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean shown = sharedPreferences.getBoolean(PREF_KEY_BOOLEAN_FIRSTRUN_SHOWN, false);
int firstrunUpgradeVersion = sharedPreferences.getInt(PREF_KEY_INT_FIRSTRUN_UPGRADE_VERSION, 0);
if (!shown) {
pagerAdapter = new FirstrunPagerAdapter(context, onClickListener);
} else if (FIRSTRUN_UPGRADE_VERSION > firstrunUpgradeVersion) {
pagerAdapter = new FirstrunUpgradePagerAdapter(context, onClickListener);
} else {
pagerAdapter = null;
}
return pagerAdapter;
}
use of org.mozilla.focus.firstrun.FirstrunPagerAdapter in project focus-android by mozilla-mobile.
the class FirstrunFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, @Nullable Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fragment_firstrun, container, false);
view.findViewById(R.id.skip).setOnClickListener(this);
background = view.findViewById(R.id.background);
final FirstrunPagerAdapter adapter = new FirstrunPagerAdapter(container.getContext(), this);
viewPager = (ViewPager) view.findViewById(R.id.pager);
viewPager.setFocusable(true);
viewPager.setPageTransformer(true, new ViewPager.PageTransformer() {
@Override
public void transformPage(View page, float position) {
page.setAlpha(1 - (0.5f * Math.abs(position)));
}
});
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
TelemetryWrapper.showFirstRunPageEvent(position);
}
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
viewPager.setClipToPadding(false);
viewPager.setAdapter(adapter);
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageSelected(int position) {
final TransitionDrawable drawable = (TransitionDrawable) background.getBackground();
if (position == adapter.getCount() - 1) {
drawable.startTransition(200);
} else {
drawable.resetTransition();
}
}
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
final TabLayout tabLayout = (TabLayout) view.findViewById(R.id.tabs);
tabLayout.setupWithViewPager(viewPager, true);
return view;
}
Aggregations