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:net.alexjf.tmm.fragments.ImmedTransactionListFragment.java

@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
    ImmediateTransactionAdapter adapter = (ImmediateTransactionAdapter) getListAdapter();
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    ImmediateTransaction transaction = adapter.getItem(info.position);
    switch (item.getItemId()) {
    case R.id.menu_remove:
        try {// w ww  . java  2s . co  m
            transaction.getMoneyNode().removeImmediateTransaction(transaction);
            adapter.remove(transaction);
            listener.onImmedTransactionRemoved(transaction);
        } catch (DatabaseException e) {
            Log.e("TMM", "Unable to remove immediate transaction", e);
        }
        return true;
    case R.id.menu_edit:
        Intent intent = new Intent(getListView().getContext(), ImmedTransactionEditActivity.class);
        intent.putExtra(ImmediateTransaction.KEY_TRANSACTION, transaction);
        startActivityForResult(intent, REQCODE_EDIT);
        return true;
    case R.id.menu_duplicate:
        duplicateFragment.setTransaction(transaction);
        duplicateFragment.show(getFragmentManager(), TAG_DUPLICATE);
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:com.facebook.samples.switchuser.SettingsFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    SlotAdapter adapter = (SlotAdapter) getListAdapter();
    Slot slot = adapter.getItem(info.position);

    switch (item.getItemId()) {
    case R.id.menu_item_clear_slot:
        if (slot.getUserId() != null) {
            // Clear out data that this app stored in the cache
            // Not calling Session.closeAndClearTokenInformation() because we have additional
            // data stored in the cache.
            slot.clear();/*from w w w.jav  a  2  s  . c o m*/
            if (slot == slotManager.getSelectedSlot()) {
                slotManager.toggleSlot(info.position);
            }

            updateListView();
        }
        return true;
    }

    return super.onContextItemSelected(item);
}

From source file:com.wheelly.fragments.LocationsListFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    return (handleContextItem(item.getItemId(), ((AdapterContextMenuInfo) item.getMenuInfo()).id)) ? true
            : super.onContextItemSelected(item);

}

From source file:vn.cybersoft.obs.android.activities.TimeScheduleActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    final long id = info.id;
    // Error check just in case.
    if (id == -1) {
        return super.onContextItemSelected(item);
    }//  w w w .  j  av a 2 s . c  o  m
    switch (item.getItemId()) {
    case R.id.delete_schedule:
        // Confirm that the schedule will be deleted.
        new AlertDialog.Builder(this).setTitle(getString(R.string.delete_schedule))
                .setMessage(getString(R.string.delete_schedule_confirm))
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface d, int w) {
                        TimeSchedule.deleteTimeSchedule(TimeScheduleActivity.this, id);
                    }
                }).setNegativeButton(android.R.string.cancel, null).show();
        return true;

    case R.id.enable_schedule:
        final Cursor c = (Cursor) mScheduleList.getAdapter().getItem(info.position);
        final TimeSchedule schedule = new TimeSchedule(c);
        TimeSchedule.enableTimeSchedule(this, schedule.id, !schedule.enabled);
        if (!schedule.enabled) {
            //TODO
        }
        return true;

    case R.id.edit_schedule:
        Intent intent = new Intent(this, SetTimeScheduleActivity.class);
        intent.putExtra(TimeSchedule.EXTRA_ID, id);
        startActivity(intent);
        return true;

    default:
        break;
    }
    return super.onContextItemSelected(item);
}

From source file:com.google.android.apps.mytracks.MarkerListActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    if (handleContextItem(item.getItemId(), ((AdapterContextMenuInfo) item.getMenuInfo()).id)) {
        return true;
    }/*from   ww w. j a va2 s  .co  m*/
    return super.onContextItemSelected(item);
}

From source file:org.onebusaway.android.ui.MyRemindersFragment.java

@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case CONTEXT_MENU_DEFAULT:
        // Fake a click
        onListItemClick(getListView(), info.targetView, info.position, info.id);
        return true;
    case CONTEXT_MENU_DELETE:
        deleteTrip(getListView(), info.position);
        return true;
    case CONTEXT_MENU_SHOWSTOP:
        goToStop(getListView(), info.position);
        return true;
    case CONTEXT_MENU_SHOWROUTE:
        goToRoute(getListView(), info.position);
        return true;
    default:/* w  w  w.j  a v a 2s . c o  m*/
        return super.onContextItemSelected(item);
    }
}

From source file:com.money.manager.ex.budget.BudgetListFragment.java

@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    int budgetId = (int) info.id;
    int id = item.getItemId();
    ContextMenuIds menuId = ContextMenuIds.get(id);

    switch (menuId) {
    case EDIT://from   w  w w.j  ava 2s  .co  m
        editBudget(budgetId);
        break;
    case DELETE:
        confirmDelete(budgetId);
        break;
    case COPY:
        BudgetService service = new BudgetService(getActivity());
        service.copy(budgetId);
        break;
    default:
        return false;
    }
    return false;
}

From source file:br.com.GUI.aulas.Agenda.java

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

    switch (item.getItemId()) {
    case R.id.mnuExcluirAula:
        Toast.makeText(getActivity(), "entreeei", Toast.LENGTH_SHORT).show();
        break;/*from   w  w w .jav a 2s. co  m*/
    case R.id.mnuEditarAula:
        Toast.makeText(getActivity(), "entreeei editaar", Toast.LENGTH_SHORT).show();
        break;

    }
    return true;
}

From source file:org.gateshipone.malp.application.fragments.serverfragments.ArtistsFragment.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 ww  w  .j  av a 2  s.c  om
@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.fragment_artist_action_enqueue:
        enqueueArtist(info.position);
        return true;
    case R.id.fragment_artist_action_play:
        playArtist(info.position);
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:com.easemob.ui.ContactlistFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.delete_contact) {
        User tobeDeleteUser = adapter.getItem(((AdapterContextMenuInfo) item.getMenuInfo()).position);
        //?/*from w w  w.j  a v a 2  s  . com*/
        deleteContact(tobeDeleteUser);
        //?
        InviteMessgeDao dao = new InviteMessgeDao(getActivity());
        dao.deleteMessage(tobeDeleteUser.getUsername());
        return true;
    }
    return super.onContextItemSelected(item);
}