Example usage for android.support.v4.view MenuItem getMenuInfo

List of usage examples for android.support.v4.view MenuItem getMenuInfo

Introduction

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

Prototype

public ContextMenuInfo getMenuInfo();

Source Link

Document

Gets the extra information linked to this menu item.

Usage

From source file:com.abcvoipsip.ui.messages.ConversationsListFragment.java

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

    if (info.position > 0) {
        ConversationListItemViews cri = (ConversationListItemViews) info.targetView.getTag();

        if (cri != null) {
            switch (item.getItemId()) {
            case MENU_DELETE: {
                confirmDeleteThread(cri.getRemoteNumber());
                break;
            }//from   w w  w.ja v a2s .  com
            case MENU_VIEW: {
                viewDetails(info.position, cri);
                break;
            }
            default:
                break;
            }
        }
    }
    return super.onContextItemSelected(item);
}

From source file:com.abcvoipsip.ui.prefs.CodecsFragment.java

@Override
@SuppressWarnings("unchecked")
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info;
    try {/*www .ja va2 s  .c om*/
        info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    } catch (ClassCastException e) {
        Log.e(THIS_FILE, "bad menuInfo", e);
        return false;
    }

    HashMap<String, Object> codec = null;
    codec = (HashMap<String, Object>) mAdapter.getItem(info.position);

    if (codec == null) {
        // If for some reason the requested item isn't available, do nothing
        return false;
    }
    int selId = item.getItemId();
    if (selId == MENU_ITEM_ACTIVATE) {
        boolean isDisabled = ((Short) codec.get(CODEC_PRIORITY) == 0);
        final short newPrio = isDisabled ? (short) 1 : (short) 0;
        if (NON_FREE_CODECS.containsKey(codec.get(CODEC_ID)) && isDisabled) {
            final HashMap<String, Object> fCodec = codec;

            final TextView message = new TextView(getActivity());
            final SpannableString s = new SpannableString(
                    getString(R.string.this_codec_is_not_free) + NON_FREE_CODECS.get(codec.get(CODEC_ID)));
            Linkify.addLinks(s, Linkify.WEB_URLS);
            message.setText(s);
            message.setMovementMethod(LinkMovementMethod.getInstance());
            message.setPadding(10, 10, 10, 10);

            //Alert user that we will disable for all incoming calls as he want to quit
            new AlertDialog.Builder(getActivity()).setTitle(R.string.warning).setView(message)
                    .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            setCodecActivated(fCodec, newPrio);
                        }
                    }).setNegativeButton(R.string.cancel, null).show();
        } else {
            setCodecActivated(codec, newPrio);
        }
        return true;
    }
    return false;
}

From source file:mobisocial.musubi.ui.fragments.ContactsFragment.java

public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    int menuItemIndex = item.getItemId();

    Cursor cursor = (Cursor) mContacts.getItem(info.position);
    final MIdentity ident = mIdentityManager
            .getIdentityForId(cursor.getLong(cursor.getColumnIndexOrThrow(MIdentity.COL_ID)));

    switch (menuItemIndex) {
    case 0://from www .j a  v  a 2 s.  c  o  m
        ignoreContact(ident);
        break;
    case 1:
        String email = ident.principal_;
        if (email == null) {
            Toast.makeText(getActivity(), "Oops, couldn't set up email.", Toast.LENGTH_SHORT).show();
            return true;
        }

        Intent intent = EmailInviteActivity.getInviteIntentForEmail(getActivity(), email);
        startActivity(intent);
        break;
    }
    return true;
}

From source file:com.abcvoipsip.ui.account.AccountsEditListFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    final SipProfile account = profileFromContextMenuInfo(item.getMenuInfo());
    if (account == null) {
        // For some reason the requested item isn't available, do nothing
        return super.onContextItemSelected(item);
    }// w ww . jav  a 2  s.c o m

    switch (item.getItemId()) {
    case MENU_ITEM_DELETE: {
        getActivity().getContentResolver()
                .delete(ContentUris.withAppendedId(SipProfile.ACCOUNT_ID_URI_BASE, account.id), null, null);
        return true;
    }
    case MENU_ITEM_MODIFY: {
        showDetails(account.id, account.wizard);
        return true;
    }
    case MENU_ITEM_ACTIVATE: {
        ContentValues cv = new ContentValues();
        cv.put(SipProfile.FIELD_ACTIVE, !account.active);
        getActivity().getContentResolver()
                .update(ContentUris.withAppendedId(SipProfile.ACCOUNT_ID_URI_BASE, account.id), cv, null, null);
        return true;
    }
    case MENU_ITEM_WIZARD: {
        Intent it = new Intent(getActivity(), WizardChooser.class);
        it.putExtra(Intent.EXTRA_UID, account.id);
        startActivityForResult(it, CHANGE_WIZARD);
        return true;
    }
    }
    return super.onContextItemSelected(item);

}

