FileDocCategorySizeDatePackage
ToolbarActionBar.javaAPI DocAndroid 5.1 API16372Thu Mar 12 22:22:10 GMT 2015com.android.internal.app

ToolbarActionBar

public class ToolbarActionBar extends android.app.ActionBar

Fields Summary
private com.android.internal.widget.DecorToolbar
mDecorToolbar
private boolean
mToolbarMenuPrepared
private Window.Callback
mWindowCallback
private boolean
mMenuCallbackSet
private boolean
mLastMenuVisibility
private ArrayList
mMenuVisibilityListeners
private final Runnable
mMenuInvalidator
private final Toolbar.OnMenuItemClickListener
mMenuClicker
Constructors Summary
public ToolbarActionBar(android.widget.Toolbar toolbar, CharSequence title, Window.Callback windowCallback)


           
        mDecorToolbar = new ToolbarWidgetWrapper(toolbar, false);
        mWindowCallback = new ToolbarCallbackWrapper(windowCallback);
        mDecorToolbar.setWindowCallback(mWindowCallback);
        toolbar.setOnMenuItemClickListener(mMenuClicker);
        mDecorToolbar.setWindowTitle(title);
    
Methods Summary
public voidaddOnMenuVisibilityListener(OnMenuVisibilityListener listener)

        mMenuVisibilityListeners.add(listener);
    
public voidaddTab(Tab tab)

        throw new UnsupportedOperationException(
                "Tabs are not supported in toolbar action bars");
    
public voidaddTab(Tab tab, boolean setSelected)

        throw new UnsupportedOperationException(
                "Tabs are not supported in toolbar action bars");
    
public voidaddTab(Tab tab, int position)

        throw new UnsupportedOperationException(
                "Tabs are not supported in toolbar action bars");
    
public voidaddTab(Tab tab, int position, boolean setSelected)

        throw new UnsupportedOperationException(
                "Tabs are not supported in toolbar action bars");
    
public booleancollapseActionView()

        if (mDecorToolbar.hasExpandedActionView()) {
            mDecorToolbar.collapseActionView();
            return true;
        }
        return false;
    
public voiddispatchMenuVisibilityChanged(boolean isVisible)

        if (isVisible == mLastMenuVisibility) {
            return;
        }
        mLastMenuVisibility = isVisible;

        final int count = mMenuVisibilityListeners.size();
        for (int i = 0; i < count; i++) {
            mMenuVisibilityListeners.get(i).onMenuVisibilityChanged(isVisible);
        }
    
public android.view.ViewgetCustomView()

        return mDecorToolbar.getCustomView();
    
public intgetDisplayOptions()

        return mDecorToolbar.getDisplayOptions();
    
public floatgetElevation()

        return mDecorToolbar.getViewGroup().getElevation();
    
public intgetHeight()

        return mDecorToolbar.getHeight();
    
public intgetNavigationItemCount()

        return 0;
    
public intgetNavigationMode()

        return NAVIGATION_MODE_STANDARD;
    
public intgetSelectedNavigationIndex()

        return -1;
    
public TabgetSelectedTab()

        throw new UnsupportedOperationException(
                "Tabs are not supported in toolbar action bars");
    
public java.lang.CharSequencegetSubtitle()

        return mDecorToolbar.getSubtitle();
    
public TabgetTabAt(int index)

        throw new UnsupportedOperationException(
                "Tabs are not supported in toolbar action bars");
    
public intgetTabCount()

        return 0;
    
public android.content.ContextgetThemedContext()

        return mDecorToolbar.getContext();
    
public java.lang.CharSequencegetTitle()

        return mDecorToolbar.getTitle();
    
public Window.CallbackgetWrappedWindowCallback()

        return mWindowCallback;
    
public voidhide()

        // TODO: Consider a better transition for this.
        // Right now use no automatic transition so that the app can supply one if desired.
        mDecorToolbar.setVisibility(View.GONE);
    
