use of androidx.viewpager.widget.ViewPager in project Slide by ccrama.
the class ShadowboxComments method onCreate.
@Override
public void onCreate(Bundle savedInstance) {
overrideSwipeFromAnywhere();
if (comments == null || comments.isEmpty()) {
finish();
}
applyDarkColorTheme(comments.get(0).comment.getComment().getSubredditName());
super.onCreate(savedInstance);
setContentView(R.layout.activity_slide);
ViewPager pager = (ViewPager) findViewById(R.id.content_view);
commentPager = new ShadowboxCommentsPagerAdapter(getSupportFragmentManager());
pager.setAdapter(commentPager);
}
use of androidx.viewpager.widget.ViewPager in project Slide by ccrama.
the class RedditGallery method onCreate.
public void onCreate(Bundle savedInstanceState) {
overrideSwipeFromAnywhere();
super.onCreate(savedInstanceState);
getTheme().applyStyle(new ColorPreferences(this).getDarkThemeSubreddit(ColorPreferences.FONT_STYLE), true);
setContentView(R.layout.album);
// Keep the screen on
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
if (getIntent().hasExtra(SUBREDDIT)) {
this.subreddit = getIntent().getExtras().getString(SUBREDDIT);
}
if (getIntent().hasExtra(EXTRA_SUBMISSION_TITLE)) {
this.submissionTitle = getIntent().getExtras().getString(EXTRA_SUBMISSION_TITLE);
}
final ViewPager pager = (ViewPager) findViewById(R.id.images);
album = new RedditGalleryPagerAdapter(getSupportFragmentManager());
pager.setAdapter(album);
pager.setCurrentItem(1);
pager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
if (position == 0 && positionOffsetPixels == 0) {
finish();
}
if (position == 0 && ((RedditGalleryPagerAdapter) pager.getAdapter()).blankPage != null) {
if (((RedditGalleryPagerAdapter) pager.getAdapter()).blankPage != null) {
((RedditGalleryPagerAdapter) pager.getAdapter()).blankPage.doOffset(positionOffset);
}
((RedditGalleryPagerAdapter) pager.getAdapter()).blankPage.realBack.setBackgroundColor(Palette.adjustAlpha(positionOffset * 0.7f));
}
}
});
if (!Reddit.appRestart.contains("tutorialSwipe")) {
startActivityForResult(new Intent(this, SwipeTutorial.class), 3);
}
}
use of androidx.viewpager.widget.ViewPager in project MTweaks-KernelAdiutorMOD by morogoku.
the class ProfileActivity method initNewMode.
private void initNewMode(Bundle savedInstanceState) {
mMode = 1;
setContentView(R.layout.activity_profile);
Control.clearProfileCommands();
Control.setProfileMode(true);
final ViewPager viewPager = findViewById(R.id.viewpager);
if (savedInstanceState != null) {
mHideWarningDialog = savedInstanceState.getBoolean("hidewarningdialog");
}
if (!mHideWarningDialog) {
ViewUtils.dialogBuilder(getString(R.string.profile_warning), null, (dialogInterface, i) -> {
}, dialog -> mHideWarningDialog = true, this).show();
}
viewPager.setOffscreenPageLimit(mItems.size());
PagerAdapter pagerAdapter = new PagerAdapter(getSupportFragmentManager(), mItems);
viewPager.setAdapter(pagerAdapter);
TabLayout tabLayout = findViewById(R.id.tablayout);
tabLayout.setupWithViewPager(viewPager);
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
mCurPosition = position;
}
@Override
public void onPageSelected(int position) {
mCurPosition = position;
}
@Override
public void onPageScrollStateChanged(int state) {
}
});
findViewById(R.id.done).setOnClickListener(view -> returnIntent(Control.getProfileCommands()));
}
Aggregations