use of com.google.android.material.tabs.TabLayoutMediator 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);
}
use of com.google.android.material.tabs.TabLayoutMediator in project nextcloud-notes by stefan-niedermann.
the class AboutActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = ActivityAboutBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
setSupportActionBar(binding.toolbar);
binding.pager.setAdapter(new TabsStateAdapter(this));
// generate title based on given position
new TabLayoutMediator(binding.tabs, binding.pager, (tab, position) -> {
switch(position) {
// Fall-through to credits tab
default:
case POS_CREDITS:
tab.setText(R.string.about_credits_tab_title);
break;
case POS_CONTRIB:
tab.setText(R.string.about_contribution_tab_title);
break;
case POS_LICENSE:
tab.setText(R.string.about_license_tab_title);
break;
}
}).attach();
}
use of com.google.android.material.tabs.TabLayoutMediator in project AntennaPod by AntennaPod.
the class DownloadsFragment method onCreateView.
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View root = inflater.inflate(R.layout.pager_fragment, container, false);
Toolbar toolbar = root.findViewById(R.id.toolbar);
toolbar.setTitle(R.string.downloads_label);
toolbar.inflateMenu(R.menu.downloads);
displayUpArrow = getParentFragmentManager().getBackStackEntryCount() != 0;
if (savedInstanceState != null) {
displayUpArrow = savedInstanceState.getBoolean(KEY_UP_ARROW);
}
((MainActivity) getActivity()).setupToolbarToggle(toolbar, displayUpArrow);
viewPager = root.findViewById(R.id.viewpager);
viewPager.setAdapter(new DownloadsPagerAdapter(this));
viewPager.setOffscreenPageLimit(2);
super.setupPagedToolbar(toolbar, viewPager);
// Give the TabLayout the ViewPager
tabLayout = root.findViewById(R.id.sliding_tabs);
new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> {
switch(position) {
case POS_COMPLETED:
tab.setText(R.string.downloads_completed_label);
break;
case POS_LOG:
tab.setText(R.string.downloads_log_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 root;
}
use of com.google.android.material.tabs.TabLayoutMediator in project AntennaPod by AntennaPod.
the class StatisticsFragment method onCreateView.
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
setHasOptionsMenu(true);
View rootView = inflater.inflate(R.layout.pager_fragment, container, false);
viewPager = rootView.findViewById(R.id.viewpager);
toolbar = rootView.findViewById(R.id.toolbar);
viewPager.setAdapter(new StatisticsPagerAdapter(this));
// Give the TabLayout the ViewPager
tabLayout = rootView.findViewById(R.id.sliding_tabs);
new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> {
switch(position) {
case POS_LISTENED_HOURS:
tab.setText(R.string.playback_statistics_label);
break;
case POS_SPACE_TAKEN:
tab.setText(R.string.download_statistics_label);
break;
default:
break;
}
}).attach();
if (getActivity().getClass() == PreferenceActivity.class) {
rootView.findViewById(R.id.toolbar).setVisibility(View.GONE);
} else {
toolbar.setTitle(getString(R.string.statistics_label));
toolbar.setNavigationOnClickListener(v -> getParentFragmentManager().popBackStack());
}
return rootView;
}
use of com.google.android.material.tabs.TabLayoutMediator in project AntennaPod by AntennaPod.
the class ContributorsPagerFragment method onCreateView.
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
setHasOptionsMenu(true);
View rootView = inflater.inflate(R.layout.pager_fragment, container, false);
ViewPager2 viewPager = rootView.findViewById(R.id.viewpager);
viewPager.setAdapter(new StatisticsPagerAdapter(this));
// Give the TabLayout the ViewPager
TabLayout tabLayout = rootView.findViewById(R.id.sliding_tabs);
new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> {
switch(position) {
case POS_DEVELOPERS:
tab.setText(R.string.developers);
break;
case POS_TRANSLATORS:
tab.setText(R.string.translators);
break;
case POS_SPECIAL_THANKS:
tab.setText(R.string.special_thanks);
break;
default:
break;
}
}).attach();
rootView.findViewById(R.id.toolbar).setVisibility(View.GONE);
return rootView;
}
Aggregations