Search in sources :

Example 11 with ViewPager

use of androidx.viewpager.widget.ViewPager in project Phonograph by kabouzeid.

the class NowPlayingScreenPreferenceDialog method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    @SuppressLint("InflateParams") View view = LayoutInflater.from(getContext()).inflate(R.layout.preference_dialog_now_playing_screen, null);
    ViewPager viewPager = view.findViewById(R.id.now_playing_screen_view_pager);
    viewPager.setAdapter(new NowPlayingScreenAdapter(getContext()));
    viewPager.addOnPageChangeListener(this);
    viewPager.setPageMargin((int) ViewUtil.convertDpToPixel(32, getResources()));
    viewPager.setCurrentItem(PreferenceUtil.getInstance(getContext()).getNowPlayingScreen().ordinal());
    InkPageIndicator pageIndicator = view.findViewById(R.id.page_indicator);
    pageIndicator.setViewPager(viewPager);
    pageIndicator.onPageSelected(viewPager.getCurrentItem());
    return new MaterialDialog.Builder(getContext()).title(R.string.pref_title_now_playing_screen_appearance).positiveText(android.R.string.ok).negativeText(android.R.string.cancel).onAny(this).customView(view, false).build();
}
Also used : SuppressLint(android.annotation.SuppressLint) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) ViewPager(androidx.viewpager.widget.ViewPager) InkPageIndicator(com.heinrichreimersoftware.materialintro.view.InkPageIndicator) NonNull(androidx.annotation.NonNull)

Example 12 with ViewPager

use of androidx.viewpager.widget.ViewPager in project MTweaks-KernelAdiutorMOD by morogoku.

the class ViewPagerDialog method onCreateView.

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.viewpager_view, container, false);
    ViewPager viewPager = rootView.findViewById(R.id.viewpager);
    CirclePageIndicator indicator = rootView.findViewById(R.id.indicator);
    viewPager.setAdapter(new RecyclerViewFragment.ViewPagerAdapter(getChildFragmentManager(), mFragments));
    indicator.setViewPager(viewPager);
    return rootView;
}
Also used : RecyclerViewFragment(com.moro.mtweaks.fragments.recyclerview.RecyclerViewFragment) View(android.view.View) ViewPager(androidx.viewpager.widget.ViewPager) CirclePageIndicator(com.viewpagerindicator.CirclePageIndicator) Nullable(androidx.annotation.Nullable)

Example 13 with ViewPager

use of androidx.viewpager.widget.ViewPager in project MTweaks-KernelAdiutorMOD by morogoku.

the class DownloadsActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_downloads);
    initToolBar();
    SupportedDownloads.KernelContent content = new SupportedDownloads.KernelContent(getIntent().getStringExtra(JSON_INTENT));
    getSupportActionBar().setTitle(Utils.htmlFrom(content.getName()).toString());
    final ViewPager viewPager = findViewById(R.id.viewpager);
    LinkedHashMap<String, Fragment> items = new LinkedHashMap<>();
    List<SupportedDownloads.KernelContent.Feature> features = content.getFeatures();
    List<SupportedDownloads.KernelContent.Download> downloads = content.getDownloads();
    if (content.getShortDescription() != null && content.getLongDescription() != null) {
        items.put(getString(R.string.about), AboutFragment.newInstance(content));
    }
    if (features.size() > 0) {
        items.put(getString(R.string.features), FeaturesFragment.newInstance(features));
    }
    if (downloads.size() > 0) {
        items.put(getString(R.string.downloads), DownloadKernelFragment.newInstance(downloads));
    }
    viewPager.setOffscreenPageLimit(items.size());
    PagerAdapter pagerAdapter = new PagerAdapter(getSupportFragmentManager(), items);
    viewPager.setAdapter(pagerAdapter);
    TabLayout tabLayout = findViewById(R.id.tablayout);
    tabLayout.setupWithViewPager(viewPager);
    viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
}
Also used : SupportedDownloads(com.moro.mtweaks.utils.tools.SupportedDownloads) ViewPager(androidx.viewpager.widget.ViewPager) DownloadKernelFragment(com.moro.mtweaks.fragments.tools.downloads.DownloadKernelFragment) AboutFragment(com.moro.mtweaks.fragments.tools.downloads.AboutFragment) FeaturesFragment(com.moro.mtweaks.fragments.tools.downloads.FeaturesFragment) Fragment(androidx.fragment.app.Fragment) FragmentStatePagerAdapter(androidx.fragment.app.FragmentStatePagerAdapter) LinkedHashMap(java.util.LinkedHashMap) TabLayout(com.google.android.material.tabs.TabLayout)

