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