Search in sources :

Example 1 with MenuBuilder

use of android.support.v7.view.menu.MenuBuilder in project HoloEverywhere by Prototik.

the class SwitchScreenPreference method onPrepareDialog.

@Override
void onPrepareDialog(Dialog dialog) {
    if (VERSION.SDK_INT < 11) {
        MenuBuilder builder = new MenuBuilder(dialog.getContext());
        onCreateOptionsMenu(builder);
        ActionBarView abv = (ActionBarView) dialog.getWindow().getDecorView().findViewById(R.id.action_bar);
        abv.setMenu(builder, this);
    }
}
Also used : ActionBarView(android.support.v7.internal.widget.ActionBarView) MenuBuilder(android.support.v7.internal.view.menu.MenuBuilder)

Example 2 with MenuBuilder

use of android.support.v7.view.menu.MenuBuilder in project HoloEverywhere by Prototik.

the class ActionBarActivityDelegateBase method onCreatePanelView.

@Override
public View onCreatePanelView(int featureId) {
    View createdPanelView = null;
    if (featureId == Window.FEATURE_OPTIONS_PANEL) {
        boolean show = true;
        MenuBuilder menu = mMenu;
        if (mActionMode == null) {
            if (menu == null) {
                // We don't have a menu created, so create one
                menu = createMenu();
                setMenu(menu);
                // Make sure we're not dispatching item changes to presenters
                menu.stopDispatchingItemsChanged();
                // Dispatch onCreateSupportOptionsMenu
                show = mActivity.superOnCreatePanelMenu(Window.FEATURE_OPTIONS_PANEL, menu);
            }
            if (show) {
                // Make sure we're not dispatching item changes to presenters
                menu.stopDispatchingItemsChanged();
                // Dispatch onPrepareSupportOptionsMenu
                show = mActivity.superOnPreparePanel(Window.FEATURE_OPTIONS_PANEL, null, menu);
            }
        }
        if (show) {
            createdPanelView = (View) getListMenuView(mActivity, this);
            // Allow menu to start dispatching changes to presenters
            menu.startDispatchingItemsChanged();
        } else {
            // If the menu isn't being shown, we no longer need it
            setMenu(null);
        }
    }
    return createdPanelView;
}
Also used : ActionBarContextView(android.support.v7.internal.widget.ActionBarContextView) MenuView(android.support.v7.internal.view.menu.MenuView) ActionBarView(android.support.v7.internal.widget.ActionBarView) View(android.view.View) MenuBuilder(android.support.v7.internal.view.menu.MenuBuilder)

Example 3 with MenuBuilder

use of android.support.v7.view.menu.MenuBuilder in project HoloEverywhere by Prototik.

the class ActionBarView method setMenu.

