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:com.flowzr.activity.BudgetListFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    super.onContextItemSelected(item);
    AdapterView.AdapterContextMenuInfo mi = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case R.id.context_budget_delete:
        deleteItem(null, item.getItemId(), selectedId);
        break;//  w w w.  j a v  a2s.c o m
    case R.id.context_budget_info:
        viewItem(null, item.getItemId(), selectedId);
        break;
    case R.id.context_budget_edit:
        editItem(null, item.getItemId(), selectedId);
        break;
    }
    return false;
}

From source file:com.money.manager.ex.currency.recycler.CurrencyRecyclerListFragment.java

@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
    RecyclerViewContextMenuInfo info = (RecyclerViewContextMenuInfo) item.getMenuInfo();
    Currency currency = getCurrencyAtPosition(info.position);
    int currencyId = currency.getCurrencyId();

    CurrencyUIFeatures ui = new CurrencyUIFeatures(getActivity());

    // check item selected
    int selectedItem = item.getItemId();
    switch (selectedItem) {
    case 0: //EDIT
        ui.startCurrencyEditActivity(currencyId);
        break;/*from   www .  j  ava 2 s  .c  o  m*/

    case 1: // Chart
        // remember the device orientation and return to it after the chart.
        // todo: this.mPreviousOrientation = ActivityUtils.forceCurrentOrientation(getActivity());

        // add the currency information.
        String symbol = currency.getCode();
        CurrencyService currencyService = this.getService();
        String baseCurrencyCode = currencyService.getBaseCurrencyCode();

        Intent intent = new Intent(getActivity(), CurrencyChartActivity.class);
        intent.setAction(Intent.ACTION_VIEW);
        intent.putExtra(Currency.CURRENCY_SYMBOL, symbol);
        intent.putExtra(CurrencyChartActivity.BASE_CURRENCY_SYMBOL, baseCurrencyCode);

        startActivity(intent);
        break;

    case 2: // Update exchange rate
        getService().updateExchangeRate(currencyId);
        break;

    case 3: //DELETE
        CurrencyService service = new CurrencyService(getActivity());
        boolean used = service.isCurrencyUsed(currencyId);

        if (used) {
            ui.notifyCurrencyCanNotBeDeleted();
        } else {
            ContentValues contentValues = new ContentValues();
            contentValues.put(Account.CURRENCYID, currencyId);
            ui.showDialogDeleteCurrency(currencyId, info.position);
        }
        break;
    }
    return false;
}

From source file:com.truman.showtime.showtime.ui.fragment.TheaterListFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterViewCompat.AdapterContextMenuInfo info = (AdapterViewCompat.AdapterContextMenuInfo) item
            .getMenuInfo();/*ww  w  .j  a  v  a  2 s  .c o  m*/
    if (item.getTitle().equals(getString(R.string.directions_theater))) {
        String theaterString = null;
        try {
            theaterString = URLEncoder.encode(mSelectedTheater.address, "UTF-8");
            Uri gmmIntentUri = Uri.parse("geo:0,0?q=" + theaterString);
            // Create an Intent from gmmIntentUri. Set the action to ACTION_VIEW
            Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
            // Make the Intent explicit by setting the Google Maps package
            //                mapIntent.setPackage("com.google.android.apps.maps");
            // Attempt to start an activity that can handle the Intent
            if (mapIntent.resolveActivity(mApplicationContext.getPackageManager()) != null) {
                startActivity(mapIntent);
            }
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    } else if (item.getTitle().equals(getString(R.string.share_theater))) {
        Intent sendIntent = new Intent();
        sendIntent.setAction(Intent.ACTION_SEND);
        sendIntent.putExtra(Intent.EXTRA_TEXT, mSelectedTheater.name + "\n" + mSelectedTheater.address + "\n"
                + "http://google.com/movies?near=" + mCity + "&tid=" + mSelectedTheater.id);

        sendIntent.setType("text/plain");
        startActivity(Intent.createChooser(sendIntent, getResources().getString(R.string.share_theater)));
    }
    return super.onContextItemSelected(item);
}

From source file:org.libreoffice.impressremote.fragment.ComputersFragment.java

private int getListItemPosition(android.view.MenuItem aMenuItem) {
    AdapterView.AdapterContextMenuInfo aMenuItemInfo = (AdapterView.AdapterContextMenuInfo) aMenuItem
            .getMenuInfo();//from  www . j av a  2 s .  c o m

    return aMenuItemInfo.position;
}

From source file:com.pentacog.mctracker.MCServerTrackerActivity.java

