Search in sources :

Example 31 with TabLayout

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

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    adapter = new PickerAdapter(getSupportFragmentManager());
    viewPager = findViewById(R.id.pager);
    viewPager.setAdapter(adapter);
    setSupportActionBar(findViewById(R.id.toolbar));
    TabLayout tabLayout = findViewById(R.id.tabs);
    tabLayout.setupWithViewPager(viewPager);
    for (// noinspection ConstantConditions
    int i = 0; // noinspection ConstantConditions
    i < adapter.getCount(); // noinspection ConstantConditions
    i++) tabLayout.getTabAt(i).setText(adapter.getTitle(i));
}
Also used : TabLayout(com.google.android.material.tabs.TabLayout)

Example 32 with TabLayout

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

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)

Example 33 with TabLayout

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

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

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

the class Discover method onCreate.

@Override
public void onCreate(Bundle savedInstance) {
    overrideSwipeFromAnywhere();
    super.onCreate(savedInstance);
    applyColorTheme("");
    setContentView(R.layout.activity_multireddits);
    ((DrawerLayout) findViewById(R.id.drawer_layout)).setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
    setupAppBar(R.id.toolbar, R.string.discover_title, true, false);
    mToolbar.setPopupTheme(new ColorPreferences(this).getFontStyle().getBaseId());
    findViewById(R.id.header).setBackgroundColor(Palette.getDefaultColor());
    TabLayout tabs = (TabLayout) findViewById(R.id.sliding_tabs);
    tabs.setTabMode(TabLayout.MODE_FIXED);
    tabs.setSelectedTabIndicatorColor(new ColorPreferences(Discover.this).getColor("no sub"));
    ViewPager pager = (ViewPager) findViewById(R.id.content_view);
    pager.setAdapter(new DiscoverPagerAdapter(getSupportFragmentManager()));
    tabs.setupWithViewPager(pager);
    pager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {

        @Override
        public void onPageSelected(int position) {
            findViewById(R.id.header).animate().translationY(0).setInterpolator(new LinearInterpolator()).setDuration(180);
        }
    });
}
Also used : ColorPreferences(me.ccrama.redditslide.Visuals.ColorPreferences) LinearInterpolator(android.view.animation.LinearInterpolator) TabLayout(com.google.android.material.tabs.TabLayout) DrawerLayout(androidx.drawerlayout.widget.DrawerLayout) ViewPager(androidx.viewpager.widget.ViewPager)

Example 35 with TabLayout

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

the class SoundChooserDialog method onCreateView.

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    view = inflater.inflate(R.layout.dialog_sound_chooser, container, false);
    Aesthetic.Companion.get().colorPrimary().take(1).subscribe(new Consumer<Integer>() {

        @Override
        public void accept(Integer integer) throws Exception {
            view.setBackgroundColor(integer);
        }
    });
    TabLayout tabLayout = view.findViewById(R.id.tabLayout);
    ViewPager viewPager = view.findViewById(R.id.viewPager);
    AlarmSoundChooserFragment alarmFragment = new AlarmSoundChooserFragment();
    RingtoneSoundChooserFragment ringtoneFragment = new RingtoneSoundChooserFragment();
    RadioSoundChooserFragment radioFragment = new RadioSoundChooserFragment();
    alarmFragment.setListener(this);
    ringtoneFragment.setListener(this);
    radioFragment.setListener(this);
    viewPager.setAdapter(new SimplePagerAdapter(getChildFragmentManager(), alarmFragment, ringtoneFragment, radioFragment));
    tabLayout.setupWithViewPager(viewPager);
    return view;
}
Also used : RadioSoundChooserFragment(james.alarmio.fragments.RadioSoundChooserFragment) TabLayout(com.google.android.material.tabs.TabLayout) AlarmSoundChooserFragment(james.alarmio.fragments.AlarmSoundChooserFragment) SimplePagerAdapter(james.alarmio.adapters.SimplePagerAdapter) ViewPager(androidx.viewpager.widget.ViewPager) RingtoneSoundChooserFragment(james.alarmio.fragments.RingtoneSoundChooserFragment) Nullable(androidx.annotation.Nullable)

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