public void setMenu(SupportMenu menu, MenuPresenter.Callback cb) {
    if (menu == mOptionsMenu) {
        return;
    }
    if (mOptionsMenu != null) {
        mOptionsMenu.removeMenuPresenter(mActionMenuPresenter);
        mOptionsMenu.removeMenuPresenter(mExpandedMenuPresenter);
    }
    MenuBuilder builder = (MenuBuilder) menu;
    mOptionsMenu = builder;
    if (mMenuView != null) {
        final ViewGroup oldParent = (ViewGroup) mMenuView.getParent();
        if (oldParent != null) {
            oldParent.removeView(mMenuView);
        }
    }
    if (mActionMenuPresenter == null) {
        mActionMenuPresenter = new ActionMenuPresenter(mContext);
        mActionMenuPresenter.setCallback(cb);
        mActionMenuPresenter.setId(R.id.action_menu_presenter);
        mExpandedMenuPresenter = new ExpandedActionViewMenuPresenter();
    }
    ActionMenuView menuView;
    final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT);
    if (!mSplitActionBar) {
        mActionMenuPresenter.setExpandedActionViewsExclusive(getResources().getBoolean(R.bool.abc_action_bar_expanded_action_views_exclusive));
        configPresenters(builder);
        menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
        final ViewGroup oldParent = (ViewGroup) menuView.getParent();
        if (oldParent != null && oldParent != this) {
            oldParent.removeView(menuView);
        }
        addView(menuView, layoutParams);
    } else {
        mActionMenuPresenter.setExpandedActionViewsExclusive(false);
        // Allow full screen width in split mode.
        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.FILL_PARENT;
        configPresenters(builder);
        menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
        if (mSplitView != null) {
            final ViewGroup oldParent = (ViewGroup) menuView.getParent();
            if (oldParent != null && oldParent != mSplitView) {
                oldParent.removeView(menuView);
            }
            menuView.setVisibility(getAnimatedVisibility());
            mSplitView.addView(menuView, layoutParams);
        } else {
            // We'll add this later if we missed it this time.
            menuView.setLayoutParams(layoutParams);
        }
    }
    mMenuView = menuView;
}
Also used : ViewGroup(android.view.ViewGroup) ActionMenuView(android.support.v7.internal.view.menu.ActionMenuView) MenuBuilder(android.support.v7.internal.view.menu.MenuBuilder) SubMenuBuilder(android.support.v7.internal.view.menu.SubMenuBuilder) ActionMenuPresenter(android.support.v7.internal.view.menu.ActionMenuPresenter)

Example 4 with MenuBuilder

use of android.support.v7.view.menu.MenuBuilder in project Carbon by ZieIony.

the class Toolbar method ensureMenu.

private void ensureMenu() {
    ensureMenuView();
    if (mMenuView.peekMenu() == null) {
        // Initialize a new menu for the first time.
        final MenuBuilder menu = (MenuBuilder) mMenuView.getMenu();
        if (mExpandedMenuPresenter == null) {
            mExpandedMenuPresenter = new ExpandedActionViewMenuPresenter();
        }
        mMenuView.setExpandedActionViewsExclusive(true);
        menu.addMenuPresenter(mExpandedMenuPresenter, mPopupContext);
    }
}
Also used : MenuBuilder(android.support.v7.view.menu.MenuBuilder) SubMenuBuilder(android.support.v7.view.menu.SubMenuBuilder)

Example 5 with MenuBuilder

use of android.support.v7.view.menu.MenuBuilder in project Carbon by ZieIony.

the class FloatingActionMenu method setMenu.

public void setMenu(int resId) {
    Menu menu = new MenuBuilder(new CarbonContextWrapper(getContentView().getContext()));
    MenuInflater inflater = new MenuInflater(getContentView().getContext());
    inflater.inflate(resId, menu);
    setMenu(menu);
}
Also used : MenuInflater(android.view.MenuInflater) CarbonContextWrapper(carbon.CarbonContextWrapper) Menu(android.view.Menu) MenuBuilder(android.support.v7.view.menu.MenuBuilder)

Aggregations

MenuBuilder (android.support.v7.view.menu.MenuBuilder)8 MenuBuilder (android.support.v7.internal.view.menu.MenuBuilder)6 View (android.view.View)5 Menu (android.view.Menu)4 MenuInflater (android.view.MenuInflater)4 ViewGroup (android.view.ViewGroup)3 CarbonContextWrapper (carbon.CarbonContextWrapper)3 ActionMenuPresenter (android.support.v7.internal.view.menu.ActionMenuPresenter)2 ActionMenuView (android.support.v7.internal.view.menu.ActionMenuView)2 ActionBarView (android.support.v7.internal.widget.ActionBarView)2 MenuItem (android.view.MenuItem)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 MenuPopupHelper (com.arlib.floatingsearchview.util.MenuPopupHelper)2 ArrayList (java.util.ArrayList)2 Activity (android.app.Activity)1 Intent (android.content.Intent)1 Resources (android.content.res.Resources)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1