Example usage for android.view Menu clear

List of usage examples for android.view Menu clear

Introduction

In this page you can find the example usage for android.view Menu clear.

Prototype

public void clear();

Source Link

Document

Remove all existing items from the menu, leaving it empty as if it had just been created.

Usage

From source file:de.spiritcroc.modular_remote.MainActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    menu.clear();
    getMenuInflater().inflate(R.menu.menu_main, menu);
    editModeMenuItem = menu.findItem(R.id.action_edit_page_content);
    connectionMgrMenuItem = menu.findItem(R.id.action_connection_manager);
    setLockedModeVisibilities();// w w  w  .  j ava  2s.  c om
    return super.onPrepareOptionsMenu(menu);
}

From source file:com.android.purenexussettings.TinkerActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tinker);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);/*from ww w  . j a va  2  s .c om*/

    // set up some defaults
    boolean cLockInstalled;
    FRAG_ARRAY_START = getResources().getIntArray(R.array.nav_drawer_cat_nums)[0];
    mTitle = mDrawerTitle = getTitle();
    mPackageName = getPackageName();
    LAST_SLIDE_BAR_TAB = 0;
    mBackPress = false;
    mIgnoreBack = false;
    mFromClick = false;
    mMenu = false;
    fullyClosed = true;
    openingHalf = true;

    // for backstack tracking
    fragmentStack = new Stack<>();

    // check if cLock installed
    try {
        PackageInfo pi = getPackageManager().getPackageInfo(KEY_LOCK_CLOCK_PACKAGE_NAME, 0);
        cLockInstalled = pi.applicationInfo.enabled;
    } catch (PackageManager.NameNotFoundException e) {
        cLockInstalled = false;
    }

    // load slide menu items - titles and frag names
    navMenuTitles = getResources().getStringArray(R.array.nav_drawer_items);
    navMenuFrags = getResources().getStringArray(R.array.nav_drawer_fragments);

    // nav drawer icons from resources
    TypedArray navMenuIcons = getResources().obtainTypedArray(R.array.nav_drawer_icons);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

    mNavView = (NavigationView) findViewById(R.id.slidermenu);

    // create navigationview items
    Menu menu = mNavView.getMenu();
    // pulled in crap menu in xml, need to clear it first
    menu.clear();

    // pull in category names and numbers in each
    String[] navMenuCats = getResources().getStringArray(R.array.nav_drawer_cats);
    int[] navMenuCatCounts = getResources().getIntArray(R.array.nav_drawer_cat_nums);

    // set up some counters
    int j = 0;
    int total = 0;
    SubMenu submenu = null;
    // go through the total possible menu list
    for (int i = 0; i < navMenuTitles.length; i++) {
        // when the count equals a threshold value, increment/sum and add submenu
        if (i == (total + navMenuCatCounts[j])) {
            total += navMenuCatCounts[j];
            // format submenu headings
            SpannableString strcat = new SpannableString(navMenuCats[j]);
            strcat.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.alphawhite)), 0,
                    strcat.length(), 0);
            strcat.setSpan(new RelativeSizeSpan(0.85f), 0, strcat.length(), 0);
            strcat.setSpan(new AlignmentSpan.Standard(Layout.Alignment.ALIGN_CENTER), 0, strcat.length(), 0);
            // is the 10 * (j + 1) bit needed...? Maybe not... meh
            submenu = menu.addSubMenu((j + 1), 10 * (j + 1), 10 * (j + 1), strcat);
            j++;
        }
        // assuming all are skipped before first submenu, only add menu items if total <> 0
        if (total > 0) {
            // format menu item title
            SpannableString stritem = new SpannableString(navMenuTitles[i]);
            stritem.setSpan(new ForegroundColorSpan(getResources().getColor(R.color.alphawhite)), 0,
                    stritem.length(), 0);
            // group id is j, i is item id and order..., then title - includes logic for conditional entries
            if (cLockInstalled || !(navMenuTitles[i].equals("cLock"))) {
                // an attempt to add icon if included...
                if (navMenuIcons.getResourceId(i, -1) != -1) {
                    submenu.add(j, i, i, stritem).setIcon(navMenuIcons.getResourceId(i, -1));
                } else {
                    submenu.add(j, i, i, stritem);
                }
            }
        }
    }

    // remove icon tint from NavView
    mNavView.setItemIconTintList(null);

    mNavView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override
        public boolean onNavigationItemSelected(MenuItem item) {
            // check for external app launching navdrawer items
            if (navMenuTitles[item.getItemId()].equals("cLock")) {
                mIgnore = true;
                mDrawerLayout.closeDrawer(mNavView);
                launchcLock();
            }

            // if nothing was caught in the above, do the usual prep to show frag stuff
            if (!mIgnore) {
                mItemPosition = item.getItemId();
                mFromClick = true;
                setTitle(navMenuTitles[mItemPosition]);
                removeCurrent();
                mDrawerLayout.closeDrawer(mNavView);
            }

            return true;
        }
    });

    // Recycle the typed array
    navMenuIcons.recycle();

    // enabling action bar app icon and behaving it as toggle button
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);

    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, toolbar, //nav menu toggle icon
            R.string.app_name, // nav drawer open - description for accessibility
            R.string.app_name // nav drawer close - description for accessibility
    ) {
        @Override
        public void onDrawerClosed(View view) {
            mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, mNavView);
            getSupportActionBar().setTitle(mTitle);
            // calling onPrepareOptionsMenu() to show action bar icons
            openingHalf = true;
            invalidateOptionsMenu();
            // now that the drawer animation is done - load fragment
            if (mIgnore || !mFromClick) {
                mIgnore = false;
            } else {
                displayView(mItemPosition);
            }
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            getSupportActionBar().setTitle(mDrawerTitle);
            // calling onPrepareOptionsMenu() to hide action bar icons
            openingHalf = false;
            invalidateOptionsMenu();
        }

        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            super.onDrawerSlide(drawerView, slideOffset);
            fullyClosed = (slideOffset == 0.0f);
            if (slideOffset < 0.5f && !openingHalf) {
                openingHalf = true;
                invalidateOptionsMenu(); // calls onPrepareOptionsMenu()
            } else if (slideOffset > 0.5f && openingHalf) {
                openingHalf = false;
                invalidateOptionsMenu(); // calls onPrepareOptionsMenu()
            }
        }

    };

    mDrawerLayout.setDrawerListener(mDrawerToggle);

    fragmentManager = getFragmentManager();

    if (savedInstanceState == null) {
        // on first time display view for first nav item
        displayView(mItemPosition = getIntent().getIntExtra(EXTRA_START_FRAGMENT, 0));
    }
}

