Search in sources :

Example 6 with MenuBuilder

use of android.support.v7.internal.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 7 with MenuBuilder

use of android.support.v7.internal.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 8 with MenuBuilder

use of android.support.v7.internal.view.menu.MenuBuilder in project wh-app-android by WhiteHouse.

the class DrawerFragment method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    mMenu = new MenuBuilder(getActivity());
    bindSubscription(AndroidObservable.bindFragment(this, FeedCategoryManager.get().getFeedCategoryConfig().first().subscribeOn(Schedulers.newThread())).subscribe(feedCategoryConfig -> {
        List<FeedCategoryItem> items = feedCategoryConfig.feeds();
        int i = 0;
        int group = 0;
        for (FeedCategoryItem c : items) {
            switch(c.viewType()) {
                case FeedCategoryItem.VIEW_TYPE_ARTICLE_LIST:
                    group = GROUP_ARTICLES;
                    break;
                case FeedCategoryItem.VIEW_TYPE_PHOTO_GALLERY:
                    group = GROUP_PHOTOS;
                    break;
                case FeedCategoryItem.VIEW_TYPE_VIDEO_GALLERY:
                    group = GROUP_VIDEOS;
                    break;
                case FeedCategoryItem.VIEW_TYPE_LIVE:
                    mLivePosition = i + 1;
                    group = GROUP_LIVE;
                    break;
            }
            mMenu.add(group, Menu.NONE, i++, c.title()).setIntent(new Intent().setData(Uri.parse(c.feedUrl())));
        }
        mMenu.add(GROUP_FAVORITES, Menu.NONE, i++, R.string.title_favorites);
        getAdapter().addHeader(new Object());
        getAdapter().fillWith(getMenuItems());
        getAdapter().selectOnly(mCheckedPosition);
        getProgressBar().setVisibility(View.GONE);
        getRecyclerView().setVisibility(View.VISIBLE);
        if (mDrawerCallbacks != null) {
            if (icicle == null) {
                mDrawerCallbacks.onRestoreSelectedItem(getAdapter().getItem(mCheckedPosition));
            }
            updateTitle();
        }
    }));
}
Also used : MenuBuilder(android.support.v7.internal.view.menu.MenuBuilder) Bundle(android.os.Bundle) Uri(android.net.Uri) Intent(android.content.Intent) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) BaseListFragment(gov.whitehouse.app.BaseListFragment) AndroidObservable(rx.android.observables.AndroidObservable) BaseAdapter(gov.whitehouse.widget.BaseAdapter) Menu(android.view.Menu) Schedulers(rx.schedulers.Schedulers) View(android.view.View) FeedCategoryManager(gov.whitehouse.core.manager.FeedCategoryManager) Icicle(icepick.Icicle) LayoutInflater(android.view.LayoutInflater) Collection(java.util.Collection) ViewGroup(android.view.ViewGroup) List(java.util.List) TextView(android.widget.TextView) Toolbar(android.support.v7.widget.Toolbar) FeedCategoryItem(gov.whitehouse.data.model.FeedCategoryItem) Nullable(android.support.annotation.Nullable) Activity(android.app.Activity) R(gov.whitehouse.R) DrawerItemAdapter(gov.whitehouse.widget.wh.DrawerItemAdapter) ArrayList(java.util.ArrayList) List(java.util.List) Intent(android.content.Intent) MenuBuilder(android.support.v7.internal.view.menu.MenuBuilder) FeedCategoryItem(gov.whitehouse.data.model.FeedCategoryItem)

Example 9 with MenuBuilder

use of android.support.v7.internal.view.menu.MenuBuilder in project floatingsearchview by arimorty.

the class MenuView method init.

private void init() {
    mMenuBuilder = new MenuBuilder(getContext());
    mMenuPopupHelper = new MenuPopupHelper(getContext(), mMenuBuilder, this);
    mActionIconColor = Util.getColor(getContext(), R.color.gray_active_icon);
    mOverflowIconColor = Util.getColor(getContext(), R.color.gray_active_icon);
}
Also used : MenuPopupHelper(com.arlib.floatingsearchview.util.MenuPopupHelper) MenuBuilder(android.support.v7.view.menu.MenuBuilder)

Example 10 with MenuBuilder

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

the class NavigationView method setMenu.

public void setMenu(int resId) {
    Menu menu = new MenuBuilder(new CarbonContextWrapper(getContext()));
    MenuInflater inflater = new MenuInflater(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