From source file:com.todoroo.astrid.activity.FilterListFragment.java

@Override
public boolean onOptionsItemSelected(final MenuItem item) {
    // handle my own menus
    switch (item.getItemId()) {
    case CONTEXT_MENU_SHORTCUT: {
        AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
        final Intent shortcutIntent = item.getIntent();
        FilterListItem filter = ((FilterAdapter.ViewHolder) info.targetView.getTag()).item;
        if (filter instanceof Filter)
            showCreateShortcutDialog(getActivity(), shortcutIntent, (Filter) filter);

        return true;
    }/*from w ww .  ja  v  a 2s. c  o m*/
    case CONTEXT_MENU_INTENT: {
        Intent intent = item.getIntent();
        startActivityForResult(intent, REQUEST_CUSTOM_INTENT);
        return true;
    }
    default: {
        Fragment tasklist = getSupportFragmentManager()
                .findFragmentByTag(TaskListFragment.TAG_TASKLIST_FRAGMENT);
        if (tasklist != null && tasklist.isInLayout())
            return tasklist.onOptionsItemSelected(item);
    }
    }
    return false;
}

From source file:com.ushahidi.android.app.ui.phone.AddCheckinActivity.java

@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    boolean result = performAction(item, info.position);

    if (!result) {
        result = super.onContextItemSelected(item);
    }//w w  w.j  a  v a2  s  .c  o m

    return result;

}

From source file:com.chess.genesis.activity.GameListOnlineFrag.java

@Override
public boolean onContextItemSelected(final MenuItem item) {
    if (!act.lastContextMenu.equals(getBTag()))
        return super.onContextItemSelected(item);

    switch (item.getItemId()) {
    case R.id.new_game:
    case R.id.resync:
    case R.id.readall_msgs:
        return onOptionsItemSelected(item);
    }/*from   ww w .  j  a  va  2  s  .  c  om*/

    final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    final GameListAdapter listAdapter = gamelistadapter_arr[pager.getCurrentItem()];
    final Bundle bundle = (Bundle) listAdapter.getItem((int) info.id);

    switch (item.getItemId()) {
    case R.id.delete_game:
        new DeleteArchiveDialog(act, handle, bundle.getString("gameid")).show();
        break;
    case R.id.local_copy:
        final int type = (pager.getCurrentItem() == ARCHIVE_PAGE) ? Enums.ARCHIVE_GAME : Enums.ONLINE_GAME;
        new CopyGameConfirm(act, bundle.getString("gameid"), type).show();
        break;
    case R.id.rematch:
        final String username = listAdapter.getExtras().getString("username");
        final String opponent = username.equals(bundle.getString("white")) ? bundle.getString("black")
                : bundle.getString("white");
        new RematchConfirm(act, handle, opponent).show();
        break;
    case R.id.nudge:
        new NudgeConfirm(act, handle, bundle.getString("gameid")).show();
        break;
    case R.id.share_game:
        sendGame(bundle);
        break;
    default:
        return super.onContextItemSelected(item);
    }
    return true;
}

From source file:com.ushahidi.android.app.ui.phone.ListMapActivity.java

@Override
public boolean onContextItemSelected(android.view.MenuItem item) {

    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    boolean result = performAction(item, info.position);

    if (!result) {
        result = super.onContextItemSelected(item);
    }//from  w ww  .j a v a2s  .  co m

    return (result);
}

From source file:mobisocial.musubi.ui.fragments.FeedListFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    int menuItemIndex = item.getItemId();
    Cursor cursor = (Cursor) mFeeds.getItem(info.position);

    switch (menuItemIndex) {
    case 0://ww w  .ja  va2  s .c  o  m
        //pass the feed id in
        handleDelete(cursor.getLong(0));
        break;
    case 1:
        //pass the feed id in
        handleExport(cursor.getLong(0));
        break;
    }
    return true;
}