From source file:net.kw.shrdlu.grtgtfs.Activities.MenuListActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    final MenuInflater inflater = getMenuInflater();

    // This can be called multiple times, for difference activities, or the
    // action bar & nav drawer. So try process things only once, else the menus are doubled up.

    // Borrow this menu for a moment to expand the nav menu first.
    if (mDrawerItems.size() == 0) {
        inflater.inflate(R.menu.navdrawermenu, menu);
        for (int i = 0; i < menu.size(); i++) {
            MenuItem item = menu.getItem(i);
            mDrawerItems.add(new NavDrawerItem(item.getIcon(), item.getTitle(), item.getItemId()));
        }//w w  w .j av a2s.co m
        mNavAdapter.notifyDataSetChanged();
        menu.clear();
    }

    inflater.inflate(R.menu.actionbarmenu, menu);
    return super.onCreateOptionsMenu(menu);
}

From source file:com.openatk.rockapp.MainActivity.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    if (mCurrentState == STATE_DEFAULT) {
        menu.clear();
        inflater.inflate(R.menu.main, menu);

        MenuItem showHideItem = menu.findItem(R.id.show_hide);
        MenuItem currentShowHideItem;

        switch (mRockState) {
        case STATE_ROCKS_BOTH:
            currentShowHideItem = menu.findItem(R.id.all_rocks);
            break;

        case STATE_ROCKS_NOT_PICKED_UP:
            currentShowHideItem = menu.findItem(R.id.not_picked_rocks);
            break;

        case STATE_ROCKS_PICKED_UP:
            currentShowHideItem = menu.findItem(R.id.picked_rocks);
            break;
        default://from   w ww .  j  a  v  a  2  s .co m
            // We are some how lost, just revert back to showing everything
            Log.e("MainActivity", "Lost Rock Shown State");
            mRockState = STATE_ROCKS_BOTH;
            currentShowHideItem = menu.findItem(R.id.all_rocks);
            break;
        }

        // Copy the current selection to the action bar
        showHideItem.setTitle(currentShowHideItem.getTitle());

        // Mark the current one as checked
        currentShowHideItem.setChecked(true);

        // The location button changes depending the current state
        // of location

        // TODO
        /*
         * MenuItem gps = menu.findItem(R.id.gps); if(map.ha) {
         * if(mRockLocationManager.haveUserLocation()) {
         * gps.setIcon(R.drawable.gps_found);
         * gps.setTitle(R.string.menu_gps); } else {
         * gps.setIcon(R.drawable.gps_searching);
         * gps.setTitle(R.string.menu_gps_searching); } } else {
         * gps.setIcon(R.drawable.gps_off);
         * gps.setTitle(R.string.menu_gps_off); }
         */
    } else if (mCurrentState == STATE_ROCK_EDIT) {
        menu.clear();
        inflater.inflate(R.menu.rock_edit_menu, menu);
        MenuItem undoButton = menu.findItem(R.id.rock_undo_move);
        if (undoMoves.isEmpty()) {
            undoButton.setVisible(false);
        } else {
            undoButton.setVisible(true);
        }
    }
    return true;
}