Example 14 with ViewPager

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

the class ComplaintsFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_complaints, container, false);
    Toolbar toolbar = getActivity().findViewById(R.id.toolbar);
    toolbar.setTitle("Complaints/Suggestions");
    Utils.setSelectedMenuItem(getActivity(), R.id.nav_complaint);
    Bundle bundle = getArguments();
    userID = bundle.getString(Constants.USER_ID);
    userProfileUrl = bundle.getString(Constants.CURRENT_USER_PROFILE_PICTURE);
    CollapsingToolbarLayout collapsingToolbarLayout = view.findViewById(R.id.collapsing_toolbar);
    collapsingToolbarLayout.setTitleEnabled(false);
    ViewPager viewPager = view.findViewById(R.id.tab_viewpager);
    slidingTabLayout = view.findViewById(R.id.sliding_tab_layout);
    Button buttonVentIssues = view.findViewById(R.id.buttonVentIssues);
    buttonVentIssues.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            FileComplaintFragment fileComplaintFragment = new FileComplaintFragment();
            fileComplaintFragment.setArguments(getArguments());
            FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
            fragmentTransaction.replace(R.id.framelayout_for_fragment, fileComplaintFragment, Utils.getTag(fileComplaintFragment));
            fragmentTransaction.addToBackStack("Complaint Fragment").commit();
        }
    });
    slidingTabLayout = view.findViewById(R.id.sliding_tab_layout);
    if (viewPager != null) {
        setupViewPager(viewPager);
    }
    return view;
}
Also used : FragmentTransaction(androidx.fragment.app.FragmentTransaction) Button(android.widget.Button) Bundle(android.os.Bundle) CollapsingToolbarLayout(com.google.android.material.appbar.CollapsingToolbarLayout) View(android.view.View) ViewPager(androidx.viewpager.widget.ViewPager) Toolbar(androidx.appcompat.widget.Toolbar)

Example 15 with ViewPager

use of androidx.viewpager.widget.ViewPager in project SmoothRefreshLayout by dkzwm.

the class AutoRefreshUtil method autoRefresh.

public void autoRefresh(boolean atOnce, boolean autoRefreshUseSmoothScroll) {
    if (mRefreshLayout != null) {
        if (mStatus != SmoothRefreshLayout.SR_STATUS_INIT)
            return;
        if (mRefreshLayout.isNotYetInEdgeCannotMoveHeader()) {
            if (mRefreshLayout.isVerticalOrientation()) {
                ScrollCompat.flingCompat(mTargetView, -mMaximumFlingVelocity);
            } else {
                if (ViewCatcherUtil.isViewPager(mTargetView)) {
                    final ViewPager pager = (ViewPager) mTargetView;
                    final PagerAdapter adapter = pager.getAdapter();
                    if (adapter == null)
                        return;
                    if (adapter.getCount() <= 0)
                        return;
                    pager.setCurrentItem(0, true);
                } else {
                    HorizontalScrollCompat.flingCompat(mTargetView, -mMaximumFlingVelocity);
                }
            }
            mNeedToTriggerRefresh = true;
            mCachedActionAtOnce = atOnce;
            mCachedAutoRefreshUseSmoothScroll = autoRefreshUseSmoothScroll;
        } else {
            mRefreshLayout.autoRefresh(atOnce, autoRefreshUseSmoothScroll);
            mNeedToTriggerRefresh = false;
            mCachedActionAtOnce = false;
            mCachedAutoRefreshUseSmoothScroll = false;
        }
        ViewCompat.postOnAnimation(mRefreshLayout, this);
    }
}
Also used : ViewPager(androidx.viewpager.widget.ViewPager) PagerAdapter(androidx.viewpager.widget.PagerAdapter)

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