Search in sources :

Example 66 with MenuItem

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;
}
Also used : MenuItem(android.view.MenuItem)

Example 67 with MenuItem

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;
}
Also used : ToolTip(tourguide.tourguide.ToolTip) MenuItem(android.view.MenuItem) Pointer(tourguide.tourguide.Pointer) ImageView(android.widget.ImageView) Overlay(tourguide.tourguide.Overlay) ImageView(android.widget.ImageView) View(android.view.View)

Example 68 with MenuItem

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();
        }
    });
}
Also used : Context(android.content.Context) MenuItem(android.view.MenuItem) ImageView(android.widget.ImageView) WPNetworkImageView(org.wordpress.android.widgets.WPNetworkImageView) TextView(android.widget.TextView) View(android.view.View) PopupMenu(android.widget.PopupMenu)

Example 69 with MenuItem

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();
        }
    });
}
Also used : MenuItem(android.view.MenuItem) CardView(android.support.v7.widget.CardView) NetworkImageView(com.android.volley.toolbox.NetworkImageView) HeaderGridView(org.wordpress.android.widgets.HeaderGridView) TextView(android.widget.TextView) View(android.view.View) PopupMenu(android.widget.PopupMenu)

Example 70 with MenuItem

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");
    }
}
Also used : User(com.meisolsson.githubsdk.model.User) MenuItem(android.view.MenuItem) SubMenu(android.view.SubMenu)

Aggregations

MenuItem (android.view.MenuItem)761 View (android.view.View)140 Intent (android.content.Intent)86 TextView (android.widget.TextView)78 PopupMenu (android.widget.PopupMenu)62 ImageView (android.widget.ImageView)58 Menu (android.view.Menu)52 SearchView (android.support.v7.widget.SearchView)46 SmallTest (android.test.suitebuilder.annotation.SmallTest)42 RecyclerView (android.support.v7.widget.RecyclerView)36 MenuInflater (android.view.MenuInflater)35 AdapterView (android.widget.AdapterView)33 ListView (android.widget.ListView)32 SubMenu (android.view.SubMenu)30 ComponentName (android.content.ComponentName)25 PackageManager (android.content.pm.PackageManager)25 Parcelable (android.os.Parcelable)24 Toolbar (android.support.v7.widget.Toolbar)24 Bundle (android.os.Bundle)19 PopupMenu (android.support.v7.widget.PopupMenu)19