Search in sources :

Example 36 with ViewPager

use of androidx.viewpager.widget.ViewPager in project zxing-android-embedded by journeyapps.

the class TabbedScanning method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tabbed_scanning);
    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
    // Set up the ViewPager with the sections adapter.
    mViewPager = findViewById(R.id.container);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    // Set up the action bar.
    final ActionBar actionBar = getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOffscreenPageLimit(0);
    mViewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    });
    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by
        // the adapter. Also specify this Activity object, which implements
        // the TabListener interface, as the callback (listener) for when
        // this tab is selected.
        actionBar.addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
}
Also used : ViewPager(androidx.viewpager.widget.ViewPager) ActionBar(androidx.appcompat.app.ActionBar)

Example 37 with ViewPager

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

the class CustomViewPager method init.

private void init() {
    try {
        Class<?> viewpager = ViewPager.class;
        Field fieldScroller = viewpager.getDeclaredField("mScroller");
        fieldScroller.setAccessible(true);
        scroller = new CustomScroller(getContext(), new DecelerateInterpolator());
        fieldScroller.set(this, scroller);
    } catch (Exception ignored) {
    }
}
Also used : DecelerateInterpolator(android.view.animation.DecelerateInterpolator) Field(java.lang.reflect.Field) ViewPager(androidx.viewpager.widget.ViewPager)

Example 38 with ViewPager

use of androidx.viewpager.widget.ViewPager in project IITB-App by wncc.

the class ComplaintDetailsFragment method initViewPagerForImages.

