Example usage for android.view MenuItem getMenuInfo

List of usage examples for android.view MenuItem getMenuInfo

Introduction

In this page you can find the example usage for android.view MenuItem getMenuInfo.

Prototype

public ContextMenuInfo getMenuInfo();

Source Link

Document

Gets the extra information linked to this menu item.

Usage

From source file:cn.ucai.superwechat.fragment.ChatHistoryFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    if (item.getItemId() == cn.ucai.superwechat.R.id.delete_message) {
        EMContact tobeDeleteUser = adapter.getItem(((AdapterContextMenuInfo) item.getMenuInfo()).position);
        boolean isGroup = false;
        if (tobeDeleteUser instanceof EMGroup)
            isGroup = true;/*from   w w  w .  j a  va2s .co m*/
        // ?
        EMChatManager.getInstance().deleteConversation(tobeDeleteUser.getUsername(), isGroup);
        InviteMessgeDao inviteMessgeDao = new InviteMessgeDao(getActivity());
        inviteMessgeDao.deleteMessage(tobeDeleteUser.getUsername());
        adapter.remove(tobeDeleteUser);
        adapter.notifyDataSetChanged();

        // ?
        ((MainActivity) getActivity()).updateUnreadLabel();

        return true;
    }
    return super.onContextItemSelected(item);
}

From source file:de.jan.ledgerjournal.JournalActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();

    if (item.getItemId() == R.id.context_journal_edit) {
        Log.d("JournalActivity", "Context menu: edit selected");
        editJournalTransaction(info.position);
    } else if (item.getItemId() == R.id.context_journal_delete) {
        Log.d("JournalActivity", "Context menu: delete selected");
        deleteJournalTransaction(info.position);
    } else if (item.getItemId() == R.id.context_journal_template) {
        addToTemplates(journal.get(info.position));
    } else {/*  ww  w. j  a  v  a  2 s  . c  o m*/
        return false;
    }
    return true;
}

From source file:cc.softwarefactory.lokki.android.fragments.PlacesFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    int position = info.position;
    String placeName = placesList.get(position);

    switch (item.getItemId()) {
    case R.id.places_context_menu_delete:
        deletePlaceDialog(placeName);//  w  w  w.jav a 2 s. co  m
        return true;
    case R.id.places_context_menu_rename:
        renamePlaceDialog(placeName);
    }

    return super.onContextItemSelected(item);
}

