Search in sources :

Example 6 with TabLayout

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

the class TrackSelectionDialog method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View dialogView = inflater.inflate(R.layout.track_selection_dialog, container, false);
    TabLayout tabLayout = dialogView.findViewById(R.id.track_selection_dialog_tab_layout);
    ViewPager viewPager = dialogView.findViewById(R.id.track_selection_dialog_view_pager);
    Button cancelButton = dialogView.findViewById(R.id.track_selection_dialog_cancel_button);
    Button okButton = dialogView.findViewById(R.id.track_selection_dialog_ok_button);
    viewPager.setAdapter(new FragmentAdapter(getChildFragmentManager()));
    tabLayout.setupWithViewPager(viewPager);
    tabLayout.setVisibility(tabFragments.size() > 1 ? View.VISIBLE : View.GONE);
    cancelButton.setOnClickListener(view -> dismiss());
    okButton.setOnClickListener(view -> {
        onClickListener.onClick(getDialog(), DialogInterface.BUTTON_POSITIVE);
        dismiss();
    });
    return dialogView;
}
Also used : Button(android.widget.Button) TabLayout(com.google.android.material.tabs.TabLayout) View(android.view.View) TrackSelectionView(com.google.android.exoplayer2.ui.TrackSelectionView) ViewPager(androidx.viewpager.widget.ViewPager) SelectionOverride(com.google.android.exoplayer2.trackselection.DefaultTrackSelector.SelectionOverride)

Example 7 with TabLayout

use of com.google.android.material.tabs.TabLayout in project SwipeRecyclerView by yanzhenjie.

the class LayoutActivity method initTabLayout.

private void initTabLayout() {
    TabLayout tabLayout = findViewById(R.id.tab_layout);
    TabLayout.Tab tab = tabLayout.newTab();
    tab.setText("商品预览");
    tabLayout.addTab(tab);
    tab = tabLayout.newTab();
    tab.setText("商品详情");
    tabLayout.addTab(tab);
    tab = tabLayout.newTab();
    tab.setText("商品描述");
    tabLayout.addTab(tab);
    tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {

        @Override
        public void onTabSelected(TabLayout.Tab tab) {
            Toast.makeText(LayoutActivity.this, "第" + tab.getPosition() + "个Tab", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onTabUnselected(TabLayout.Tab tab) {
        }

        @Override
        public void onTabReselected(TabLayout.Tab tab) {
        }
    });
}
Also used : TabLayout(com.google.android.material.tabs.TabLayout)

Example 8 with TabLayout

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

the class ReactionsBottomSheetDialogFragment method setUpTabMediator.

private void setUpTabMediator(@Nullable Bundle savedInstanceState) {
    if (savedInstanceState == null) {
        FrameLayout container = requireDialog().findViewById(R.id.container);
        LayoutInflater layoutInflater = LayoutInflater.from(requireContext());
        View statusBarShader = layoutInflater.inflate(R.layout.react_with_any_emoji_status_fade, container, false);
        TabLayout emojiTabs = (TabLayout) layoutInflater.inflate(R.layout.reactions_bottom_sheet_dialog_fragment_tabs, container, false);
        ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewUtil.getStatusBarHeight(container));
        statusBarShader.setLayoutParams(params);
        container.addView(statusBarShader, 0);
        container.addView(emojiTabs);
        ViewCompat.setOnApplyWindowInsetsListener(container, (v, insets) -> insets.consumeSystemWindowInsets());
        new TabLayoutMediator(emojiTabs, recipientPagerView, (tab, position) -> {
            tab.setCustomView(R.layout.reactions_bottom_sheet_dialog_fragment_emoji_item);
            View customView = Objects.requireNonNull(tab.getCustomView());
            EmojiImageView emoji = customView.findViewById(R.id.reactions_bottom_view_emoji_item_emoji);
            TextView text = customView.findViewById(R.id.reactions_bottom_view_emoji_item_text);
            EmojiCount emojiCount = recipientsAdapter.getEmojiCount(position);
            if (position != 0) {
                emoji.setVisibility(View.VISIBLE);
                emoji.setImageEmoji(emojiCount.getDisplayEmoji());
                text.setText(String.valueOf(emojiCount.getCount()));
            } else {
                emoji.setVisibility(View.GONE);
                text.setText(customView.getContext().getString(R.string.ReactionsBottomSheetDialogFragment_all, emojiCount.getCount()));
            }
        }).attach();
    }
}
Also used : ViewCompat(androidx.core.view.ViewCompat) Context(android.content.Context) Bundle(android.os.Bundle) MessageId(org.thoughtcrime.securesms.database.model.MessageId) ViewModelProvider(androidx.lifecycle.ViewModelProvider) TabLayout(com.google.android.material.tabs.TabLayout) LayoutInflater(android.view.LayoutInflater) NonNull(androidx.annotation.NonNull) LifecycleDisposable(org.thoughtcrime.securesms.util.LifecycleDisposable) FrameLayout(android.widget.FrameLayout) ViewPager2(androidx.viewpager2.widget.ViewPager2) ViewUtil(org.thoughtcrime.securesms.util.ViewUtil) EmojiImageView(org.thoughtcrime.securesms.components.emoji.EmojiImageView) R(org.thoughtcrime.securesms.R) ViewGroup(android.view.ViewGroup) Objects(java.util.Objects) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) ThemeUtil(org.thoughtcrime.securesms.util.ThemeUtil) BottomSheetDialogFragment(com.google.android.material.bottomsheet.BottomSheetDialogFragment) View(android.view.View) TabLayoutMediator(com.google.android.material.tabs.TabLayoutMediator) DialogInterface(android.content.DialogInterface) DialogFragment(androidx.fragment.app.DialogFragment) TabLayout(com.google.android.material.tabs.TabLayout) ViewGroup(android.view.ViewGroup) FrameLayout(android.widget.FrameLayout) LayoutInflater(android.view.LayoutInflater) TabLayoutMediator(com.google.android.material.tabs.TabLayoutMediator) TextView(android.widget.TextView) EmojiImageView(org.thoughtcrime.securesms.components.emoji.EmojiImageView) TextView(android.widget.TextView) View(android.view.View) EmojiImageView(org.thoughtcrime.securesms.components.emoji.EmojiImageView)

Example 9 with TabLayout

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

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 10 with TabLayout

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

the class RxTabLayoutTest method selectionEventsNoInitial.

@Test
@UiThreadTest
public void selectionEventsNoInitial() {
    TabLayout empty = new TabLayout(context);
    RecordingObserver<TabLayoutSelectionEvent> o = new RecordingObserver<>();
    RxTabLayout.selectionEvents(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)

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