Search in sources :

Example 26 with ViewPager

use of androidx.viewpager.widget.ViewPager in project Gadgetbridge by Freeyourgadget.

the class AppManagerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_fragmentappmanager);
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        mGBDevice = extras.getParcelable(GBDevice.EXTRA_DEVICE);
    }
    if (mGBDevice == null) {
        throw new IllegalArgumentException("Must provide a device when invoking this activity");
    }
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    assert fab != null;
    fab.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
            intent.addCategory(Intent.CATEGORY_OPENABLE);
            intent.setType("*/*");
            startActivityForResult(intent, READ_REQUEST_CODE);
        }
    });
    // Set up the ViewPager with the sections adapter.
    ViewPager viewPager = (ViewPager) findViewById(R.id.appmanager_pager);
    if (viewPager != null) {
        viewPager.setAdapter(getPagerAdapter());
    }
}
Also used : Bundle(android.os.Bundle) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) Intent(android.content.Intent) View(android.view.View) ViewPager(androidx.viewpager.widget.ViewPager)

Example 27 with ViewPager

use of androidx.viewpager.widget.ViewPager in project xabber-android by redsolution.

the class ImageViewerActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_image_viewer);
    // get params
    Intent intent = getIntent();
    Bundle args = intent.getExtras();
    if (args == null) {
        finish();
        return;
    }
    String imageUrl = args.getString(IMAGE_URL);
    String messageId = args.getString(MESSAGE_ID);
    int imagePosition = args.getInt(ATTACHMENT_POSITION);
    // setup toolbar
    toolbar = (Toolbar) findViewById(R.id.toolbar_default);
    toolbar.setNavigationIcon(R.drawable.ic_arrow_left_white_24dp);
    toolbar.inflateMenu(R.menu.menu_image_viewer);
    toolbar.setOnMenuItemClickListener(this);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            NavUtils.navigateUpFromSameTask(ImageViewerActivity.this);
        }
    });
    // get imageAttachments
    Realm realm = MessageDatabaseManager.getInstance().getRealmUiThread();
    MessageItem messageItem = realm.where(MessageItem.class).equalTo(MessageItem.Fields.UNIQUE_ID, messageId).findFirst();
    if (imageUrl != null) {
        Attachment attachment = new Attachment();
        attachment.setFileUrl(imageUrl);
        imageAttachments.add(attachment);
    } else {
        RealmList<Attachment> attachments = messageItem.getAttachments();
        for (Attachment attachment : attachments) {
            if (attachment.isImage())
                imageAttachments.add(attachment);
        }
    }
    // get account jid
    this.accountJid = messageItem.getAccount();
    // find views
    progressBar = findViewById(R.id.progressBar);
    ivCancelDownload = findViewById(R.id.ivCancelDownload);
    ivCancelDownload.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onCancelDownloadClick();
        }
    });
    viewPager = findViewById(R.id.viewPager);
    PagerAdapter pagerAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {

        @Override
        public Fragment getItem(int position) {
            Attachment attachment = imageAttachments.get(position);
            return ImageViewerFragment.newInstance(attachment.getFilePath(), attachment.getFileUrl(), attachment.getUniqueId());
        }

        @Override
        public int getCount() {
            return imageAttachments.size();
        }
    };
    viewPager.setAdapter(pagerAdapter);
    viewPager.setCurrentItem(imagePosition);
    viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
            updateToolbar();
            unsubscribeAttachmentState();
            subscribeForAttachment(imageAttachments.get(position));
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });
    if (imageAttachments.size() > imagePosition)
        subscribeForAttachment(imageAttachments.get(imagePosition));
}
Also used : MessageItem(com.xabber.android.data.database.messagerealm.MessageItem) Bundle(android.os.Bundle) FragmentPagerAdapter(androidx.fragment.app.FragmentPagerAdapter) Intent(android.content.Intent) Attachment(com.xabber.android.data.database.messagerealm.Attachment) ImageView(android.widget.ImageView) View(android.view.View) ViewPager(androidx.viewpager.widget.ViewPager) PagerAdapter(androidx.viewpager.widget.PagerAdapter) FragmentPagerAdapter(androidx.fragment.app.FragmentPagerAdapter) Realm(io.realm.Realm)

Example 28 with ViewPager

use of androidx.viewpager.widget.ViewPager in project CircleIndicator by ongakuer.

the class DefaultFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    ViewPager viewpager = view.findViewById(R.id.viewpager);
    CircleIndicator indicator = view.findViewById(R.id.indicator);
    viewpager.setAdapter(new SamplePagerAdapter());
    indicator.setViewPager(viewpager);
    viewpager.setCurrentItem(2);
}
Also used : CircleIndicator(me.relex.circleindicator.CircleIndicator) ViewPager(androidx.viewpager.widget.ViewPager) SamplePagerAdapter(me.relex.circleindicator.sample.SamplePagerAdapter)

Example 29 with ViewPager

use of androidx.viewpager.widget.ViewPager in project CircleIndicator by ongakuer.

the class CustomAnimationFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    int indicatorWidth = (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, getResources().getDisplayMetrics()) + 0.5f);
    int indicatorHeight = (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics()) + 0.5f);
    int indicatorMargin = (int) (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 6, getResources().getDisplayMetrics()) + 0.5f);
    ViewPager viewpager = view.findViewById(R.id.viewpager);
    CircleIndicator indicator = view.findViewById(R.id.indicator);
    Config config = new Config.Builder().width(indicatorWidth).height(indicatorHeight).margin(indicatorMargin).animator(R.animator.indicator_animator).animatorReverse(R.animator.indicator_animator_reverse).drawable(R.drawable.black_radius_square).build();
    indicator.initialize(config);
    viewpager.setAdapter(new SamplePagerAdapter());
    indicator.setViewPager(viewpager);
}
Also used : Config(me.relex.circleindicator.Config) CircleIndicator(me.relex.circleindicator.CircleIndicator) ViewPager(androidx.viewpager.widget.ViewPager) SamplePagerAdapter(me.relex.circleindicator.sample.SamplePagerAdapter)

Example 30 with ViewPager

use of androidx.viewpager.widget.ViewPager in project CircleIndicator by ongakuer.

the class SnackbarBehaviorFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull final View view, @Nullable Bundle savedInstanceState) {
    ViewPager viewpager = view.findViewById(R.id.viewpager);
    CircleIndicator indicator = view.findViewById(R.id.indicator);
    viewpager.setAdapter(new SamplePagerAdapter());
    indicator.setViewPager(viewpager);
    mSnackbar = Snackbar.make(view.findViewById(R.id.coordinator_layout), "Snackbar", Snackbar.LENGTH_SHORT);
    view.findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!mSnackbar.isShown()) {
                mSnackbar.show();
            } else {
                mSnackbar.dismiss();
            }
        }
    });
}
Also used : CircleIndicator(me.relex.circleindicator.CircleIndicator) ViewPager(androidx.viewpager.widget.ViewPager) View(android.view.View) SamplePagerAdapter(me.relex.circleindicator.sample.SamplePagerAdapter)

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