Search in sources :

Example 16 with TabLayout

use of com.google.android.material.tabs.TabLayout in project Signal-Android by signalapp.

the class ManagePendingAndRequestingMembersActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState, boolean ready) {
    super.onCreate(savedInstanceState, ready);
    setContentView(R.layout.group_pending_and_requesting_member_activity);
    if (savedInstanceState == null) {
        GroupId.V2 groupId = GroupId.parseOrThrow(getIntent().getStringExtra(GROUP_ID)).requireV2();
        ViewPager2 viewPager = findViewById(R.id.pending_and_requesting_pager);
        TabLayout tabLayout = findViewById(R.id.pending_and_requesting_tabs);
        viewPager.setAdapter(new ViewPagerAdapter(this, groupId));
        new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> {
            switch(position) {
                case 0:
                    tab.setText(R.string.PendingMembersActivity_requests);
                    break;
                case 1:
                    tab.setText(R.string.PendingMembersActivity_invites);
                    break;
                default:
                    throw new AssertionError();
            }
        }).attach();
    }
    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    requireSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
Also used : ViewPager2(androidx.viewpager2.widget.ViewPager2) Context(android.content.Context) Bundle(android.os.Bundle) TabLayout(com.google.android.material.tabs.TabLayout) PendingMemberInvitesFragment(org.thoughtcrime.securesms.groups.ui.invitesandrequests.invited.PendingMemberInvitesFragment) NonNull(androidx.annotation.NonNull) Intent(android.content.Intent) ViewPager2(androidx.viewpager2.widget.ViewPager2) RequestingMembersFragment(org.thoughtcrime.securesms.groups.ui.invitesandrequests.requesting.RequestingMembersFragment) R(org.thoughtcrime.securesms.R) FragmentActivity(androidx.fragment.app.FragmentActivity) FragmentStateAdapter(androidx.viewpager2.adapter.FragmentStateAdapter) DynamicTheme(org.thoughtcrime.securesms.util.DynamicTheme) PassphraseRequiredActivity(org.thoughtcrime.securesms.PassphraseRequiredActivity) DynamicNoActionBarTheme(org.thoughtcrime.securesms.util.DynamicNoActionBarTheme) Fragment(androidx.fragment.app.Fragment) GroupId(org.thoughtcrime.securesms.groups.GroupId) Toolbar(androidx.appcompat.widget.Toolbar) TabLayoutMediator(com.google.android.material.tabs.TabLayoutMediator) TabLayout(com.google.android.material.tabs.TabLayout) TabLayoutMediator(com.google.android.material.tabs.TabLayoutMediator) GroupId(org.thoughtcrime.securesms.groups.GroupId) Toolbar(androidx.appcompat.widget.Toolbar)

Example 17 with TabLayout

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

use of com.google.android.material.tabs.TabLayout in project android_packages_apps_Settings by omnirom.

the class ProfileSelectFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mContentView = (ViewGroup) super.onCreateView(inflater, container, savedInstanceState);
    final Activity activity = getActivity();
    final int selectedTab = convertPosition(getTabId(activity, getArguments()));
    final View tabContainer = mContentView.findViewById(R.id.tab_container);
    final ViewPager viewPager = tabContainer.findViewById(R.id.view_pager);
    viewPager.setAdapter(new ProfileSelectFragment.ViewPagerAdapter(this));
    final TabLayout tabs = tabContainer.findViewById(R.id.tabs);
    tabs.setupWithViewPager(viewPager);
    setupTabTextColor(tabs);
    tabContainer.setVisibility(View.VISIBLE);
    final TabLayout.Tab tab = tabs.getTabAt(selectedTab);
    tab.select();
    final FrameLayout listContainer = mContentView.findViewById(android.R.id.list_container);
    listContainer.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    final RecyclerView recyclerView = getListView();
    recyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);
    Utils.setActionBarShadowAnimation(activity, getSettingsLifecycle(), recyclerView);
    return mContentView;
}
Also used : TabLayout(com.google.android.material.tabs.TabLayout) FrameLayout(android.widget.FrameLayout) SettingsActivity(com.android.settings.SettingsActivity) Activity(android.app.Activity) RecyclerView(androidx.recyclerview.widget.RecyclerView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) ViewPager(androidx.viewpager.widget.ViewPager) LinearLayout(android.widget.LinearLayout)

Example 19 with TabLayout

use of com.google.android.material.tabs.TabLayout in project RxBinding by JakeWharton.

the class RxTabLayoutTest method selectionsNoInitial.

@Test
@UiThreadTest
public void selectionsNoInitial() {
    TabLayout empty = new TabLayout(context);
    RecordingObserver<TabLayout.Tab> o = new RecordingObserver<>();
    RxTabLayout.selections(empty).subscribe(o);
    o.assertNoMoreEvents();
}
Also used : TabLayout(com.google.android.material.tabs.TabLayout) RecordingObserver(com.jakewharton.rxbinding4.RecordingObserver) UiThreadTest(androidx.test.annotation.UiThreadTest) Test(org.junit.Test) UiThreadTest(androidx.test.annotation.UiThreadTest)

Example 20 with TabLayout

use of com.google.android.material.tabs.TabLayout in project Signal-Android by WhisperSystems.

the class PaymentsAllActivityFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    ViewPager viewPager = view.findViewById(R.id.payments_all_activity_fragment_view_pager);
    TabLayout tabLayout = view.findViewById(R.id.payments_all_activity_fragment_tabs);
    Toolbar toolbar = view.findViewById(R.id.payments_all_activity_fragment_toolbar);
    toolbar.setNavigationOnClickListener(v -> Navigation.findNavController(v).popBackStack());
    viewPager.setAdapter(new Adapter(getChildFragmentManager()));
    tabLayout.setupWithViewPager(viewPager);
}
Also used : TabLayout(com.google.android.material.tabs.TabLayout) FragmentStatePagerAdapter(androidx.fragment.app.FragmentStatePagerAdapter) ViewPager(androidx.viewpager.widget.ViewPager) Toolbar(androidx.appcompat.widget.Toolbar)

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