private void initViewPagerForImages(Venter.Complaint detailedComplaint) {
    ViewPager viewPager = mView.findViewById(R.id.complaint_image_view_pager);
    if (viewPager != null) {
        try {
            ImageViewPagerAdapter imageFragmentPagerAdapter = new ImageViewPagerAdapter(getActivity(), detailedComplaint);
            viewPager.setAdapter(imageFragmentPagerAdapter);
            circleIndicator.setViewPager(viewPager);
            imageFragmentPagerAdapter.registerDataSetObserver(circleIndicator.getDataSetObserver());
            Objects.requireNonNull(viewPager.getAdapter()).notifyDataSetChanged();
            synchronized (viewPager) {
                viewPager.notifyAll();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
Also used : ImageViewPagerAdapter(app.insti.adapter.ImageViewPagerAdapter) ViewPager(androidx.viewpager.widget.ViewPager)

Example 39 with ViewPager

use of androidx.viewpager.widget.ViewPager in project IITB-App by wncc.

the class UserFragment method populateViews.

private void populateViews() {
    if (getActivity() == null || getView() == null)
        return;
    userProfilePictureImageView = getActivity().findViewById(R.id.user_profile_picture_profile);
    TextView userNameTextView = getActivity().findViewById(R.id.user_name_profile);
    TextView userRollNumberTextView = getActivity().findViewById(R.id.user_rollno_profile);
    final TextView userEmailIDTextView = getActivity().findViewById(R.id.user_email_profile);
    TextView userContactNumberTextView = getActivity().findViewById(R.id.user_contact_no_profile);
    FloatingActionButton userShareFab = getActivity().findViewById(R.id.share_user_button);
    Picasso.get().load(user.getUserProfilePictureUrl()).placeholder(R.drawable.user_placeholder).into(userProfilePictureImageView);
    userProfilePictureImageView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            zoomImageFromThumb(userProfilePictureImageView);
        }
    });
    mShortAnimationDuration = getResources().getInteger(android.R.integer.config_shortAnimTime);
    if (!showingMin) {
        /* Show tabs */
        getActivity().findViewById(R.id.tab_layout).setVisibility(VISIBLE);
        /* Load lists */
        final List<Role> roleList = user.getUserRoles();
        final List<Body> bodyList = user.getUserFollowedBodies();
        final List<Event> eventList = user.getUserGoingEvents();
        final List<Role> formerRoleList = user.getUserFormerRoles();
        /* Construct user profile */
        final List<CardInterface> profile = new ArrayList<>(roleList);
        for (Role role : formerRoleList) {
            Role temp = new Role(role);
            temp.setRoleName("Former " + role.getRoleName() + " " + role.getRoleYear());
            profile.add(temp);
        }
        profile.addAll(user.getUserAchievements());
        List<Event> eventInterestedList = user.getUserInterestedEvents();
        eventList.removeAll(eventInterestedList);
        eventList.addAll(eventInterestedList);
        GenericRecyclerViewFragment frag1 = GenericRecyclerViewFragment.newInstance(profile);
        BodyRecyclerViewFragment frag2 = BodyRecyclerViewFragment.newInstance(bodyList);
        EventRecyclerViewFragment frag3 = EventRecyclerViewFragment.newInstance(eventList);
        frag1.parentFragment = this;
        frag2.parentFragment = this;
        frag3.parentFragment = this;
        TabAdapter tabAdapter = new TabAdapter(getChildFragmentManager());
        tabAdapter.addFragment(frag1, "Profile");
        tabAdapter.addFragment(frag2, "Following");
        tabAdapter.addFragment(frag3, "Events");
        // Set up the ViewPager with the sections adapter.
        ViewPager viewPager = (ViewPager) getActivity().findViewById(R.id.viewPager);
        viewPager.setAdapter(tabAdapter);
        viewPager.setOffscreenPageLimit(2);
        TabLayout tabLayout = (TabLayout) getActivity().findViewById(R.id.tab_layout);
        tabLayout.setupWithViewPager(viewPager);
        userShareFab.show();
        getActivity().findViewById(R.id.loadingPanel).setVisibility(View.GONE);
    }
    userNameTextView.setText(user.getUserName());
    userRollNumberTextView.setText(user.getUserRollNumber());
    if (user.getUserEmail() != null && !user.getUserEmail().equals("N/A")) {
        userEmailIDTextView.setText(user.getUserEmail());
    } else {
        if (user.getUserRollNumber() != null)
            userEmailIDTextView.setText(user.getUserRollNumber() + "@iitb.ac.in");
    }
    userEmailIDTextView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mail((String) userEmailIDTextView.getText());
        }
    });
    if (!"N/A".equals(user.getUserContactNumber())) {
        userContactNumberTextView.setText(user.getUserContactNumber());
        userContactNumberTextView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                call(user.getUserContactNumber());
            }
        });
    } else {
        userContactNumberTextView.setVisibility(View.GONE);
    }
    userShareFab.setOnClickListener(new View.OnClickListener() {

        String shareUrl = ShareURLMaker.getUserURL(user);

        @Override
        public void onClick(View view) {
            Intent i = new Intent(Intent.ACTION_SEND);
            i.setType("text/plain");
            i.putExtra(Intent.EXTRA_SUBJECT, "Sharing URL");
            i.putExtra(Intent.EXTRA_TEXT, shareUrl);
            startActivity(Intent.createChooser(i, "Share URL"));
        }
    });
}
Also used : CardInterface(app.insti.interfaces.CardInterface) TabAdapter(app.insti.adapter.TabAdapter) ArrayList(java.util.ArrayList) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ViewPager(androidx.viewpager.widget.ViewPager) Role(app.insti.api.model.Role) TabLayout(com.google.android.material.tabs.TabLayout) FloatingActionButton(com.google.android.material.floatingactionbutton.FloatingActionButton) Event(app.insti.api.model.Event) TextView(android.widget.TextView) Body(app.insti.api.model.Body)

Example 40 with ViewPager

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

the class DynamicAdapterFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    view.findViewById(R.id.add).setOnClickListener(this);
    view.findViewById(R.id.remove).setOnClickListener(this);
    mAdapter = new SamplePagerAdapter(1) {

        @Override
        public int getItemPosition(@NonNull Object object) {
            return POSITION_NONE;
        }
    };
    ViewPager viewpager = view.findViewById(R.id.viewpager);
    CircleIndicator indicator = view.findViewById(R.id.indicator);
    viewpager.setAdapter(mAdapter);
    indicator.setViewPager(viewpager);
    mAdapter.registerDataSetObserver(indicator.getDataSetObserver());
}
Also used : CircleIndicator(me.relex.circleindicator.CircleIndicator) ViewPager(androidx.viewpager.widget.ViewPager) 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