Example usage for android.widget ActionMenuPresenter setExpandedActionViewsExclusive

List of usage examples for android.widget ActionMenuPresenter setExpandedActionViewsExclusive

Introduction

In this page you can find the example usage for android.widget ActionMenuPresenter setExpandedActionViewsExclusive.

Prototype

public void setExpandedActionViewsExclusive(boolean isExclusive) 

Source Link

Usage

From source file:android.support.v7.widget.Toolbar.java

/** @hide */
public void setMenu(MenuBuilder menu, ActionMenuPresenter outerPresenter) {
    if (menu == null && mMenuView == null) {
        return;/*from   w w  w.  j  a v  a2  s  . c o m*/
    }

    ensureMenuView();
    final MenuBuilder oldMenu = mMenuView.peekMenu();
    if (oldMenu == menu) {
        return;
    }

    if (oldMenu != null) {
        oldMenu.removeMenuPresenter(mOuterActionMenuPresenter);
        oldMenu.removeMenuPresenter(mExpandedMenuPresenter);
    }

    if (mExpandedMenuPresenter == null) {
        mExpandedMenuPresenter = new ExpandedActionViewMenuPresenter();
    }

    outerPresenter.setExpandedActionViewsExclusive(true);
    if (menu != null) {
        menu.addMenuPresenter(outerPresenter, mPopupContext);
        menu.addMenuPresenter(mExpandedMenuPresenter, mPopupContext);
    } else {
        outerPresenter.initForMenu(mPopupContext, null);
        mExpandedMenuPresenter.initForMenu(mPopupContext, null);
        outerPresenter.updateMenuView(true);
        mExpandedMenuPresenter.updateMenuView(true);
    }
    mMenuView.setPopupTheme(mPopupTheme);
    mMenuView.setPresenter(outerPresenter);
    mOuterActionMenuPresenter = outerPresenter;
}

From source file:lewa.support.v7.widget.Toolbar.java

public void setMenu(MenuBuilder menu, ActionMenuPresenter outerPresenter) {
    if (menu == null && mMenuView == null) {
        return;//  w w  w . ja  va2  s  . c  om
    }

    //       ensureMenuView();
    if (mMenuView != null) {
        final MenuBuilder oldMenu = mMenuView.peekMenu();
        if (oldMenu == menu) {
            return;
        }

        if (oldMenu != null) {
            oldMenu.removeMenuPresenter(mOuterActionMenuPresenter);
            //                oldMenu.removeMenuPresenter(mExpandedMenuPresenter);
        }
    }

    if (mExpandedMenuPresenter == null) {
        mExpandedMenuPresenter = new ExpandedActionViewMenuPresenter();
    }
    mActionMenuPresenter = outerPresenter;
    outerPresenter.setExpandedActionViewsExclusive(false);
    if (menu != null) {
        menu.addMenuPresenter(outerPresenter, mPopupContext);
        final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.MATCH_PARENT);
        mActionMenuPresenter.setReserveOverflow(true);
        mActionMenuPresenter.setWidthLimit(getContext().getResources().getDisplayMetrics().widthPixels, true);
        // No limit to the item count; use whatever will fit.
        mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE);
        // Span the whole width
        layoutParams.width = LayoutParams.MATCH_PARENT;
        int actionbarHeight = ActionBarPolicy.get(mContext).getTabContainerHeight();
        layoutParams.height = actionbarHeight;
        //            layoutParams.height = mContentHeight;
        mMenuView = (ActionMenuView) outerPresenter.getMenuView(this);
        //            menu.addMenuPresenter(mExpandedMenuPresenter, mPopupContext);
        //            final LayoutParams lp = generateDefaultLayoutParams();
        //            lp.gravity = GravityCompat.END | (mButtonGravity & Gravity.VERTICAL_GRAVITY_MASK);
        //            lp.gravity = 
        //            lp.width = LayoutParams.MATCH_PARENT;
        //            mMenuView.setLayoutParams(lp);
        //            ((LewaActionBarContainer) mSplitView)
        //            .getActionMenuBar().addView(mMenuView, layoutParams);
        Injector.addActionOptionMenu(this, menu, layoutParams);
    } else {
        outerPresenter.initForMenu(mPopupContext, null);
        mExpandedMenuPresenter.initForMenu(mPopupContext, null);
        outerPresenter.updateMenuView(true);
        mExpandedMenuPresenter.updateMenuView(true);
    }
    //        mMenuView.setPopupTheme(mPopupTheme);
    //        mMenuView.setPresenter(outerPresenter);

}