Example usage for android.view ContextMenu setGroupVisible

List of usage examples for android.view ContextMenu setGroupVisible

Introduction

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

Prototype

public void setGroupVisible(int group, boolean visible);

Source Link

Document

Show or hide all menu items that are in the given group.

Usage

From source file:com.akop.bach.fragment.xboxlive.SentMessagesFragment.java

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

    getActivity().getMenuInflater().inflate(R.menu.xbl_sent_message_list_context, menu);

    menu.setHeaderTitle(getString(R.string.sent_message));
    menu.setGroupVisible(R.id.menu_group_gold_required, mAccount.isGold());
}

From source file:com.akop.bach.fragment.xboxlive.MessagesFragment.java

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

    AdapterContextMenuInfo acmi = (AdapterContextMenuInfo) menuInfo;
    ViewHolder vh = (ViewHolder) acmi.targetView.getTag();

    getActivity().getMenuInflater().inflate(R.menu.xbl_message_list_context, menu);

    menu.setHeaderTitle(getString(R.string.message_from_f, vh.sender.getText()));

    menu.setGroupVisible(R.id.menu_group_gold_required, mAccount.isGold());
    menu.setGroupVisible(R.id.menu_group_unread, Messages.isUnreadTextMessage(getActivity(), acmi.id));
}

From source file:org.videolan.vlc.gui.audio.AudioBrowserFragment.java

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

    if (v.getId() != R.id.songs_list) {
        menu.setGroupEnabled(R.id.songs_view_only, false);
        menu.setGroupEnabled(R.id.phone_only, false);
    }//from  w  w  w.ja va2  s.  c o m
    if (!Util.isPhone())
        menu.setGroupVisible(R.id.phone_only, false);
}

From source file:com.android.browser.BookmarksPageCallbacks.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    BookmarkContextMenuInfo info = (BookmarkContextMenuInfo) menuInfo;
    BrowserBookmarksAdapter adapter = getChildAdapter(info.groupPosition);
    Cursor cursor = adapter.getItem(info.childPosition);
    if (!canEdit(cursor)) {
        return;/*from  w  w w . j  a  v a2 s .  co m*/
    }
    boolean isFolder = cursor.getInt(BookmarksLoader.COLUMN_INDEX_IS_FOLDER) != 0;

    final Activity activity = getActivity();
    MenuInflater inflater = activity.getMenuInflater();
    inflater.inflate(R.menu.bookmarkscontext, menu);
    if (isFolder) {
        menu.setGroupVisible(R.id.FOLDER_CONTEXT_MENU, true);
    } else {
        menu.setGroupVisible(R.id.BOOKMARK_CONTEXT_MENU, true);
        if (mDisableNewWindow) {
            menu.findItem(R.id.new_window_context_menu_id).setVisible(false);
        }
    }
    BookmarkItem header = new BookmarkItem(activity);
    header.setEnableScrolling(true);
    populateBookmarkItem(cursor, header, isFolder);
    menu.setHeaderView(header);

    int count = menu.size();
    for (int i = 0; i < count; i++) {
        menu.getItem(i).setOnMenuItemClickListener(mContextItemClickListener);
    }
}

From source file:com.baohume.browser.BookmarksPageCallbacks.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    BookmarkExpandableView.BookmarkContextMenuInfo info = (BookmarkExpandableView.BookmarkContextMenuInfo) menuInfo;
    BrowserBookmarksAdapter adapter = getChildAdapter(info.groupPosition);
    Cursor cursor = adapter.getItem(info.childPosition);
    if (!canEdit(cursor)) {
        return;//from   www .j  a  v  a2s.co m
    }
    boolean isFolder = cursor.getInt(BookmarksLoader.COLUMN_INDEX_IS_FOLDER) != 0;

    final Activity activity = getActivity();
    MenuInflater inflater = activity.getMenuInflater();
    inflater.inflate(R.menu.bookmarkscontext, menu);
    if (isFolder) {
        menu.setGroupVisible(R.id.FOLDER_CONTEXT_MENU, true);
    } else {
        menu.setGroupVisible(R.id.BOOKMARK_CONTEXT_MENU, true);
        if (mDisableNewWindow) {
            menu.findItem(R.id.new_window_context_menu_id).setVisible(false);
        }
    }
    BookmarkItem header = new BookmarkItem(activity);
    header.setEnableScrolling(true);
    populateBookmarkItem(cursor, header, isFolder);
    menu.setHeaderView(header);

    int count = menu.size();
    for (int i = 0; i < count; i++) {
        menu.getItem(i).setOnMenuItemClickListener(mContextItemClickListener);
    }
}

