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.videolan.vlc.gui.HistoryFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    if (!getUserVisibleHint())
        return super.onContextItemSelected(item);

    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    if (info == null) // info can be null
        return super.onContextItemSelected(item);
    int id = item.getItemId();

    if (id == R.id.history_view_play) {
        playListIndex(info.position);//from  w w w.  ja va  2  s .  c o  m
        return true;
    } else if (id == R.id.history_view_delete) {
        LibVLC.getExistingInstance().getPrimaryMediaList().remove(info.position);
        mHistoryAdapter.refresh();
        return true;
    }
    return super.onContextItemSelected(item);
}

From source file:com.racoon.ampdroid.views.SelectedAlbumsView.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    Album a = controller.getSelectedAlbums().get((int) info.id);
    switch (item.getItemId()) {
    case R.id.contextMenuAdd:
        for (Song s : controller.findSongs(a)) {
            controller.getPlayNow().add(s);
        }/*  w  w w . j  a va2  s  .  c  o  m*/
        Context context = getView().getContext();
        CharSequence text = getResources().getString(R.string.albumsViewAlbumsAdded);
        int duration = Toast.LENGTH_SHORT;
        Toast toast = Toast.makeText(context, text, duration);
        toast.show();
        return true;
    case R.id.contextMenuOpen:
        controller.getSelectedSongs().clear();
        for (Song s : controller.findSongs(a)) {
            controller.getSelectedSongs().add(s);
        }
        // Create new fragment and transaction
        SelectedSongsView newFragment = new SelectedSongsView();
        FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();

        // Replace whatever is in the fragment_container view with this fragment,
        // and add the transaction to the back stack
        transaction.replace(R.id.content_frame, newFragment);
        transaction.addToBackStack(null);

        // Commit the transaction
        transaction.commit();
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:com.racoon.ampdroid.views.SelectedArtistsView.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    Artist a = controller.getSelectedArtists().get((int) info.id);
    switch (item.getItemId()) {
    case R.id.contextMenuAdd:
        for (Song s : controller.findSongs(a)) {
            controller.getPlayNow().add(s);
        }/*from  w  w w  . java 2 s.  c om*/
        Context context = getView().getContext();
        CharSequence text = getResources().getString(R.string.artistsViewArtistSongsAdded);
        int duration = Toast.LENGTH_SHORT;
        Toast toast = Toast.makeText(context, text, duration);
        toast.show();
        return true;
    case R.id.contextMenuOpen:
        controller.getSelectedSongs().clear();
        for (Song s : controller.findSongs(a)) {
            controller.getSelectedSongs().add(s);
        }
        // Create new fragment and transaction
        SelectedSongsView newFragment = new SelectedSongsView();
        FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();

        // Replace whatever is in the fragment_container view with this fragment,
        // and add the transaction to the back stack
        transaction.replace(R.id.content_frame, newFragment);
        transaction.addToBackStack(null);

        // Commit the transaction
        transaction.commit();
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:de.nico.ha_manager.activities.Main.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    if (item.getTitle() == getString(R.string.dialog_edit)) {
        editOne(hwArray, pos);/* w w  w . j  av a  2s  .  c  om*/
        return true;
    }
    if (item.getTitle() == getString(R.string.dialog_delete)) {
        deleteOne(hwArray, pos);
        update();
        return true;
    }
    return false;

}

From source file:com.tastycactus.timesheet.TimeEntriesActivity.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
    case DELETE_TIME_ENTRY_MENU_ITEM:
        for (EntriesBase fragment : fragmentAdapter.getFragments())
            fragment.deleteTimeEntry(info.id);
        // Update the App Widget in case we deleted the currently-active
        // time entry
        startService(new Intent(this, TimesheetAppWidgetProvider.UpdateService.class));
        return true;
    case EDIT_TIME_ENTRY_MENU_ITEM:
        Intent i = new Intent(this, TimeEntryEditActivity.class);
        i.putExtra("_id", info.id);
        startActivityForResult(i, ACTIVITY_EDIT);
        return true;
    }//from ww w .  j  a va2s  . co  m
    return false;
}

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

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    Cursor c = adapter.getCursor();
    c.moveToPosition(info.position);//  ww  w.  j  a va 2 s.  c om
    String sensorName = c.getString(c.getColumnIndexOrThrow(SensAppContract.Sensor.NAME));
    switch (item.getItemId()) {
    case MENU_DELETE_ID:
        new DeleteSensorsTask(getActivity()).execute(sensorName);
        return true;
    case MENU_UPLOAD_ID:
        Intent i = new Intent(getActivity(), SensAppService.class);
        i.setAction(SensAppService.ACTION_UPLOAD);
        i.setData(Uri.parse(SensAppContract.Measure.CONTENT_URI + "/" + sensorName));
        getActivity().startService(i);
        return true;
    }
    return super.onContextItemSelected(item);
}

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

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

    switch (item.getItemId()) {
    case R.id.download_chapter:
        Download.startChapterDownload(getActivity(), info.id);
        return true;
    case R.id.stop_chapter_download:
        Download.stopChapterDownload(getActivity(), info.id);
        return true;
    case R.id.view_chapter:
        showChapter(info.id);/*from  w  w  w  . ja v  a  2 s.c o m*/
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

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

@Override
public boolean onContextItemSelected(MenuItem item) {
    if (!getUserVisibleHint())
        return false;
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    if (info == null)
        return false;
    final Uri feedUri = ContentUris.withAppendedId(Feeds.CONTENT_URI, info.id);
    new Thread() {
        @Override/*from  w ww.ja v a2  s  .com*/
        public void run() {
            getActivity().getContentResolver().delete(feedUri, null, null);
        }
    }.start();
    return true;
}

From source file:com.racoon.ampdroid.views.SelectedPlaylistsView.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    Playlist selected = controller.getSelectedPlaylists().get((int) info.id);
    String urlString = controller.getServer().getHost() + "/server/xml.server.php?action=playlist_songs&auth="
            + controller.getServer().getAuthKey() + "&filter=" + String.valueOf(selected.getId());
    Log.d("url", urlString);
    switch (item.getItemId()) {
    case R.id.contextMenuAdd:
        controller.parsePlaylistSongs(urlString, controller.getPlayNow());
        Context context = getView().getContext();
        CharSequence text = getResources().getString(R.string.playlistsViewPlaylistAdded);
        int duration = Toast.LENGTH_SHORT;
        Toast toast = Toast.makeText(context, text, duration);
        toast.show();/*w w  w  .  ja v  a 2  s.co m*/
        return true;
    case R.id.contextMenuOpen:
        controller.getSelectedSongs().clear();
        controller.parsePlaylistSongs(urlString, controller.getSelectedSongs());
        // Create new fragment and transaction
        SelectedSongsView newFragment = new SelectedSongsView();
        FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();

        // Replace whatever is in the fragment_container view with this fragment,
        // and add the transaction to the back stack
        transaction.replace(R.id.content_frame, newFragment);
        transaction.addToBackStack(null);

        // Commit the transaction
        transaction.commit();
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}

From source file:com.piusvelte.wapdroid.ManageData.java

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

    if (item.getItemId() == R.id.menu_remove) {
        ContentResolver contentResolver = getActivity().getContentResolver();
        contentResolver.delete(Networks.CONTENT_URI, Networks._ID + "=?", new String[] { String.valueOf(id) });
        BackupManager.dataChanged(getActivity());
    }/*from  ww w  .  j  a v a 2 s.c  om*/

    return super.onContextItemSelected(item);
}