From source file:com.albedinsky.android.support.universi.UniversiActivity.java

/**
 *///from  w w w .  j a va  2 s .  co  m
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (mAnnotationHandler == null || !mAnnotationHandler.hasOptionsMenu())
        return false;
    final int menuResource = mAnnotationHandler.getOptionsMenuResource(-1);
    if (menuResource != -1) {
        if (mAnnotationHandler.shouldClearOptionsMenu()) {
            menu.clear();
        }
        switch (mAnnotationHandler.getOptionsMenuFlags(0)) {
        case MenuOptions.IGNORE_SUPER:
            getMenuInflater().inflate(menuResource, menu);
            break;
        case MenuOptions.BEFORE_SUPER:
            getMenuInflater().inflate(menuResource, menu);
            super.onCreateOptionsMenu(menu);
            break;
        case MenuOptions.DEFAULT:
            super.onCreateOptionsMenu(menu);
            getMenuInflater().inflate(menuResource, menu);
            break;
        }
        return true;
    }
    return super.onCreateOptionsMenu(menu);
}

From source file:com.amaze.filemanager.ui.views.drawer.Drawer.java

public void refreshDrawer() {
    Menu menu = navView.getMenu();
    menu.clear();
    actionViewStateManager.deselectCurrentActionView();

    int order = 0;
    ArrayList<String> storageDirectories = mainActivity.getStorageDirectories();
    phoneStorageCount = 0;//w ww .  j av a 2  s.c om
    for (String file : storageDirectories) {
        if (file.contains(OTGUtil.PREFIX_OTG)) {
            addNewItem(menu, STORAGES_GROUP, order++, "OTG", new MenuMetadata(file),
                    R.drawable.ic_usb_white_24dp, R.drawable.ic_show_chart_black_24dp);
            continue;
        }

        File f = new File(file);
        String name;
        @DrawableRes
        int icon1;
        if ("/storage/emulated/legacy".equals(file) || "/storage/emulated/0".equals(file)
                || "/mnt/sdcard".equals(file)) {
            name = resources.getString(R.string.storage);
            icon1 = R.drawable.ic_phone_android_white_24dp;
        } else if ("/storage/sdcard1".equals(file)) {
            name = resources.getString(R.string.extstorage);
            icon1 = R.drawable.ic_sd_storage_white_24dp;
        } else if ("/".equals(file)) {
            name = resources.getString(R.string.rootdirectory);
            icon1 = R.drawable.ic_drawer_root_white;
        } else {
            name = f.getName();
            icon1 = R.drawable.ic_sd_storage_white_24dp;
        }

        if (f.isDirectory() || f.canExecute()) {
            addNewItem(menu, STORAGES_GROUP, order++, name, new MenuMetadata(file), icon1,
                    R.drawable.ic_show_chart_black_24dp);
            if (phoneStorageCount == 0)
                firstPath = file;
            else if (phoneStorageCount == 1)
                secondPath = file;

            phoneStorageCount++;
        }
    }
    dataUtils.setStorages(storageDirectories);

    if (dataUtils.getServers().size() > 0) {
        Collections.sort(dataUtils.getServers(), new BookSorter());
        synchronized (dataUtils.getServers()) {
            for (String[] file : dataUtils.getServers()) {
                addNewItem(menu, SERVERS_GROUP, order++, file[0], new MenuMetadata(file[1]),
                        R.drawable.ic_settings_remote_white_24dp, R.drawable.ic_edit_24dp);
            }
        }
    }

    ArrayList<String[]> accountAuthenticationList = new ArrayList<>();

    if (CloudSheetFragment.isCloudProviderAvailable(mainActivity)) {
        for (CloudStorage cloudStorage : dataUtils.getAccounts()) {
            @DrawableRes
            int deleteIcon = R.drawable.ic_delete_grey_24dp;

            if (cloudStorage instanceof Dropbox) {
                addNewItem(menu, CLOUDS_GROUP, order++, CloudHandler.CLOUD_NAME_DROPBOX,
                        new MenuMetadata(CloudHandler.CLOUD_PREFIX_DROPBOX + "/"),
                        R.drawable.ic_dropbox_white_24dp, deleteIcon);

                accountAuthenticationList.add(new String[] { CloudHandler.CLOUD_NAME_DROPBOX,
                        CloudHandler.CLOUD_PREFIX_DROPBOX + "/", });
            } else if (cloudStorage instanceof Box) {
                addNewItem(menu, CLOUDS_GROUP, order++, CloudHandler.CLOUD_NAME_BOX,
                        new MenuMetadata(CloudHandler.CLOUD_PREFIX_BOX + "/"), R.drawable.ic_box_white_24dp,
                        deleteIcon);

                accountAuthenticationList.add(
                        new String[] { CloudHandler.CLOUD_NAME_BOX, CloudHandler.CLOUD_PREFIX_BOX + "/", });
            } else if (cloudStorage instanceof OneDrive) {
                addNewItem(menu, CLOUDS_GROUP, order++, CloudHandler.CLOUD_NAME_ONE_DRIVE,
                        new MenuMetadata(CloudHandler.CLOUD_PREFIX_ONE_DRIVE + "/"),
                        R.drawable.ic_onedrive_white_24dp, deleteIcon);

                accountAuthenticationList.add(new String[] { CloudHandler.CLOUD_NAME_ONE_DRIVE,
                        CloudHandler.CLOUD_PREFIX_ONE_DRIVE + "/", });
            } else if (cloudStorage instanceof GoogleDrive) {
                addNewItem(menu, CLOUDS_GROUP, order++, CloudHandler.CLOUD_NAME_GOOGLE_DRIVE,
                        new MenuMetadata(CloudHandler.CLOUD_PREFIX_GOOGLE_DRIVE + "/"),
                        R.drawable.ic_google_drive_white_24dp, deleteIcon);

                accountAuthenticationList.add(new String[] { CloudHandler.CLOUD_NAME_GOOGLE_DRIVE,
                        CloudHandler.CLOUD_PREFIX_GOOGLE_DRIVE + "/", });
            }
        }
        Collections.sort(accountAuthenticationList, new BookSorter());
    }

    if (mainActivity.getBoolean(PREFERENCE_SHOW_SIDEBAR_FOLDERS)) {
        if (dataUtils.getBooks().size() > 0) {

            Collections.sort(dataUtils.getBooks(), new BookSorter());

            synchronized (dataUtils.getBooks()) {
                for (String[] file : dataUtils.getBooks()) {
                    addNewItem(menu, FOLDERS_GROUP, order++, file[0], new MenuMetadata(file[1]),
                            R.drawable.ic_folder_white_24dp, R.drawable.ic_edit_24dp);
                }
            }
        }
    }

    Boolean[] quickAccessPref = TinyDB.getBooleanArray(mainActivity.getPrefs(), QuickAccessPref.KEY,
            QuickAccessPref.DEFAULT);

    if (mainActivity.getBoolean(PREFERENCE_SHOW_SIDEBAR_QUICKACCESSES)) {
        if (quickAccessPref[0]) {
            addNewItem(menu, QUICKACCESSES_GROUP, order++, R.string.quick, new MenuMetadata("5"),
                    R.drawable.ic_star_white_24dp, null);
        }
        if (quickAccessPref[1]) {
            addNewItem(menu, QUICKACCESSES_GROUP, order++, R.string.recent, new MenuMetadata("6"),
                    R.drawable.ic_history_white_24dp, null);
        }
        if (quickAccessPref[2]) {
            addNewItem(menu, QUICKACCESSES_GROUP, order++, R.string.images, new MenuMetadata("0"),
                    R.drawable.ic_photo_library_white_24dp, null);
        }
        if (quickAccessPref[3]) {
            addNewItem(menu, QUICKACCESSES_GROUP, order++, R.string.videos, new MenuMetadata("1"),
                    R.drawable.ic_video_library_white_24dp, null);
        }
        if (quickAccessPref[4]) {
            addNewItem(menu, QUICKACCESSES_GROUP, order++, R.string.audio, new MenuMetadata("2"),
                    R.drawable.ic_library_music_white_24dp, null);
        }
        if (quickAccessPref[5]) {
            addNewItem(menu, QUICKACCESSES_GROUP, order++, R.string.documents, new MenuMetadata("3"),
                    R.drawable.ic_library_books_white_24dp, null);
        }
        if (quickAccessPref[6]) {
            addNewItem(menu, QUICKACCESSES_GROUP, order++, R.string.apks, new MenuMetadata("4"),
                    R.drawable.ic_apk_library_white_24dp, null);
        }
    }

    addNewItem(menu, LASTGROUP, order++, R.string.ftp, new MenuMetadata(() -> {
        FragmentTransaction transaction2 = mainActivity.getSupportFragmentManager().beginTransaction();
        transaction2.replace(R.id.content_frame, new FtpServerFragment());
        mainActivity.getAppbar().getAppbarLayout().animate().translationY(0)
                .setInterpolator(new DecelerateInterpolator(2)).start();
        pending_fragmentTransaction = transaction2;
        if (!isDrawerLocked)
            close();
        else
            onDrawerClosed();
    }), R.drawable.ic_ftp_white_24dp, null);

    addNewItem(menu, LASTGROUP, order++, R.string.apps, new MenuMetadata(() -> {
        FragmentTransaction transaction2 = mainActivity.getSupportFragmentManager().beginTransaction();
        transaction2.replace(R.id.content_frame, new AppsListFragment());
        mainActivity.getAppbar().getAppbarLayout().animate().translationY(0)
                .setInterpolator(new DecelerateInterpolator(2)).start();
        pending_fragmentTransaction = transaction2;
        if (!isDrawerLocked)
            close();
        else
            onDrawerClosed();
    }), R.drawable.ic_android_white_24dp, null);

    addNewItem(menu, LASTGROUP, order++, R.string.setting, new MenuMetadata(() -> {
        Intent in = new Intent(mainActivity, PreferencesActivity.class);
        mainActivity.startActivity(in);
        mainActivity.finish();
    }), R.drawable.ic_settings_white_24dp, null);

    for (int i = 0; i < navView.getMenu().size(); i++) {
        navView.getMenu().getItem(i).setEnabled(true);
    }

    for (int group : GROUPS) {
        menu.setGroupCheckable(group, true, true);
    }

    MenuItem item = navView.getSelected();
    if (item != null) {
        item.setChecked(true);
        actionViewStateManager.selectActionView(item);
        isSomethingSelected = true;
    }
}

