FileDocCategorySizeDatePackage
FrameworkActionBarWrapper.javaAPI DocAndroid 5.1 API12502Thu Mar 12 22:22:44 GMT 2015com.android.layoutlib.bridge.bars

FrameworkActionBarWrapper

public abstract class FrameworkActionBarWrapper extends Object
A common API to access {@link ToolbarActionBar} and {@link WindowDecorActionBar}.

Fields Summary
protected android.app.ActionBar
mActionBar
protected com.android.ide.common.rendering.api.ActionBarCallback
mCallback
protected com.android.layoutlib.bridge.android.BridgeContext
mContext
Constructors Summary
FrameworkActionBarWrapper(com.android.layoutlib.bridge.android.BridgeContext context, com.android.ide.common.rendering.api.ActionBarCallback callback, android.app.ActionBar actionBar)

        mActionBar = actionBar;
        mCallback = callback;
        mContext = context;
    
Methods Summary
public static com.android.layoutlib.bridge.bars.FrameworkActionBarWrappergetActionBarWrapper(com.android.layoutlib.bridge.android.BridgeContext context, com.android.ide.common.rendering.api.ActionBarCallback callback, android.view.View decorContent)
Returns a wrapper around different implementations of the Action Bar to provide a common API.

param
decorContent the top level view returned by inflating ?attr/windowActionBarFullscreenDecorLayout

        View view = decorContent.findViewById(R.id.action_bar);
        if (view instanceof Toolbar) {
            return new ToolbarWrapper(context, callback, (Toolbar) view);
        } else if (view instanceof ActionBarView) {
            return new WindowActionBarWrapper(context, callback, decorContent,
                    (ActionBarView) view);
        } else {
            throw new IllegalStateException("Can't make an action bar out of " +
                    view.getClass().getSimpleName());
        }
    
protected android.content.ContextgetActionMenuContext()
The context used for the ActionBar and the menus in the ActionBarView.

        return mActionBar.getThemedContext();
    
abstract android.widget.ActionMenuPresentergetActionMenuPresenter()

abstract com.android.internal.widget.DecorToolbargetDecorToolbar()
Framework's wrapper over two ActionBar implementations.

abstract com.android.internal.view.menu.MenuBuildergetMenuBuilder()
The Menu in which to inflate the user's menus.

abstract intgetMenuPopupElevation()

abstract intgetMenuPopupMargin()
Margin between the menu popup and the action bar.

abstract android.content.ContextgetPopupContext()
The context used to inflate the popup menu.

protected voidinflateMenus()
Gets the menus to add to the action bar from the callback, resolves them, inflates them and adds them to the action bar.

        MenuInflater inflater = new MenuInflater(getActionMenuContext());
        MenuBuilder menuBuilder = getMenuBuilder();
        for (String name : mCallback.getMenuIdNames()) {
            int id;
            if (name.startsWith(ANDROID_NS_NAME_PREFIX)) {
                // Framework menu.
                name = name.substring(ANDROID_NS_NAME_PREFIX.length());
                id = mContext.getFrameworkResourceValue(MENU, name, -1);
            } else {
                // Project menu.
                id = mContext.getProjectResourceValue(MENU, name, -1);
            }
            if (id > -1) {
                inflater.inflate(id, menuBuilder);
            }
        }
    
protected booleanisOverflowPopupNeeded()

        return mCallback.isOverflowPopupNeeded();
    
protected booleanisSplit()

        return getDecorToolbar().isSplit();
    
public voidsetHomeAsUp(boolean homeAsUp)

        mActionBar.setDisplayHomeAsUpEnabled(homeAsUp);
    
public voidsetIcon(java.lang.String icon)

        // Nothing to do.
    
public voidsetSubTitle(java.lang.CharSequence subTitle)

        if (subTitle != null) {
            mActionBar.setSubtitle(subTitle);
        }
    
public voidsetTitle(java.lang.CharSequence title)

        mActionBar.setTitle(title);
    
protected voidsetupActionBar()
A call to setup any custom properties.

        // Nothing to do here.