use of com.google.android.material.tabs.TabLayoutMediator in project AntennaPod by AntennaPod.
the class GpodnetMainFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View root = inflater.inflate(R.layout.pager_fragment, container, false);
setupToolbar(root.findViewById(R.id.toolbar));
ViewPager2 viewPager = root.findViewById(R.id.viewpager);
GpodnetPagerAdapter pagerAdapter = new GpodnetPagerAdapter(this);
viewPager.setAdapter(pagerAdapter);
// Give the TabLayout the ViewPager
TabLayout tabLayout = root.findViewById(R.id.sliding_tabs);
new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> {
switch(position) {
case POS_TAGS:
tab.setText(R.string.gpodnet_taglist_header);
break;
// Fall-through
case POS_TOPLIST:
default:
tab.setText(R.string.gpodnet_toplist_header);
break;
}
}).attach();
return root;
}
use of com.google.android.material.tabs.TabLayoutMediator in project AntennaPod by AntennaPod.
the class EpisodesFragment method onCreateView.
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View rootView = inflater.inflate(R.layout.pager_fragment, container, false);
Toolbar toolbar = rootView.findViewById(R.id.toolbar);
toolbar.setTitle(R.string.episodes_label);
toolbar.inflateMenu(R.menu.episodes);
displayUpArrow = getParentFragmentManager().getBackStackEntryCount() != 0;
if (savedInstanceState != null) {
displayUpArrow = savedInstanceState.getBoolean(KEY_UP_ARROW);
}
((MainActivity) getActivity()).setupToolbarToggle(toolbar, displayUpArrow);
ViewPager2 viewPager = rootView.findViewById(R.id.viewpager);
viewPager.setAdapter(new EpisodesPagerAdapter(this));
viewPager.setOffscreenPageLimit(2);
super.setupPagedToolbar(toolbar, viewPager);
// Give the TabLayout the ViewPager
tabLayout = rootView.findViewById(R.id.sliding_tabs);
new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> {
switch(position) {
case POS_NEW_EPISODES:
tab.setText(R.string.new_episodes_label);
break;
case POS_ALL_EPISODES:
tab.setText(R.string.all_episodes_short_label);
break;
case POS_FAV_EPISODES:
tab.setText(R.string.favorite_episodes_label);
break;
default:
break;
}
}).attach();
// restore our last position
SharedPreferences prefs = getActivity().getSharedPreferences(TAG, Context.MODE_PRIVATE);
int lastPosition = prefs.getInt(PREF_LAST_TAB_POSITION, 0);
viewPager.setCurrentItem(lastPosition, false);
return rootView;
}
use of com.google.android.material.tabs.TabLayoutMediator 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();
}
}
use of com.google.android.material.tabs.TabLayoutMediator 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);
}
use of com.google.android.material.tabs.TabLayoutMediator in project collect by opendatakit.
the class DeleteSavedFormActivity method setUpViewPager.
private void setUpViewPager() {
String[] tabNames = { getString(R.string.data), getString(R.string.forms) };
ViewPager2 viewPager = findViewById(R.id.viewPager);
TabLayout tabLayout = findViewById(R.id.tabLayout);
viewPager.setAdapter(new DeleteFormsTabsAdapter(this, viewModel.isMatchExactlyEnabled()));
new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> tab.setText(tabNames[position])).attach();
}
Aggregations