public booleaninvalidateOptionsMenu()

        mDecorToolbar.getViewGroup().removeCallbacks(mMenuInvalidator);
        mDecorToolbar.getViewGroup().postOnAnimation(mMenuInvalidator);
        return true;
    
public booleanisShowing()

        return mDecorToolbar.getVisibility() == View.VISIBLE;
    
public booleanisTitleTruncated()

        return super.isTitleTruncated();
    
public TabnewTab()

        throw new UnsupportedOperationException(
                "Tabs are not supported in toolbar action bars");
    
public voidonConfigurationChanged(android.content.res.Configuration config)

        super.onConfigurationChanged(config);
    
public booleanonMenuKeyEvent(android.view.KeyEvent event)

        if (event.getAction() == KeyEvent.ACTION_UP) {
            openOptionsMenu();
        }
        return true;
    
public booleanopenOptionsMenu()

        return mDecorToolbar.showOverflowMenu();
    
voidpopulateOptionsMenu()

        if (!mMenuCallbackSet) {
            mDecorToolbar.setMenuCallbacks(new ActionMenuPresenterCallback(), new MenuBuilderCallback());
            mMenuCallbackSet = true;
        }
        final Menu menu = mDecorToolbar.getMenu();
        final MenuBuilder mb = menu instanceof MenuBuilder ? (MenuBuilder) menu : null;
        if (mb != null) {
            mb.stopDispatchingItemsChanged();
        }
        try {
            menu.clear();
            if (!mWindowCallback.onCreatePanelMenu(Window.FEATURE_OPTIONS_PANEL, menu) ||
                    !mWindowCallback.onPreparePanel(Window.FEATURE_OPTIONS_PANEL, null, menu)) {
                menu.clear();
            }
        } finally {
            if (mb != null) {
                mb.startDispatchingItemsChanged();
            }
        }
    
public voidremoveAllTabs()

        throw new UnsupportedOperationException(
                "Tabs are not supported in toolbar action bars");
    
public voidremoveOnMenuVisibilityListener(OnMenuVisibilityListener listener)

        mMenuVisibilityListeners.remove(listener);
    
public voidremoveTab(Tab tab)

        throw new UnsupportedOperationException(
                "Tabs are not supported in toolbar action bars");
    
public voidremoveTabAt(int position)

        throw new UnsupportedOperationException(
                "Tabs are not supported in toolbar action bars");
    
public voidselectTab(Tab tab)

        throw new UnsupportedOperationException(
                "Tabs are not supported in toolbar action bars");
    
public voidsetBackgroundDrawable(android.graphics.drawable.Drawable d)

        mDecorToolbar.setBackgroundDrawable(d);
    