/**
 * @see android.app.Activity#onContextItemSelected(MenuItem item)
 *//*w ww.jav  a2  s .c o  m*/
@Override
public boolean onContextItemSelected(MenuItem item) {
    final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();

    switch (item.getItemId()) {
    case R.id.context_copy:
        Server server = serverList.getItem(info.position);
        String address = server.address.toString() + ":" + server.port;
        ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
        clipboard.setText(address);
        Toast.makeText(this, address + " Copied", Toast.LENGTH_SHORT).show();
        return true;
    case R.id.context_delete:
        deleteServer(info.position);
        return true;
    case R.id.context_edit:
        editServer(info.position);
        return true;
    case 124:
        Server s = serverList.getItem(info.position);
        s.favorite = !s.favorite;
        serverList.sort();
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:org.tunesremote.AllAlbumsListFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {

    int id = item.getItemId();
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();

    try {/* w w  w. j a va2 s  .c o  m*/
        final Response resp = (Response) adapter.getItem(info.position);
        final String albumid = resp.getNumberString("mper");

        if (id == R.id.context_album_play) {
            host.session.controlPlayAlbum(albumid, 0);
            host.setResult(Activity.RESULT_OK, new Intent());
            host.finish();
            return true;
        } else if (id == R.id.context_album_queue) {
            host.session.controlQueueAlbum(albumid);
            host.setResult(Activity.RESULT_OK, new Intent());
            host.finish();
            return true;
        } else if (id == R.id.context_album_browse) {
            Intent intent = new Intent(host, TracksActivity.class);
            intent.putExtra(Intent.EXTRA_TITLE, albumid);
            intent.putExtra("minm", resp.getString("minm"));
            intent.putExtra("miid", Long.valueOf(resp.getNumberLong("miid")).intValue());
            intent.putExtra("Artist", resp.getString("asaa"));
            intent.putExtra("AllAlbums", false);
            host.startActivityForResult(intent, 1);
            return true;
        }
    } catch (Exception ex) {
        Log.w(TAG, "onContextItemSelected: " + ex.getMessage());
    }

    return super.onContextItemSelected(item);
}

From source file:org.gateshipone.malp.application.fragments.serverfragments.AlbumsFragment.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 ww. jav  a 2 s .  com*/
@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_albums_action_enqueue:
        enqueueAlbum(info.position);
        return true;
    case R.id.fragment_albums_action_play:
        playAlbum(info.position);
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:com.ultramegasoft.flavordex2.fragment.CatListFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    final Context context = getContext();
    final FragmentManager fm = getFragmentManager();
    if (context == null || fm == null) {
        return super.onContextItemSelected(item);
    }/*from www  .  ja  v  a  2 s  . c o m*/

    final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case R.id.menu_edit:
        EditCatActivity.startActivity(context, info.id, mAdapter.getItem(info.position).name);
        return true;
    case R.id.menu_delete:
        CatDeleteDialog.showDialog(fm, null, 0, info.id);
        return true;
    }
    return super.onContextItemSelected(item);
}

From source file:com.royer.bangstopwatch.app.StopwatchFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {

    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();

    switch (item.getItemId()) {
    case R.id.menu_deletelap:
        this.mLapManager.DeleteLap(info.position);
        mLapAdapter.notifyDataSetChanged();
        updateRealElapseTime();/*from   ww  w.  j a va  2  s  .c o m*/
        printTime();
        return true;
    default:
        return super.onContextItemSelected(item);
    }

}

From source file:com.money.manager.ex.recurring.transactions.RecurringTransactionListFragment.java

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

    ContextMenu.ContextMenuInfo menuInfo = item.getMenuInfo();
    if (menuInfo == null) {
        String errorMessage = "no context menu info";
        Log.w(this.getClass().getSimpleName(), errorMessage);
        ExceptionHandler handler = new ExceptionHandler(getActivity(), this);
        handler.showMessage("no context menu info");
        return false;
    }//from  w w w  . j a va  2  s .c o m
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;

    int menuItemId = item.getItemId();
    int transactionId = (int) info.id;

    switch (menuItemId) {
    case R.id.menu_enter_next_occurrence:
        showCreateTransactionActivity(transactionId);
        break;

    case R.id.menu_skip_next_occurrence:
        confirmSkip(transactionId);
        break;

    case R.id.menu_edit:
        startRecurringTransactionEditActivity(transactionId, REQUEST_EDIT_REPEATING_TRANSACTION);
        break;

    case R.id.menu_delete:
        confirmDelete(transactionId);
        break;
    }

    return false;
}