From source file:org.spinsuite.view.T_Menu.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    //   Options//from  w  ww . j av a  2  s . co  m
    switch (item.getItemId()) {
    case O_NO_FORCED:
        synchronizeData(info.position, false, false);
        return true;
    case O_FORCED:
        synchronizeData(info.position, true, false);
        return true;
    case O_DELETE_BEFORE:
        synchronizeData(info.position, true, true);
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:org.gateshipone.malp.application.fragments.serverfragments.PlaylistTracksFragment.java

/**
 * Hook called when an menu item in the context menu is selected.
 *
 * @param item The menu item that was selected.
 * @return True if the hook was consumed here.
 *//*from  w w w.j  a  v a  2  s .  c o m*/
@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();

    if (info == null) {
        return super.onContextItemSelected(item);
    }

    switch (item.getItemId()) {
    case R.id.action_song_enqueue:
        enqueueTrack(info.position);
        return true;
    case R.id.action_song_play:
        play(info.position);
        return true;
    case R.id.action_song_play_next:
        playNext(info.position);
        return true;
    case R.id.action_add_to_saved_playlist:
        // open dialog in order to save the current playlist as a playlist in the mediastore
        ChoosePlaylistDialog choosePlaylistDialog = new ChoosePlaylistDialog();
        Bundle args = new Bundle();
        args.putBoolean(ChoosePlaylistDialog.EXTRA_SHOW_NEW_ENTRY, true);
        choosePlaylistDialog.setCallback(
                new AddPathToPlaylist((MPDFileEntry) mFileAdapter.getItem(info.position), getActivity()));
        choosePlaylistDialog.setArguments(args);
        choosePlaylistDialog.show(((AppCompatActivity) getContext()).getSupportFragmentManager(),
                "ChoosePlaylistDialog");
        return true;
    case R.id.action_remove_from_list:
        MPDQueryHandler.removeSongFromSavedPlaylist(mPath, info.position);
        refreshContent();
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:org.webinos.android.app.wrt.ui.WidgetListActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    String installId = ids[(int) info.id];
    switch (item.getItemId()) {
    case R.id.menu_uninstall:
        Intent intent = new Intent(this, WidgetUninstallActivity.class);
        intent.putExtra("installId", installId);
        startActivity(intent);//w  w w. jav  a2s.  c  o m
        return true;
    case R.id.menu_check_for_updates:
        Toast.makeText(this, getString(R.string.not_yet_implemented), Toast.LENGTH_SHORT).show();
        return true;
    case R.id.menu_details:
        Toast.makeText(this, getString(R.string.not_yet_implemented), Toast.LENGTH_SHORT).show();
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:com.meetingninja.csse.meetings.MeetingsFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    int position = item.getItemId();
    boolean handled = false;
    AdapterContextMenuInfo aInfo = (AdapterContextMenuInfo) item.getMenuInfo();
    if (item.getGroupId() == MainActivity.DrawerLabel.MEETINGS.getPosition()) {
        switch (item.getOrder()) {
        case 1: // Edit
            Toast.makeText(getActivity(), item.getTitle(), Toast.LENGTH_SHORT).show();
            handled = true;/*from  w w w  .j a v a  2  s  .c om*/
            break;
        case 2: // Delete
            Meeting meeting = meetingAdpt.getItem(position);
            // mySQLiteAdapter.deleteMeeting(meeting); Need to implement
            MeetingVolleyAdapter.deleteMeeting(meeting.getID());
            meetings.remove(position);
            meetingAdpt.notifyDataSetChanged();
            handled = true;
            break;
        default:
            Log.wtf(TAG, "Invalid context menu option selected");
            break;
        }
    } else {
        Log.wtf(TAG, "What happened here?");
    }

    return handled;
}

From source file:com.commonsware.android.arXiv.CategoriesListFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    if (!getUserVisibleHint())
        return false;
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    if (info == null)
        return false;
    ContentValues cv = new ContentValues();
    int id;/*from   w  ww.  j  a  v  a  2 s . c o m*/
    if (mySourcePref == 0) {
        String tempquery = "search_query=cat:" + urls[info.position] + "*";
        String tempurl = "http://export.arxiv.org/api/query?" + tempquery
                + "&sortBy=submittedDate&sortOrder=ascending";
        cv.put(Feeds.TITLE, shortItems[info.position]);
        cv.put(Feeds.SHORTTITLE, tempquery);
        cv.put(Feeds.URL, tempurl);
        cv.put(Feeds.UNREAD, -1);
        cv.put(Feeds.COUNT, -1);
        id = R.string.added_to_favorites;
    } else {
        cv.put(Feeds.TITLE, shortItems[info.position] + " (RSS)");
        cv.put(Feeds.SHORTTITLE, shortItems[info.position]);
        cv.put(Feeds.URL, urls[info.position]);
        cv.put(Feeds.UNREAD, -2);
        cv.put(Feeds.COUNT, -2);
        id = R.string.added_to_favorites_rss;
    }
    cv.put(Feeds.LAST_UPDATE, 0);
    new AsyncQueryHandler(getActivity().getContentResolver()) {
        @Override
        protected void onInsertComplete(int id, Object cookie, Uri uri) {
            Toast.makeText(getActivity(), id, Toast.LENGTH_SHORT).show();
        }
    }.startInsert(id, null, Feeds.CONTENT_URI, cv);
    return true;
}

From source file:com.feytuo.chat.activity.ContactlistFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.delete_contact) {
        final User tobeDeleteUser = adapter.getItem(((AdapterContextMenuInfo) item.getMenuInfo()).position);
        // ?//w w w  . j ava2s.  co m
        deleteContact(tobeDeleteUser);
        // ?
        InviteMessgeDao dao = new InviteMessgeDao(getActivity());
        dao.deleteMessage(tobeDeleteUser.getUsername());

        // db?
        UserDao userDao = new UserDao(getActivity());
        userDao.deleteContact(tobeDeleteUser.getUsername());
        App.getInstance().getContactList().remove(tobeDeleteUser.getUsername());
        //
        getActivity().runOnUiThread(new Runnable() {
            public void run() {
                adapter.remove(tobeDeleteUser);
                adapter.notifyDataSetChanged();
                setNoFriendBackGround();
            }
        });
        return true;
    } else if (item.getItemId() == R.id.add_to_blacklist) {
        User user = adapter.getItem(((AdapterContextMenuInfo) item.getMenuInfo()).position);
        moveToBlacklist(user.getUsername());
        return true;
    }
    return super.onContextItemSelected(item);
}

From source file:org.videolan.vlc2.gui.audio.AudioAlbumsSongsFragment.java

private boolean handleContextItemSelected(MenuItem item, int position) {
    ContextMenuInfo menuInfo = item.getMenuInfo();

    int startPosition;
    int groupPosition;
    List<String> medias;
    int id = item.getItemId();

    boolean useAllItems = id == R.id.audio_list_browser_play_all;
    boolean append = id == R.id.audio_list_browser_append;

    if (ExpandableListContextMenuInfo.class.isInstance(menuInfo)) {
        ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;
        groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    } else//from   w  ww  .  j  a  v  a 2s. com
        groupPosition = position;

    if (id == R.id.audio_list_browser_delete) {
        AlertDialog alertDialog = CommonDialogs.deleteMedia(getActivity(),
                mSongsAdapter.getLocations(groupPosition).get(0),
                new VLCRunnable(mSongsAdapter.getItem(groupPosition)) {
                    @Override
                    public void run(Object o) {
                        AudioBrowserListAdapter.ListItem listItem = (AudioBrowserListAdapter.ListItem) o;
                        Media media = listItem.mMediaList.get(0);
                        mMediaLibrary.getMediaItems().remove(media);
                        mSongsAdapter.removeMedia(media);
                        mAlbumsAdapter.removeMedia(media);
                        mAudioController.removeLocation(media.getLocation());
                    }
                });
        alertDialog.show();
        return true;
    }

    if (id == R.id.audio_list_browser_set_song) {
        AudioUtil.setRingtone(mSongsAdapter.getItem(groupPosition).mMediaList.get(0), getActivity());
        return true;
    }

    if (useAllItems) {
        medias = new ArrayList<String>();
        startPosition = mSongsAdapter.getListWithPosition(medias, groupPosition);
    } else {
        startPosition = 0;
        switch (mTabHost.getCurrentTab()) {
        case 0: // albums
            medias = mAlbumsAdapter.getLocations(groupPosition);
            break;
        case 1: // songs
            medias = mSongsAdapter.getLocations(groupPosition);
            break;
        default:
            return true;
        }
    }

    if (append)
        mAudioController.append(medias);
    else
        mAudioController.load(medias, startPosition);

    return super.onContextItemSelected(item);
}