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

BridgeActionBar

public abstract class BridgeActionBar extends Object
An abstraction over two implementations of the ActionBar - framework and appcompat.

Fields Summary
protected final com.android.layoutlib.bridge.android.BridgeContext
mBridgeContext
protected final com.android.ide.common.rendering.api.SessionParams
mParams
protected final android.view.ViewGroup
mEnclosingLayout
private final android.view.View
mDecorContent
private final com.android.ide.common.rendering.api.ActionBarCallback
mCallback
private android.widget.FrameLayout
mContentRoot
Constructors Summary
public BridgeActionBar(com.android.layoutlib.bridge.android.BridgeContext context, com.android.ide.common.rendering.api.SessionParams params, android.view.ViewGroup parentView)

        mBridgeContext = context;
        mParams = params;
        mCallback = params.getProjectCallback().getActionBarCallback();
        ResourceValue layoutName = getLayoutResource(context);
        if (layoutName == null) {
            throw new RuntimeException("Unable to find the layout for Action Bar.");
        }
        int layoutId;
        if (layoutName.isFramework()) {
            layoutId = context.getFrameworkResourceValue(layoutName.getResourceType(),
                    layoutName.getName(), 0);
        } else {
            layoutId = context.getProjectResourceValue(layoutName.getResourceType(),
                    layoutName.getName(), 0);

        }
        if (layoutId == 0) {
            throw new RuntimeException(
                    String.format("Unable to resolve attribute \"%1$s\" of type \"%2$s\"",
                            layoutName.getName(), layoutName.getResourceType()));
        }
        if (mCallback.isOverflowPopupNeeded()) {
            // Create a RelativeLayout around the action bar, to which the overflow popup may be
            // added.
            mEnclosingLayout = new RelativeLayout(mBridgeContext);
            setMatchParent(mEnclosingLayout);
            parentView.addView(mEnclosingLayout);
        } else {
            mEnclosingLayout = parentView;
        }

        // Inflate action bar layout.
        mDecorContent = LayoutInflater.from(context).inflate(layoutId, mEnclosingLayout, true);

    
Methods Summary
public abstract voidcreateMenuPopup()

public com.android.ide.common.rendering.api.ActionBarCallbackgetCallBack()

        return mCallback;
    
public android.widget.FrameLayoutgetContentRoot()

        return mContentRoot;
    
protected android.view.ViewgetDecorContent()
Returns the view inflated. This should contain both the ActionBar and the app content in it.

        return mDecorContent;
    
protected abstract com.android.ide.common.rendering.api.ResourceValuegetLayoutResource(com.android.layoutlib.bridge.android.BridgeContext context)
Returns the Layout Resource that should be used to inflate the action bar. This layout should cover the complete screen, and have a FrameLayout included, where the content will be inflated.

protected voidsetContentRoot(android.widget.FrameLayout contentRoot)

        mContentRoot = contentRoot;
    
protected abstract voidsetHomeAsUp(boolean homeAsUp)

private voidsetIcon()

        String appIcon = mParams.getAppIcon();
        if (appIcon != null) {
            setIcon(appIcon);
        }
    
protected abstract voidsetIcon(java.lang.String icon)

protected static voidsetMatchParent(android.view.View view)

        view.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
                LayoutParams.MATCH_PARENT));
    
protected abstract voidsetSubtitle(java.lang.CharSequence subtitle)

private voidsetSutTitle()

        String subTitle = mCallback.getSubTitle();
        if (subTitle != null) {
            setSubtitle(subTitle);
        }
    
private voidsetTitle()

        RenderResources res = mBridgeContext.getRenderResources();

        String title = mParams.getAppLabel();
        ResourceValue titleValue = res.findResValue(title, false);
        if (titleValue != null && titleValue.getValue() != null) {
            setTitle(titleValue.getValue());
        } else {
            setTitle(title);
        }
    
protected abstract voidsetTitle(java.lang.CharSequence title)

protected voidsetupActionBar()
Setup things like the title, subtitle, icon etc.

        setTitle();
        setSutTitle();
        setIcon();
        setHomeAsUp(mCallback.getHomeButtonStyle() == HomeButtonStyle.SHOW_HOME_AS_UP);