@Override public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) { inflater.inflate(R.menu.shuffle_item, menu); menu.findItem(R.id.menu_shuffle_item).setTitle(getShuffleTitleId()); // use the same popup menu to provide actions for smart playlist // as is used in the PlaylistFragment mActionMenuHelper = new PlaylistPopupMenuHelper( getActivity(), getChildFragmentManager(), PopupMenuType.SmartPlaylist) { public Playlist getPlaylist(int position) { SmartPlaylistType type = getSmartPlaylistType(); return new Playlist(type.mId, getString(type.mTitleId), 0); } }; mActionMenuHelper.onPreparePopupMenu(0); mActionMenuHelper.createPopupMenu(menu); inflater.inflate(R.menu.clear_list, menu); super.onCreateOptionsMenu(menu, inflater); }
@Override public boolean onOptionsItemSelected(final MenuItem item) { switch (item.getItemId()) { case R.id.menu_shuffle_item: playAll(-1, true); return true; case R.id.clear_list: ConfirmDialog.show(this, CLEAR_REQUEST, getClearTitleId(), R.string.clear); return true; default: if (mActionMenuHelper.onMenuItemClick(item)) { return true; } } return super.onOptionsItemSelected(item); }