From source file:com.borqs.browser.combo.BookmarksPageCallbacks.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    BookmarkContextMenuInfo info = (BookmarkContextMenuInfo) menuInfo;
    BrowserBookmarksAdapter adapter = getChildAdapter(info.groupPosition);
    Cursor cursor = adapter.getItem(info.childPosition);
    if (!canEdit(cursor)) {
        return;/*from ww  w  . j  a  v a 2  s .  c o m*/
    }
    boolean isFolder = cursor.getInt(BookmarksLoader.COLUMN_INDEX_IS_FOLDER) != 0;

    final Activity activity = this;
    MenuInflater inflater = activity.getMenuInflater();
    inflater.inflate(R.menu.bookmarkscontext, menu);
    if (isFolder) {
        menu.setGroupVisible(R.id.FOLDER_CONTEXT_MENU, true);
    } else {
        menu.setGroupVisible(R.id.BOOKMARK_CONTEXT_MENU, true);
        if (mDisableNewWindow) {
            menu.findItem(R.id.new_window_context_menu_id).setVisible(false);
        }
    }
    BookmarkItem header = new BookmarkItem(activity);
    header.setEnableScrolling(true);
    populateBookmarkItem(cursor, header, isFolder);
    menu.setHeaderView(header);

    int count = menu.size();
    for (int i = 0; i < count; i++) {
        menu.getItem(i).setOnMenuItemClickListener(mContextItemClickListener);
    }
}

From source file:org.tigase.mobile.roster.RosterFragment.java

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

    final Long id = extractId(menuInfo);

    if (id != null && id != -1) {
        RosterItem r = getJid(id);//from www. j av  a  2  s .co m
        final boolean sessionEstablished = r != null && isSessionEstablished(r.getSessionObject());

        MenuInflater m = new MenuInflater(getActivity());
        try {
            Presence p = r.getSessionObject().getPresence().getBestPresence(r.getJid());
            if (p != null && p.getType() == null) {
                SubMenu sm = menu.addSubMenu(R.id.contactsOnlineGroup, Menu.NONE, Menu.NONE, "Chat with");
                prepareResources(sm, id);
            }
        } catch (Exception e) {
        }
        m.inflate(R.menu.roster_context_menu, menu);

        JaxmppCore jaxmpp = this.getMulti().get(r.getSessionObject());
        if (jaxmpp != null && sessionEstablished) {
            GeolocationModule module = jaxmpp.getModule(GeolocationModule.class);
            if (module != null) {
                ContentValues location = module.getLocationForJid(r.getJid());
                if (location != null) {
                    Double lat = location.getAsDouble(GeolocationTableMetaData.FIELD_LAT);
                    Double lon = location.getAsDouble(GeolocationTableMetaData.FIELD_LON);
                    String uriStr = null;
                    if (lon == null || lat == null) {
                        String str = "";
                        String val = location.getAsString(GeolocationTableMetaData.FIELD_STREET);
                        Log.v(TAG, "Street = " + String.valueOf(val));
                        if (val != null) {
                            str += val;
                        }
                        val = location.getAsString(GeolocationTableMetaData.FIELD_LOCALITY);
                        Log.v(TAG, "Locality = " + String.valueOf(val));
                        if (val != null) {
                            if (!isEmpty(str)) {
                                str += " ";
                            }
                            str += val;
                        }
                        val = location.getAsString(GeolocationTableMetaData.FIELD_COUNTRY);
                        Log.v(TAG, "Country = " + String.valueOf(val));
                        if (val != null) {
                            if (!isEmpty(str)) {
                                str += " ";
                            }
                            str += val;
                        }

                        if (!isEmpty(str)) {
                            str = str.replace(' ', '+');
                            uriStr = "geo:0,0?q=" + str;
                        }
                    } else {
                        Log.v(TAG, "latitude = " + String.valueOf(lat));
                        Log.v(TAG, "longitude = " + String.valueOf(lon));
                        uriStr = "geo:" + String.valueOf(lat) + "," + String.valueOf(lon) + "?z=14";
                    }
                    if (uriStr != null) {
                        uriStr += "(" + RosterDisplayTools.getDisplayName(r) + ")";
                        Log.v(TAG, "created geolocation uri = " + uriStr);
                        Uri uri = Uri.parse(uriStr);
                        MenuItem item = menu.add(R.string.geolocation_show);
                        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                        item.setIntent(intent);
                    }
                }
            }
        }

        menu.setGroupVisible(R.id.contactsOnlineGroup, sessionEstablished);
    }
}