Example usage for android.view ContextMenu removeItem

List of usage examples for android.view ContextMenu removeItem

Introduction

In this page you can find the example usage for android.view ContextMenu removeItem.

Prototype

public void removeItem(int id);

Source Link

Document

Remove the item with the given identifier.

Usage

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

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    MenuInflater inflater = mActivity.getMenuInflater();
    inflater.inflate(R.menu.channels_menu, menu);
    AdapterContextMenuInfo mi = (AdapterContextMenuInfo) menuInfo;
    menu.setHeaderTitle(mController.getChannelName(mi.position));

    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mActivity);
    if (mSearchTime != 0) {
        menu.removeItem(R.id.cm_remote);
        menu.removeItem(R.id.cm_livetv);
    } else if (!sp.getBoolean("livetv_enabled", false)) {
        menu.removeItem(R.id.cm_livetv);
    }/*from   www .j ava  2s  .c  o m*/

    if (Preferences.useInternet && !Preferences.getVdr().extremux) {
        MenuItem menuitem = menu.findItem(R.id.cm_livetv);
        if (menuitem != null)
            menuitem.setEnabled(false);
    }
}

From source file:com.github.nutomic.pegasus.activities.AreaList.java

/**
 * Create context menu for ListView items. Modifiers are hidden for the
 * default area.//from  w  ww  .j av a 2s  .  co m
 */
public void onCreateContextMenu(android.view.ContextMenu menu, View v,
        android.view.ContextMenu.ContextMenuInfo menuInfo) {
    getMenuInflater().inflate(R.menu.area_list_context, menu);
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;

    String name = getAreaName(info);

    menu.setHeaderTitle(name);

    // Default area selected, can't rename, learn or delete.
    if (info.id == AreaColumns.AREA_DEFAULT) {
        menu.removeItem(R.id.rename);
        menu.removeItem(R.id.learn);
        menu.removeItem(R.id.delete);
    }
}

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

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;

    super.onCreateContextMenu(menu, v, menuInfo);
    MenuInflater inflater = getActivity().getMenuInflater();

    inflater.inflate(R.menu.manga_context, menu);

    DB db = DB.getInstance(getActivity());
    int status = db.getManga(info.id).getAsInteger(DB.MANGA_SUBSCRIPTION_STATUS);
    ;//from   www.j  ava 2  s  .  c om

    if (status != DB.SUBSCRIPTION_FOLLOWING)
        menu.removeItem(R.id.stop_following);
    else
        menu.removeItem(R.id.follow);
}

From source file:net.potterpcs.recipebook.DirectionsEditor.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    MenuInflater inflater = getActivity().getMenuInflater();
    inflater.inflate(R.menu.directionscontext, menu);

    // Don't display the "Remove Photo" option if there's no photo to remove.
    // On the other hand, if there's already a photo, don't try to add another.
    // TODO Maybe allow a "Change Photo" option
    if (photoUris.get(((AdapterContextMenuInfo) menuInfo).position) == null) {
        menu.removeItem(R.id.ctxremovephotodirection);
    } else {/*from w w  w  . jav  a2 s.  c om*/
        menu.removeItem(R.id.ctxphotodirection);
    }
}

From source file:de.jan.ledgerjournal.JournalActivity.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    if (v.getId() == R.id.journalListView) {
        AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
        Transaction t = journal.get(info.position);
        menu.setHeaderTitle(t.date + "\t" + t.payee);

        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.context_journal, menu);
        if (topfId == JournalDbHelper.TEMPLATE_TOPFID)
            menu.removeItem(R.id.context_journal_template);
    }//  ww w  . j  a v a2  s  .co  m
}

From source file:prince.app.sphotos.Fragment_Albums.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;

    // set the contextual menu header
    menu.setHeaderTitle(FBINIT.sAlbumsArray.get(info.position).mAlbumName);

    MenuInflater inflater = getActivity().getMenuInflater();
    inflater.inflate(R.menu.album_menu, menu);

    // hide add photos if we cannot upload to this album
    if (!FBINIT.sAlbumsArray.get(info.position).mAlbumUpload) {
        menu.removeItem(R.id.album_add);
    }/*from   www  .j av a 2  s . c om*/
}

From source file:org.rebo.app.TileMap.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);

    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.map_menu, menu);

    if (App.poiSearch.getPOIs().isEmpty())
        menu.removeItem(R.id.menu_poi_clear);

    if (App.routeSearch.isEmpty())
        menu.removeItem(R.id.menu_route_clear);
}

From source file:de.elanev.studip.android.app.widget.UserListFragment.java

/**
 * Creating floating context menu//from   w ww  .  j a  v  a 2 s  .c  o  m
 */
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    MenuInflater inflater = getActivity().getMenuInflater();
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    Cursor listItemCursor = (Cursor) mListView.getAdapter().getItem(info.position);

    final String[] projection = new String[] {
            ContactsContract.Qualified.ContactGroups.CONTACT_GROUPS_GROUP_NAME,
            ContactsContract.Qualified.ContactGroups.CONTACT_GROUPS_GROUP_ID,
            ContactsContract.Qualified.ContactGroups.CONTACT_GROUPS_ID };
    final String contactId = listItemCursor
            .getString(listItemCursor.getColumnIndex(UsersContract.Columns.USER_ID));

    CursorLoader loader = new CursorLoader(getActivity(),
            ContactsContract.CONTENT_URI_CONTACTS.buildUpon().appendPath(contactId).build(), projection, null,
            null, ContactsContract.Columns.ContactGroups.GROUP_NAME + " ASC");

    final Cursor c = loader.loadInBackground();

    if (c.getCount() <= 0) {
        inflater.inflate(R.menu.user_add_context_menu, menu);
    } else {
        inflater.inflate(R.menu.user_context_menu, menu);
        c.moveToFirst();
        while (!c.isAfterLast()) {
            String currGroupName = c
                    .getString(c.getColumnIndex(ContactsContract.Columns.ContactGroups.GROUP_NAME));
            if (TextUtils.equals(currGroupName, getString(R.string.studip_app_contacts_favorites))) {
                menu.removeItem(R.id.add_to_favorites);
                menu.findItem(R.id.remove_from_favorites).setVisible(true);
            }

            c.moveToNext();
        }

    }
    c.close();
}