use of android.view.MenuItem in project XobotOS by xamarin.
the class MenuPopupHelper method onSubMenuSelected.
@Override
public boolean onSubMenuSelected(SubMenuBuilder subMenu) {
if (subMenu.hasVisibleItems()) {
MenuPopupHelper subPopup = new MenuPopupHelper(mContext, subMenu, mAnchorView, false);
subPopup.setCallback(mPresenterCallback);
boolean preserveIconSpacing = false;
final int count = subMenu.size();
for (int i = 0; i < count; i++) {
MenuItem childItem = subMenu.getItem(i);
if (childItem.isVisible() && childItem.getIcon() != null) {
preserveIconSpacing = true;
break;
}
}
subPopup.setForceShowIcon(preserveIconSpacing);
if (subPopup.tryShow()) {
if (mPresenterCallback != null) {
mPresenterCallback.onOpenSubMenu(subMenu);
}
return true;
}
}
return false;
}
use of android.view.MenuItem in project TourGuide by worker8.
the class ToolbarActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu;
getMenuInflater().inflate(R.menu.menu_demo_main, menu);
// We need to get the menu item as a View in order to work with TourGuide
MenuItem menuItem = menu.getItem(0);
ImageView button = (ImageView) menuItem.getActionView();
// just adding some padding to look better
float density = mActivity.getResources().getDisplayMetrics().density;
int padding = (int) (5 * density);
button.setPadding(padding, padding, padding, padding);
// set an image
button.setImageDrawable(mActivity.getResources().getDrawable(android.R.drawable.ic_dialog_email));
ToolTip toolTip = new ToolTip().setTitle("Welcome!").setDescription("Click on Get Started to begin...").setGravity(Gravity.LEFT | Gravity.BOTTOM);
mTutorialHandler = TourGuide.init(this).with(TourGuide.Technique.CLICK).motionType(TourGuide.MotionType.CLICK_ONLY).setPointer(new Pointer()).setToolTip(toolTip).setOverlay(new Overlay()).playOn(button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mTutorialHandler.cleanUp();
}
});
return true;
}
use of android.view.MenuItem in project WordPress-Android by wordpress-mobile.
the class StatsViewHolder method setMoreButtonOpenInReader.
/*
* Used by stats fragments to create the more btn context menu with the "View" option in it.
* Opening it with reader if possible.
*
*/
public void setMoreButtonOpenInReader(final StatsPostModel currentItem) {
if (imgMore == null) {
return;
}
imgMore.setVisibility(View.VISIBLE);
imgMore.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
final Context ctx = view.getContext();
PopupMenu popup = new PopupMenu(ctx, view);
MenuItem menuItem = popup.getMenu().add(ctx.getString(R.string.stats_view));
menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
StatsUtils.openPostInReaderOrInAppWebview(ctx, currentItem);
return true;
}
});
popup.show();
}
});
}
use of android.view.MenuItem in project WordPress-Android by wordpress-mobile.
the class ThemeBrowserAdapter method configureImageButton.
private void configureImageButton(Context context, ThemeViewHolder themeViewHolder, final String themeId, final boolean isPremium, boolean isCurrent) {
final PopupMenu popupMenu = new PopupMenu(context, themeViewHolder.imageButton);
popupMenu.getMenuInflater().inflate(R.menu.theme_more, popupMenu.getMenu());
configureMenuForTheme(popupMenu.getMenu(), isCurrent);
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
int i = item.getItemId();
if (i == R.id.menu_activate) {
if (isPremium) {
mCallback.onDetailsSelected(themeId);
} else {
mCallback.onActivateSelected(themeId);
}
} else if (i == R.id.menu_try_and_customize) {
mCallback.onTryAndCustomizeSelected(themeId);
} else if (i == R.id.menu_view) {
mCallback.onViewSelected(themeId);
} else if (i == R.id.menu_details) {
mCallback.onDetailsSelected(themeId);
} else {
mCallback.onSupportSelected(themeId);
}
return true;
}
});
themeViewHolder.imageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
popupMenu.show();
}
});
}
use of android.view.MenuItem in project PocketHub by pockethub.
the class MainActivity method setUpNavigationMenu.
private void setUpNavigationMenu() {
MenuItem organizationContainer = navigationView.getMenu().findItem(R.id.navigation_organizations);
if (organizationContainer.hasSubMenu()) {
SubMenu organizationsMenu = organizationContainer.getSubMenu();
for (int i = 1; i < orgs.size(); i++) {
User organization = orgs.get(i);
if (organizationsMenu.findItem(organization.id()) == null) {
MenuItem organizationMenuItem = organizationsMenu.add(Menu.NONE, organization.id(), Menu.NONE, organization.name() != null ? organization.name() : organization.login());
organizationMenuItem.setIcon(R.drawable.ic_github_organization_black_24dp);
//Because of tinting the real image would became a grey block
//avatars.bind(organizationMenuItem, organization);
menuItemOrganizationMap.put(organizationMenuItem, organization);
}
}
} else {
throw new IllegalStateException("Menu item " + organizationContainer + " should have a submenu");
}
}
Aggregations