From source file:eu.trentorise.smartcampus.trentinofamiglia.fragments.poi.PoisListingFragment.java

@Override
public void onPrepareOptionsMenu(Menu menu) {
    /*/* www.j  ava  2 s  .co  m*/
     * menu.clear(); MenuItem item = menu.add(Menu.CATEGORY_SYSTEM,
     * R.id.map_view, Menu.NONE, R.string.map_view);
     * item.setIcon(R.drawable.ic_map);
     * item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
     */
    menu.clear();
    getActivity().getMenuInflater().inflate(R.menu.list_menu, menu);
    //      SubMenu submenu = menu.getItem(0).getSubMenu();
    //      submenu.clear();

    if (category == null) {
        category = (getArguments() != null) ? getArguments().getString(SearchFragment.ARG_CATEGORY) : null;
    }

    super.onPrepareOptionsMenu(menu);
}

From source file:com.odoo.addons.calendar.CalendarDashboard.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();
    inflater.inflate(R.menu.menu_calendar_dashboard, menu);
    if (getActivity() != null) {
        MenuItem today = menu.findItem(R.id.menu_dashboard_goto_today);
        today.setIcon(TodayIcon.get(getActivity()).getIcon());
    }//w  w w.jav a2  s  . c om
    setHasSearchView(this, menu, R.id.menu_search);
}

