use of com.simplecity.amp_library.ui.views.RatingSnackbar in project Shuttle by timusus.
the class LibraryController method setupViewPager.
private void setupViewPager() {
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
CategoryItem.getCategoryItems(sharedPreferences);
if (pagerAdapter != null && refreshPagerAdapter) {
pagerAdapter.removeAllChildFragments();
refreshPagerAdapter = false;
pager.setAdapter(null);
}
int defaultPage = 1;
pagerAdapter = new PagerAdapter(getChildFragmentManager());
List<CategoryItem> categoryItems = Stream.of(CategoryItem.getCategoryItems(sharedPreferences)).filter(categoryItem -> categoryItem.isChecked).toList();
int defaultPageType = settingsManager.getDefaultPageType();
for (int i = 0; i < categoryItems.size(); i++) {
CategoryItem categoryItem = categoryItems.get(i);
pagerAdapter.addFragment(categoryItem.getFragment(getContext()));
if (categoryItem.type == defaultPageType) {
defaultPage = i;
}
}
int currentPage = Math.min(defaultPage, pagerAdapter.getCount());
pager.setAdapter(pagerAdapter);
pager.setOffscreenPageLimit(pagerAdapter.getCount() - 1);
pager.setCurrentItem(currentPage);
slidingTabLayout.setupWithViewPager(pager);
pager.postDelayed(() -> {
if (pager != null) {
new RatingSnackbar(settingsManager, analyticsManager).show(pager, () -> {
ShuttleUtils.openShuttleLink(getActivity(), getActivity().getPackageName(), getActivity().getPackageManager());
return Unit.INSTANCE;
});
}
}, 1000);
}
Aggregations