Java Code Examples for com.google.android.material.tabs.TabLayout#setVisibility()

The following examples show how to use com.google.android.material.tabs.TabLayout#setVisibility() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CPUBoostActivity.java    From SmartPack-Kernel-Manager with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tablayout);

    TabLayout tabLayout = findViewById(R.id.tabLayoutID);
    ViewPager viewPager = findViewById(R.id.viewPagerID);

    PagerAdapter adapter = new PagerAdapter(getSupportFragmentManager());
    if (CPUBoost.getInstance().supported() || CPUInputBoost.getInstance().supported()) {
        adapter.AddFragment(new CPUBoostFragment(), getString(R.string.cpu_boost));
    }
    if (VoxPopuli.hasVoxpopuliTunable()) {
        adapter.AddFragment(new PowerHalFragment(), getString(R.string.powerhal));
    }
    if (StuneBoost.supported()) {
        adapter.AddFragment(new StuneBoostFragment(), getString(R.string.stune_boost));
    }

    viewPager.setAdapter(adapter);
    tabLayout.setVisibility(View.VISIBLE);
    ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) viewPager.getLayoutParams();
    lp.bottomMargin += 150;
    tabLayout.setupWithViewPager(viewPager);
}
 
Example 2
Source File: MainActivity.java    From AndroidAPS with GNU Affero General Public License v3.0 6 votes vote down vote up
private void setupTabs() {
    ViewPager viewPager = findViewById(R.id.pager);
    TabLayout normalTabs = findViewById(R.id.tabs_normal);
    normalTabs.setupWithViewPager(viewPager, true);
    TabLayout compactTabs = findViewById(R.id.tabs_compact);
    compactTabs.setupWithViewPager(viewPager, true);
    Toolbar toolbar = findViewById(R.id.toolbar);
    if (SP.getBoolean("short_tabtitles", false)) {
        normalTabs.setVisibility(View.GONE);
        compactTabs.setVisibility(View.VISIBLE);
        toolbar.setLayoutParams(new LinearLayout.LayoutParams(Toolbar.LayoutParams.MATCH_PARENT, (int) getResources().getDimension(R.dimen.compact_height)));
    } else {
        normalTabs.setVisibility(View.VISIBLE);
        compactTabs.setVisibility(View.GONE);
        TypedValue typedValue = new TypedValue();
        if (getTheme().resolveAttribute(R.attr.actionBarSize, typedValue, true)) {
            toolbar.setLayoutParams(new LinearLayout.LayoutParams(Toolbar.LayoutParams.MATCH_PARENT,
                    TypedValue.complexToDimensionPixelSize(typedValue.data, getResources().getDisplayMetrics())));
        }
    }
}
 
Example 3
Source File: BaseListActivity.java    From materialistic with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("ConstantConditions")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_list);
    setTitle(getDefaultTitle());
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME |
            ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE);
    findViewById(R.id.toolbar).setOnClickListener(v -> {
        Scrollable scrollable = getScrollableList();
        if (scrollable != null) {
            scrollable.scrollToTop();
        }
    });
    mAppBar = (AppBarLayout) findViewById(R.id.appbar);
    mIsMultiPane = getResources().getBoolean(R.bool.multi_pane);
    if (mIsMultiPane) {
        LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver,
                new IntentFilter(WebFragment.ACTION_FULLSCREEN));
        mListView = findViewById(android.R.id.list);
        mTabLayout = (TabLayout) findViewById(R.id.tab_layout);
        mTabLayout.setVisibility(View.GONE);
        mViewPager = (ViewPager) findViewById(R.id.content);
        mViewPager.setVisibility(View.GONE);
        mReplyButton = (FloatingActionButton) findViewById(R.id.reply_button);
        mNavButton = (NavFloatingActionButton) findViewById(R.id.navigation_button);
        mNavButton.setNavigable(direction ->
                // if callback is fired navigable should not be null
                ((Navigable) ((ItemPagerAdapter) mViewPager.getAdapter()).getItem(0))
                        .onNavigate(direction));
        AppUtils.toggleFab(mNavButton, false);
        AppUtils.toggleFab(mReplyButton, false);
    }
    mMultiWindowEnabled = Preferences.multiWindowEnabled(this);
    mStoryViewMode = Preferences.getDefaultStoryView(this);
    mExternalBrowser = Preferences.externalBrowserEnabled(this);
    if (savedInstanceState == null) {
        getSupportFragmentManager()
                .beginTransaction()
                .replace(android.R.id.list,
                        instantiateListFragment(),
                        LIST_FRAGMENT_TAG)
                .commit();
    } else {
        mSelectedItem = savedInstanceState.getParcelable(STATE_SELECTED_ITEM);
        mFullscreen = savedInstanceState.getBoolean(STATE_FULLSCREEN);
        if (mIsMultiPane) {
            openMultiPaneItem();
        } else {
            unbindViewPager();
        }
    }
    mPreferenceObservable.subscribe(this, this::onPreferenceChanged,
            R.string.pref_navigation,
            R.string.pref_external,
            R.string.pref_story_display,
            R.string.pref_multi_window);
}
 
