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);
}
}
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;
}
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;
}
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);
}
}
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);
}
Aggregations