Search in sources :

Example 66 with ViewPager

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);
}
Also used : ViewPager(androidx.viewpager.widget.ViewPager)

Example 67 with ViewPager

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);
    }
}
Also used : ColorPreferences(me.ccrama.redditslide.Visuals.ColorPreferences) Intent(android.content.Intent) ViewPager(androidx.viewpager.widget.ViewPager)

Example 68 with ViewPager

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()));
}
Also used : ApplyOnBootFragment(com.moro.mtweaks.fragments.ApplyOnBootFragment) LinearLayout(android.widget.LinearLayout) Bundle(android.os.Bundle) BaseActivity(com.moro.mtweaks.activities.BaseActivity) NonNull(androidx.annotation.NonNull) ViewPager(androidx.viewpager.widget.ViewPager) Intent(android.content.Intent) HashMap(java.util.HashMap) AppCompatCheckBox(androidx.appcompat.widget.AppCompatCheckBox) DrawableCompat(androidx.core.graphics.drawable.DrawableCompat) BaseFragment(com.moro.mtweaks.fragments.BaseFragment) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) Dialog(com.moro.mtweaks.views.dialog.Dialog) Fragment(androidx.fragment.app.Fragment) View(android.view.View) FragmentStatePagerAdapter(androidx.fragment.app.FragmentStatePagerAdapter) Settings(com.moro.mtweaks.database.Settings) Utils(com.moro.mtweaks.utils.Utils) FragmentManager(androidx.fragment.app.FragmentManager) AppCompatImageButton(androidx.appcompat.widget.AppCompatImageButton) TabLayout(com.google.android.material.tabs.TabLayout) LayoutInflater(android.view.LayoutInflater) NavigationActivity(com.moro.mtweaks.activities.NavigationActivity) ViewGroup(android.view.ViewGroup) ViewUtils(com.moro.mtweaks.utils.ViewUtils) R(com.moro.mtweaks.R) List(java.util.List) Nullable(androidx.annotation.Nullable) Control(com.moro.mtweaks.utils.root.Control) Collections(java.util.Collections) DialogFragment(androidx.fragment.app.DialogFragment) TabLayout(com.google.android.material.tabs.TabLayout) ViewPager(androidx.viewpager.widget.ViewPager) FragmentStatePagerAdapter(androidx.fragment.app.FragmentStatePagerAdapter)

Aggregations

ViewPager (androidx.viewpager.widget.ViewPager)68 View (android.view.View)24 Intent (android.content.Intent)12 TabLayout (com.google.android.material.tabs.TabLayout)12 Toolbar (androidx.appcompat.widget.Toolbar)11 ViewGroup (android.view.ViewGroup)9 TextView (android.widget.TextView)9 ColorPreferences (me.ccrama.redditslide.Visuals.ColorPreferences)9 ImageView (android.widget.ImageView)8 PageNavigationView (me.majiajie.pagerbottomtabstrip.PageNavigationView)8 Bundle (android.os.Bundle)6 PagerAdapter (androidx.viewpager.widget.PagerAdapter)6 MyViewPagerAdapter (me.majiajie.pagerbottomtabstriptest.other.MyViewPagerAdapter)6 CircleIndicator (me.relex.circleindicator.CircleIndicator)6 LayoutInflater (android.view.LayoutInflater)5 Button (android.widget.Button)5 SamplePagerAdapter (me.relex.circleindicator.sample.SamplePagerAdapter)5 LinearInterpolator (android.view.animation.LinearInterpolator)4 NonNull (androidx.annotation.NonNull)4 FragmentStatePagerAdapter (androidx.fragment.app.FragmentStatePagerAdapter)4