public voidsetCustomView(android.view.View view)

        setCustomView(view, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    
public voidsetCustomView(android.view.View view, LayoutParams layoutParams)

        view.setLayoutParams(layoutParams);
        mDecorToolbar.setCustomView(view);
    
public voidsetCustomView(int resId)

        final LayoutInflater inflater = LayoutInflater.from(mDecorToolbar.getContext());
        setCustomView(inflater.inflate(resId, mDecorToolbar.getViewGroup(), false));
    
public voidsetDefaultDisplayHomeAsUpEnabled(boolean enabled)

        // Do nothing
    
public voidsetDisplayHomeAsUpEnabled(boolean showHomeAsUp)

        setDisplayOptions(showHomeAsUp ? DISPLAY_HOME_AS_UP : 0, DISPLAY_HOME_AS_UP);
    
public voidsetDisplayOptions(int options)

        setDisplayOptions(options, 0xffffffff);
    
public voidsetDisplayOptions(int options, int mask)

        final int currentOptions = mDecorToolbar.getDisplayOptions();
        mDecorToolbar.setDisplayOptions(options & mask | currentOptions & ~mask);
    
public voidsetDisplayShowCustomEnabled(boolean showCustom)

        setDisplayOptions(showCustom ? DISPLAY_SHOW_CUSTOM : 0, DISPLAY_SHOW_CUSTOM);
    
public voidsetDisplayShowHomeEnabled(boolean showHome)

        setDisplayOptions(showHome ? DISPLAY_SHOW_HOME : 0, DISPLAY_SHOW_HOME);
    
public voidsetDisplayShowTitleEnabled(boolean showTitle)

        setDisplayOptions(showTitle ? DISPLAY_SHOW_TITLE : 0, DISPLAY_SHOW_TITLE);
    
public voidsetDisplayUseLogoEnabled(boolean useLogo)

        setDisplayOptions(useLogo ? DISPLAY_USE_LOGO : 0, DISPLAY_USE_LOGO);
    
public voidsetElevation(float elevation)

        mDecorToolbar.getViewGroup().setElevation(elevation);
    
public voidsetHomeActionContentDescription(java.lang.CharSequence description)

        mDecorToolbar.setNavigationContentDescription(description);
    
public voidsetHomeActionContentDescription(int resId)

        mDecorToolbar.setNavigationContentDescription(resId);
    
public voidsetHomeAsUpIndicator(android.graphics.drawable.Drawable indicator)

        mDecorToolbar.setNavigationIcon(indicator);
    
public voidsetHomeAsUpIndicator(int resId)

        mDecorToolbar.setNavigationIcon(resId);
    
public voidsetHomeButtonEnabled(boolean enabled)

        // If the nav button on a Toolbar is present, it's enabled. No-op.
    
public voidsetIcon(int resId)

        mDecorToolbar.setIcon(resId);
    
public voidsetIcon(android.graphics.drawable.Drawable icon)

        mDecorToolbar.setIcon(icon);
    
public voidsetListNavigationCallbacks(android.widget.SpinnerAdapter adapter, OnNavigationListener callback)

        mDecorToolbar.setDropdownParams(adapter, new NavItemSelectedListener(callback));
    
public voidsetLogo(int resId)

        mDecorToolbar.setLogo(resId);
    
public voidsetLogo(android.graphics.drawable.Drawable logo)

        mDecorToolbar.setLogo(logo);
    
public voidsetNavigationMode(int mode)

        if (mode == ActionBar.NAVIGATION_MODE_TABS) {
            throw new IllegalArgumentException("Tabs not supported in this configuration");
        }
        mDecorToolbar.setNavigationMode(mode);
    
public voidsetSelectedNavigationItem(int position)

        switch (mDecorToolbar.getNavigationMode()) {
            case NAVIGATION_MODE_LIST:
                mDecorToolbar.setDropdownSelectedPosition(position);
                break;
            default:
                throw new IllegalStateException(
                        "setSelectedNavigationIndex not valid for current navigation mode");
        }
    
public voidsetShowHideAnimationEnabled(boolean enabled)

        // This space for rent; no-op.
    
public voidsetSplitBackgroundDrawable(android.graphics.drawable.Drawable d)

        // This space for rent (do nothing)
    
public voidsetStackedBackgroundDrawable(android.graphics.drawable.Drawable d)

        // This space for rent (do nothing)
    
public voidsetSubtitle(java.lang.CharSequence subtitle)

        mDecorToolbar.setSubtitle(subtitle);
    
public voidsetSubtitle(int resId)

        mDecorToolbar.setSubtitle(resId != 0 ? mDecorToolbar.getContext().getText(resId) : null);
    
public voidsetTitle(java.lang.CharSequence title)

        mDecorToolbar.setTitle(title);
    
public voidsetTitle(int resId)

        mDecorToolbar.setTitle(resId != 0 ? mDecorToolbar.getContext().getText(resId) : null);
    
public voidsetWindowTitle(java.lang.CharSequence title)

        mDecorToolbar.setWindowTitle(title);
    
public voidshow()

        // TODO: Consider a better transition for this.
        // Right now use no automatic transition so that the app can supply one if desired.
        mDecorToolbar.setVisibility(View.VISIBLE);
    
public android.view.ActionModestartActionMode(ActionMode.Callback callback)

        return null;