Example 4
Source File: MobiComKitPeopleActivity.java    From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (!MobiComUserPreference.getInstance(this).isLoggedIn()) {
        finish();
    }
    setContentView(R.layout.people_activity);
    String jsonString = FileUtils.loadSettingsJsonFile(getApplicationContext());
    if (!TextUtils.isEmpty(jsonString)) {
        alCustomizationSettings = (AlCustomizationSettings) GsonUtils.getObjectFromJson(jsonString, AlCustomizationSettings.class);
    } else {
        alCustomizationSettings = new AlCustomizationSettings();
    }

    onContactsInteractionListener = this;
    Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
    setSupportActionBar(myToolbar);
    // Set up the action bar.
    actionBar = getSupportActionBar();
    if (!TextUtils.isEmpty(alCustomizationSettings.getThemeColorPrimary()) && !TextUtils.isEmpty(alCustomizationSettings.getThemeColorPrimaryDark())) {
        actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor(alCustomizationSettings.getThemeColorPrimary())));
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            getWindow().setStatusBarColor(Color.parseColor(alCustomizationSettings.getThemeColorPrimaryDark()));
        }
    }
    actionBar.setHomeButtonEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowTitleEnabled(true);


    intentExtra = getIntent();
    action = intentExtra.getAction();
    type = intentExtra.getType();

    if (getIntent().getExtras() != null) {
        if (Intent.ACTION_SEND.equals(action) && type != null) {
            actionBar.setTitle(getString(R.string.send_message_to));
        } else {
            actionBar.setTitle(getString(R.string.search_title));
            userIdArray = getIntent().getStringArrayExtra(USER_ID_ARRAY);
        }
    } else {
        actionBar.setTitle(getString(R.string.search_title));
    }
    appContactFragment = new AppContactFragment(userIdArray);
    appContactFragment.setAlCustomizationSettings(alCustomizationSettings);
    channelFragment = new ChannelFragment();
    setSearchListFragment(appContactFragment);
    if (alCustomizationSettings.isGroupsSectionTabHidden() || ApplozicSetting.getInstance(this).isGroupsSectionTabHidden()) {
        addFragment(this, appContactFragment, "AppContactFragment");
    } else {
        viewPager = (ViewPager) findViewById(R.id.viewPager);
        viewPager.setVisibility(View.VISIBLE);
        setupViewPager(viewPager);
        tabLayout = (TabLayout) findViewById(R.id.tab_layout);
        tabLayout.setVisibility(View.VISIBLE);
        tabLayout.setupWithViewPager(viewPager);
        tabLayout.addOnTabSelectedListener(this);
    }

    // This flag notes that the Activity is doing a search, and so the result will be
    // search results rather than all contacts. This prevents the Activity and Fragment
    // from trying to a search on search results.
    isSearchResultView = true;
}