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:org.akvo.flow.activity.ListUserActivity.java

/**
 * spawns an activity (configured in initializeFields) in Edit mode
 *//*from   www . j a v a 2 s.co  m*/
@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case EDIT_ID:
        handleCreate(info.id);
        return true;
    case DELETE_ID:
        handleDelete(info.id);
        return true;
    }
    return super.onContextItemSelected(item);
}

From source file:org.sanpra.checklist.activity.ChecklistActivity.java

@Override
public boolean onContextItemSelected(MenuItem menuItem) {
    final AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuItem.getMenuInfo();
    switch (menuItem.getItemId()) {
    case R.id.context_menu_delete:
        mDbHelper.deleteItem(info.id);//from   w  ww. jav  a2  s.  c o  m
        refreshChecklistDataAndView();
        return true;

    case R.id.context_menu_edit:
        final Intent editItemIntent = new Intent(this, ItemDescriptionEntryActivity.class);
        editItemIntent.putExtra(actionTag, EDIT_ITEM_ACTION);
        editItemIntent.putExtra("item_id", info.id);
        startActivity(editItemIntent);
        return true;

    default:
        return super.onContextItemSelected(menuItem);
    }
}

From source file:eu.trentorise.smartcampus.eb.fragments.ExperiencesListFragment.java

@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
    final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    final Experience exp = experiencesList.get(info.position);
    switch (item.getItemId()) {
    case R.id.expmenu_remove:
        DialogFragment newFragment = new DeleteExperienceFragment();
        newFragment.setArguments(DeleteExperienceFragment.prepare(exp.getId()));
        newFragment.show(getActivity().getSupportFragmentManager(), "exp_delete");
        return true;
    case R.id.expmenu_assign_collection:
        DialogFragment assignFragment = new AssignCollectionFragment();
        assignFragment.setArguments(AssignCollectionFragment.prepare(exp.getId(), exp.getCollectionIds()));
        assignFragment.show(getActivity().getSupportFragmentManager(), "exp_assign_colls");
        return true;
    default:/*from   www  .  ja v a 2 s  .c o m*/
        Toast.makeText(getActivity(), R.string.not_implemented, Toast.LENGTH_SHORT).show();
        return true;
    }

}

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

@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case CONTEXT_MENU_DELETE:
        final String id = QueryUtils.StopList.getId(getListView(), info.position);
        final Uri uri = Uri.withAppendedPath(ObaContract.Stops.CONTENT_URI, id);
        ObaContract.Stops.markAsFavorite(getActivity(), uri, false);
        return true;
    default:/*from  www .ja v a2s. co  m*/
        return super.onContextItemSelected(item);
    }
}

From source file:org.barbon.mangaget.fragments.MangaSearchResults.java

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

    switch (item.getItemId()) {
    case R.id.add_manga:
        addManga(info.position);//from www.j  av a  2  s . com
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:can.yrt.onebusaway.MySearchStopsFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (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_SHOW_ON_MAP:
        showOnMap(getListView(), info.position);
        return true;
    default:/*from   ww  w .ja v  a  2  s.  c  om*/
        return super.onContextItemSelected(item);
    }
}

From source file:net.tacks_a.ankicard.fragment.AnkiCardListFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    LogUtil.logDebug();//w  w  w.ja v a 2 s. c o  m
    AdapterView.AdapterContextMenuInfo info;
    info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();

    switch (item.getItemId()) {
    case R.id.lst_anki_card_edit:
        // 
        showEditAnkiCard(mAnkiCardList.get(info.position));
        return true;
    case R.id.lst_anki_card_delete:
        // 
        deleteAnkiCard(mAnkiCardList.get(info.position));
        return true;
    }
    return false;
}

From source file:de.androvdr.fragments.TimersFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case R.id.timer_overview:
        mController.action(TimerController.TIMER_ACTION_PROGRAMINFOS, info.position);
        return true;
    case R.id.timer_overviewfull:
        mController.action(TimerController.TIMER_ACTION_PROGRAMINFOS_ALL, info.position);
        return true;
    case R.id.timer_delete:
        AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
        builder.setMessage(R.string.timer_delete_timer).setCancelable(false)
                .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.dismiss();
                        mController.action(TimerController.TIMER_ACTION_DELETE, info.position);
                    }//from w  w  w . j a v a  2s  .c om
                }).setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                });
        AlertDialog alert = builder.create();
        alert.show();
        return true;
    case R.id.timer_toggle:
        mController.action(TimerController.TIMER_ACTION_TOGGLE, info.position);
        return true;
    case R.id.timer_record:
        mController.action(TimerController.TIMER_ACTION_RECORD, info.position);
        return true;
    case R.id.timer_switch:
        mController.action(TimerController.TIMER_ACTION_SWITCH_CAHNNEL, info.position);
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:vn.cybersoft.obs.android.activities.PowerScheduleActivity.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. java 2s .c om

    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) {
                        PowerSchedule.deleteSchedule(getContentResolver(), 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 PowerSchedule schedule = new PowerSchedule(c);
        PowerSchedule.enableSchedule(getContentResolver(), schedule.id, !schedule.enabled);
        return true;

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

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

From source file:org.sensapp.android.sensappdroid.fragments.MeasureListFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case MENU_DELETE_ID:
        new DeleteMeasuresTask(getActivity(), SensAppContract.Measure.CONTENT_URI)
                .execute(SensAppContract.Measure.ID + " = " + info.id);
        return true;
    case MENU_UPLOAD_ID:
        new PutMeasuresTask(getActivity(), Uri.parse(SensAppContract.Measure.CONTENT_URI + "/" + info.id))
                .execute();/*  w  w  w.j av a 2s. c o m*/
        return true;
    }
    return super.onContextItemSelected(item);
}