Search in sources :

Example 36 with TabLayout

use of com.google.android.material.tabs.TabLayout 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

TabLayout (com.google.android.material.tabs.TabLayout)36 View (android.view.View)19 Bundle (android.os.Bundle)13 Toolbar (androidx.appcompat.widget.Toolbar)13 NonNull (androidx.annotation.NonNull)12 ViewPager (androidx.viewpager.widget.ViewPager)12 ViewPager2 (androidx.viewpager2.widget.ViewPager2)11 TabLayoutMediator (com.google.android.material.tabs.TabLayoutMediator)11 Fragment (androidx.fragment.app.Fragment)10 Intent (android.content.Intent)9 LayoutInflater (android.view.LayoutInflater)9 ViewGroup (android.view.ViewGroup)9 TextView (android.widget.TextView)7 Nullable (androidx.annotation.Nullable)7 FragmentStateAdapter (androidx.viewpager2.adapter.FragmentStateAdapter)7 Context (android.content.Context)6 R (de.danoeh.antennapod.R)5 SharedPreferences (android.content.SharedPreferences)3 MenuItem (android.view.MenuItem)3 FrameLayout (android.widget.FrameLayout)3