From source file:com.filterdevice.ProfileScanningFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();
    inflater.inflate(R.menu.global, menu);
    final EditText mEditText = (EditText) menu.findItem(R.id.search).getActionView();
    mEditText.addTextChangedListener(textWatcher);

    MenuItem pairCache = menu.findItem(R.id.pairing);
    if (Utils.getBooleanSharedPreference(getActivity(), Constants.PREF_PAIR_CACHE_STATUS)) {
        pairCache.setChecked(true);//from  w w w. ja v a2s  .c  o  m
    } else {
        pairCache.setChecked(false);
    }

    MenuItem mSearch = menu.findItem(R.id.search);
    mSearch.setVisible(true);
    mSearch.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
        @Override
        public boolean onMenuItemActionCollapse(MenuItem item) {
            // Do something when collapsed
            View view = getActivity().getCurrentFocus();
            if (view != null) {
                InputMethodManager imm = (InputMethodManager) getActivity()
                        .getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
            }
            Logger.e("Collapsed");
            return true; // Return true to collapse action view
        }

        @Override
        public boolean onMenuItemActionExpand(MenuItem item) {
            Logger.e("Expanded");
            mEditText.requestFocus();
            View view = getActivity().getCurrentFocus();
            if (view != null) {
                InputMethodManager inputManager = (InputMethodManager) getActivity()
                        .getSystemService(Context.INPUT_METHOD_SERVICE);
                inputManager.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
            }
            return true; // Return true to expand action view
        }
    });

    super.onCreateOptionsMenu(menu, inflater);
}

From source file:com.cyanogenmod.eleven.ui.fragments.AudioPlayerFragment.java

public void showPopupMenu() {
    // create the popup menu
    if (mPopupMenu == null) {
        mPopupMenu = new PopupMenu(getActivity(), mMenuButton);
        mPopupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
            @Override/*  ww  w  .  j  a va  2s  . c o  m*/
            public boolean onMenuItemClick(MenuItem item) {
                return onPopupMenuItemClick(item);
            }
        });
    }

    final Menu menu = mPopupMenu.getMenu();
    final MenuInflater inflater = mPopupMenu.getMenuInflater();
    menu.clear();

    // Shuffle all
    inflater.inflate(R.menu.shuffle_all, menu);
    if (MusicUtils.getQueueSize() > 0) {
        // ringtone, and equalizer
        inflater.inflate(R.menu.audio_player, menu);

        if (!NavUtils.hasEffectsPanel(getActivity())) {
            menu.removeItem(R.id.menu_audio_player_equalizer);
        }

        // save queue/clear queue
        inflater.inflate(R.menu.queue, menu);
    }
    // Settings
    inflater.inflate(R.menu.activity_base, menu);

    // show the popup
    mPopupMenu.show();
}