Example usage for android.widget ExpandableListView getPackedPositionGroup

List of usage examples for android.widget ExpandableListView getPackedPositionGroup

Introduction

In this page you can find the example usage for android.widget ExpandableListView getPackedPositionGroup.

Prototype

public static int getPackedPositionGroup(long packedPosition) 

Source Link

Document

Gets the group position from a packed position.

Usage

From source file:org.yammp.fragment.ArtistFragment.java

@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo info) {

    ExpandableListContextMenuInfo mi = (ExpandableListContextMenuInfo) info;

    int itemtype = ExpandableListView.getPackedPositionType(mi.packedPosition);
    mSelectedGroupPosition = ExpandableListView.getPackedPositionGroup(mi.packedPosition);
    int gpos = mSelectedGroupPosition;
    if (itemtype == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {

        mGroupSelected = true;/*  w  w  w.  jav  a 2  s .  c o  m*/
        mChildSelected = false;
        mGroupCursor.moveToPosition(gpos);
        menu.add(hashCode(), PLAY_SELECTION, 0, R.string.play_selection);
        menu.add(hashCode(), DELETE_ITEMS, 0, R.string.delete_music);
        menu.add(hashCode(), DELETE_LYRICS, 0, R.string.delete_lyrics);
        if (gpos == -1) {
            // this shouldn't happen
            Log.d("Artist/Album", "no group");
            return;
        }
        mCurrentGroupArtistName = mGroupCursor.getString(mGroupArtistIdx);
        mSelectedGroupId = mGroupCursor.getLong(mGroupArtistIdIdx);
        if (mCurrentGroupArtistName != null && !MediaStore.UNKNOWN_STRING.equals(mCurrentGroupArtistName)) {
            menu.setHeaderTitle(mCurrentGroupArtistName);
            menu.add(hashCode(), SEARCH, 0, android.R.string.search_go);
        } else {
            menu.setHeaderTitle(getString(R.string.unknown_artist));
        }
    }
}

From source file:edu.chalmers.dat255.audiobookplayer.view.BookshelfFragment.java

@SuppressWarnings("rawtypes")
@Override/*from   w w w. ja  va2s.c  om*/
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    // check that the menuInfo is of the correct type
    // this method is allowed to have quite a high cyclomatic complexity as
    // it would otherwise cause code duplication

    if (menuInfo instanceof ExpandableListContextMenuInfo && adapter != null) {
        ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;
        // get the provided book position
        int bookIndex = ExpandableListView.getPackedPositionGroup(info.packedPosition);
        // trackIndex will be -1 if group is clicked
        int trackIndex = ExpandableListView.getPackedPositionChild(info.packedPosition);
        // get the type of the context menu
        int type = ExpandableListView.getPackedPositionType(info.packedPosition);
        // create an empty array to prevent trying to loop over an
        // uninitialized variable
        IContextMenuItem[] menuItems = new IContextMenuItem[0];
        String title = "";
        // fill the context menu with the correct items
        if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
            // get all menu items from the child context menu
            menuItems = ChildContextMenuItem.values();
            // set the context menu's title to that of the value of the
            // child
            title = adapter.getChild(bookIndex, trackIndex);

        } else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
            // get all menu items from the group context menu
            menuItems = GroupContextMenuItem.values();
            // set the context menu's title to that of the value of the book
            title = adapter.getGroup(bookIndex);
        }
        // set the title
        menu.setHeaderTitle(title);
        // populate the context menu with items in the order they were
        // declared in the enum declaration.
        for (IContextMenuItem item : menuItems) {
            // as this only loops when menuItems is of either of type
            // GroupContextMenuItem[] or ChildContextMenuItem[], Enum can be
            // used as a raw type
            menu.add(Menu.NONE, ((Enum) item).ordinal(), ((Enum) item).ordinal(), item.getText());
        }
    }
}

From source file:org.tigase.mobile.bookmarks.BookmarksActivity.java

@TargetApi(11)
private void initializeContextActions() {

    listView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL);
    listView.setMultiChoiceModeListener(new MultiChoiceModeListener() {

        private Bookmark getBookmarkFromFlatPosition(int pos) {
            long packed = listView.getExpandableListPosition(pos);
            int child = ExpandableListView.getPackedPositionChild(packed);
            int group = ExpandableListView.getPackedPositionGroup(packed);

            return (Bookmark) adapter.getChild(group, child);
        }//from   w  w w .j  a va  2 s . co  m

        @Override
        public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
            SparseBooleanArray selection = listView.getCheckedItemPositions();

            if (item.getItemId() == R.id.edit) {
                for (int i = 0; i < selection.size(); i++) {
                    if (selection.valueAt(i)) {
                        int pos = selection.keyAt(i);

                        Bookmark bookmark = getBookmarkFromFlatPosition(pos);
                        editItem(bookmark);
                    }
                }
                mode.finish(); // Action picked, so close the CAB
                return true;
            } else if (item.getItemId() == R.id.remove) {
                List<Bookmark> items = new ArrayList<Bookmark>();
                for (int i = 0; i < selection.size(); i++) {
                    if (selection.valueAt(i)) {
                        int pos = selection.keyAt(i);

                        Bookmark bookmark = getBookmarkFromFlatPosition(pos);
                        if (bookmark != null) {
                            items.add(bookmark);
                        }
                    }
                }
                removeItems(items);
                mode.finish();
                return true;
            } else {
                return false;
            }

        }

        @Override
        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
            MenuInflater inflater = mode.getMenuInflater();
            inflater.inflate(R.menu.bookmarks_context_menu, menu);
            return true;
        }

        @Override
        public void onDestroyActionMode(ActionMode mode) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) {
            Menu menu = mode.getMenu();
            for (int i = 0; i < menu.size(); i++) {
                MenuItem mi = menu.getItem(i);
                if (mi.getItemId() == R.id.edit) {
                    mi.setVisible(listView.getCheckedItemCount() < 2);
                }
            }
        }

        @Override
        public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
            // TODO Auto-generated method stub
            return true;
        }

    });
}

From source file:co.nerdart.ourss.fragment.FeedsListFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.feed_list_fragment, container, false);

    mListView = (DragNDropExpandableListView) rootView.findViewById(android.R.id.list);
    mListAdapter.setExpandableListView(mListView);
    mListView.setFastScrollEnabled(true);
    mListView.setOnItemLongClickListener(new OnItemLongClickListener() {
        @Override// w  w  w  .  jav a 2s  .co  m
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            String title = ((TextView) view.findViewById(android.R.id.text1)).getText().toString();
            Matcher m = Pattern.compile("(.*) \\([0-9]+\\)$").matcher(title);
            if (m.matches()) {
                title = m.group(1);
            }

            long feedId = mListView.getItemIdAtPosition(position);
            ActionMode actionMode;
            if (view.findViewById(R.id.indicator).getVisibility() == View.VISIBLE) { // This is a group
                actionMode = getActivity().startActionMode(mGroupActionModeCallback);
            } else { // This is a feed
                actionMode = getActivity().startActionMode(mFeedActionModeCallback);
            }
            actionMode.setTag(new Pair<Long, String>(feedId, title));

            mListAdapter.setSelectedFeed(feedId);
            return true;
        }
    });

    mListView.setAdapter(mListAdapter);

    mListView.setOnChildClickListener(new OnChildClickListener() {
        @Override
        public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition,
                long id) {
            mListAdapter.startFeedActivity(id);
            return false;
        }
    });

    mListView.setDragNDropListener(new DragNDropListener() {
        boolean fromHasGroupIndicator = false;

        @Override
        public void onStopDrag(View itemView) {
        }

        @Override
        public void onStartDrag(View itemView) {
            fromHasGroupIndicator = itemView.findViewById(R.id.indicator).getVisibility() == View.VISIBLE;
        }

        @Override
        public void onDrop(final int flatPosFrom, final int flatPosTo) {
            final boolean fromIsGroup = ExpandableListView.getPackedPositionType(mListView
                    .getExpandableListPosition(flatPosFrom)) == ExpandableListView.PACKED_POSITION_TYPE_GROUP;
            final boolean toIsGroup = ExpandableListView.getPackedPositionType(mListView
                    .getExpandableListPosition(flatPosTo)) == ExpandableListView.PACKED_POSITION_TYPE_GROUP;

            final boolean fromIsFeedWithoutGroup = fromIsGroup && !fromHasGroupIndicator;

            View toView = mListView.getChildAt(flatPosTo - mListView.getFirstVisiblePosition());
            boolean toIsFeedWithoutGroup = toIsGroup
                    && toView.findViewById(R.id.indicator).getVisibility() != View.VISIBLE;

            final long packedPosTo = mListView.getExpandableListPosition(flatPosTo);
            final int packedGroupPosTo = ExpandableListView.getPackedPositionGroup(packedPosTo);

            if ((fromIsFeedWithoutGroup || !fromIsGroup) && toIsGroup && !toIsFeedWithoutGroup) {
                new AlertDialog.Builder(getActivity()) //
                        .setTitle(R.string.to_group_title) //
                        .setMessage(R.string.to_group_message) //
                        .setPositiveButton(R.string.to_group_into, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                ContentValues values = new ContentValues();
                                values.put(FeedColumns.PRIORITY, 1);
                                values.put(FeedColumns.GROUP_ID, mListView.getItemIdAtPosition(flatPosTo));

                                ContentResolver cr = getActivity().getContentResolver();
                                cr.update(FeedColumns.CONTENT_URI(mListView.getItemIdAtPosition(flatPosFrom)),
                                        values, null, null);
                                cr.notifyChange(FeedColumns.GROUPS_CONTENT_URI, null);
                            }
                        }).setNegativeButton(R.string.to_group_above, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                moveItem(fromIsGroup, toIsGroup, fromIsFeedWithoutGroup, packedPosTo,
                                        packedGroupPosTo, flatPosFrom);
                            }
                        }).show();
            } else {
                moveItem(fromIsGroup, toIsGroup, fromIsFeedWithoutGroup, packedPosTo, packedGroupPosTo,
                        flatPosFrom);
            }
        }

        @Override
        public void onDrag(int x, int y, ListView listView) {
        }
    });

    return rootView;
}

From source file:com.login.home.java

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

    int type = ExpandableListView.getPackedPositionType(info.packedPosition);
    if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition);
        int childPos = ExpandableListView.getPackedPositionChild(info.packedPosition);
        @SuppressWarnings("unchecked")
        HashMap<String, String> o = (HashMap<String, String>) mAdapter.getChild(groupPos, childPos);
        SharedPreferences settings = getSharedPreferences("pref_meetmethere", 0);
        ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
        String log = settings.getString("login", "error");
        String pass = settings.getString("password", "error");
        postParameters.add(new BasicNameValuePair("login", log));
        postParameters.add(new BasicNameValuePair("password", pass));
        postParameters.add(new BasicNameValuePair("id", o.get("id")));
        if (groupPos == 1 || groupPos == 0) {
            switch (item.getItemId()) {
            case 0:
                postParameters.add(new BasicNameValuePair("confirmed", "1"));
                break;
            case 1:
                postParameters.add(new BasicNameValuePair("confirmed", "2"));
                break;
            case 2:
                if (groupPos == 0) {
                    Intent intent = new Intent(home.this, event_info.class);
                    intent.putExtra("longitude", o.get("longitude"));
                    intent.putExtra("latitude", o.get("latitude"));
                    intent.putExtra("willAttend", o.get("willAttend"));
                    intent.putExtra("address", o.get("address"));
                    intent.putExtra("id", o.get("id"));
                    intent.putExtra("title", o.get("title"));
                    intent.putExtra("startdate", o.get("startdate"));
                    intent.putExtra("enddate", o.get("enddate"));
                    intent.putExtra("address", o.get("address"));
                    intent.putExtra("description", o.get("description"));
                    startActivity(intent);
                } else if (groupPos == 1) {
                    String friend = o.get("login");
                    Intent intent = new Intent(home.this, profile.class);
                    intent.putExtra("friend", friend);
                    intent.putExtra("yourrequest", "true");
                    intent.putExtra("id", o.get("id"));
                    intent.putExtra("confirmed", "0");
                    startActivity(intent);
                }//from   w  w  w.ja v a 2  s .  c o m
                break;
            }

            String response = null;
            try {
                if (groupPos == 1)
                    response = CustomHttpClient.executeHttpPost(
                            "http://antoines.goldzoneweb.info/accept_contact.php", postParameters);
                else
                    response = CustomHttpClient.executeHttpPost(
                            "http://antoines.goldzoneweb.info/accept_event.php", postParameters);

                String res = response.toString();
                res = res.replaceAll("\\s+", "");
                if (res.equals("OK")) {
                    Intent myIntent = new Intent(home.this, home.class);
                    startActivityForResult(myIntent, 0);
                }

            } catch (Exception e) {
                System.out.println("Error occured");
            }
        } else if (groupPos == 2) {
            switch (item.getItemId()) {
            case 0:
                Intent intent = new Intent(home.this, event_info.class);
                intent.putExtra("longitude", o.get("longitude"));
                intent.putExtra("latitude", o.get("latitude"));
                intent.putExtra("willAttend", o.get("willAttend"));
                intent.putExtra("address", o.get("address"));
                intent.putExtra("id", o.get("id"));
                intent.putExtra("title", o.get("title"));
                intent.putExtra("startdate", o.get("startdate"));
                intent.putExtra("enddate", o.get("enddate"));
                intent.putExtra("address", o.get("address"));
                intent.putExtra("description", o.get("description"));
                startActivity(intent);
                break;
            case 1:
                Intent intent2 = new Intent(home.this, mapevent.class);
                intent2.putExtra("longitude", o.get("longitude"));
                intent2.putExtra("latitude", o.get("latitude"));
                intent2.putExtra("willAttend", o.get("willAttend"));
                intent2.putExtra("address", o.get("address"));
                intent2.putExtra("id", o.get("id"));
                intent2.putExtra("title", o.get("title"));
                intent2.putExtra("startdate", o.get("startdate"));
                intent2.putExtra("enddate", o.get("enddate"));
                intent2.putExtra("address", o.get("address"));
                intent2.putExtra("description", o.get("description"));
                startActivity(intent2);
                break;
            case 2:
                postParameters.add(new BasicNameValuePair("confirmed", "2"));
                String response = null;
                try {
                    response = CustomHttpClient.executeHttpPost(
                            "http://antoines.goldzoneweb.info/accept_event.php", postParameters);

                    String res = response.toString();
                    res = res.replaceAll("\\s+", "");
                    if (res.equals("OK")) {
                        Intent myIntent = new Intent(home.this, home.class);
                        startActivityForResult(myIntent, 0);
                    }

                } catch (Exception e) {
                    System.out.println("Error occured");
                }
                break;
            }
        }
    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        return true;
    }
    return false;
}

From source file:com.money.manager.ex.common.CategoryListFragment.java

@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
    ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) item
            .getMenuInfo();//  ww w . j  a v  a  2  s . co  m

    int type = ExpandableListView.getPackedPositionType(info.packedPosition);
    int group = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    int child = ExpandableListView.getPackedPositionChild(info.packedPosition);

    CategorySub categoryIds = new CategorySub();
    categoryIds.categId = Constants.NOT_SET;
    categoryIds.categName = "";
    categoryIds.subCategId = Constants.NOT_SET;
    categoryIds.subCategName = "";

    if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        categoryIds.categId = mCategories.get(group).getId();
        categoryIds.categName = mCategories.get(group).getName();
    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        categoryIds.categId = mSubCategories.get(mCategories.get(group)).get(child).getCategId();
        categoryIds.subCategId = mSubCategories.get(mCategories.get(group)).get(child).getSubCategId();
        categoryIds.subCategName = mSubCategories.get(mCategories.get(group)).get(child).getSubcategoryName()
                .toString();
    }
    // manage select menu
    ContextMenuIds menuId = ContextMenuIds.get(item.getItemId());
    switch (menuId) {
    case EDIT:
        if (categoryIds.subCategId == ExpandableListView.INVALID_POSITION) {
            showDialogEditCategoryName(SQLTypeTransaction.UPDATE, categoryIds.categId, categoryIds.categName);
        } else {
            showDialogEditSubCategoryName(SQLTypeTransaction.UPDATE, categoryIds.categId,
                    categoryIds.subCategId, categoryIds.subCategName);
        }
        break;

    case DELETE:
        showDialogDeleteCategorySub(categoryIds);
        break;

    case VIEW_TRANSACTIONS: // view transactions
        SearchParameters parameters = new SearchParameters();
        parameters.category = categoryIds;

        showSearchActivityFor(parameters);
    }
    return false;
}

From source file:org.jitsi.android.gui.contactlist.ContactListFragment.java

/**
 * {@inheritDoc}/*from   w  w w.  j a va2  s. c  om*/
 */
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);

    if (contactListView.getExpandableListAdapter() != getContactListAdapter()) {
        return;
    }

    ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;

    int type = ExpandableListView.getPackedPositionType(info.packedPosition);

    int group = ExpandableListView.getPackedPositionGroup(info.packedPosition);

    int child = ExpandableListView.getPackedPositionChild(info.packedPosition);

    // Only create a context menu for child items
    MenuInflater inflater = getActivity().getMenuInflater();
    if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        createGroupCtxMenu(menu, inflater, group);
    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        createContactCtxMenu(menu, inflater, group, child);
    }
}

From source file:org.videolan.vlc2.gui.audio.AudioAlbumsSongsFragment.java

private boolean handleContextItemSelected(MenuItem item, int position) {
    ContextMenuInfo menuInfo = item.getMenuInfo();

    int startPosition;
    int groupPosition;
    List<String> medias;
    int id = item.getItemId();

    boolean useAllItems = id == R.id.audio_list_browser_play_all;
    boolean append = id == R.id.audio_list_browser_append;

    if (ExpandableListContextMenuInfo.class.isInstance(menuInfo)) {
        ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;
        groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    } else/*from  ww  w  . j av  a  2s. c  om*/
        groupPosition = position;

    if (id == R.id.audio_list_browser_delete) {
        AlertDialog alertDialog = CommonDialogs.deleteMedia(getActivity(),
                mSongsAdapter.getLocations(groupPosition).get(0),
                new VLCRunnable(mSongsAdapter.getItem(groupPosition)) {
                    @Override
                    public void run(Object o) {
                        AudioBrowserListAdapter.ListItem listItem = (AudioBrowserListAdapter.ListItem) o;
                        Media media = listItem.mMediaList.get(0);
                        mMediaLibrary.getMediaItems().remove(media);
                        mSongsAdapter.removeMedia(media);
                        mAlbumsAdapter.removeMedia(media);
                        mAudioController.removeLocation(media.getLocation());
                    }
                });
        alertDialog.show();
        return true;
    }

    if (id == R.id.audio_list_browser_set_song) {
        AudioUtil.setRingtone(mSongsAdapter.getItem(groupPosition).mMediaList.get(0), getActivity());
        return true;
    }

    if (useAllItems) {
        medias = new ArrayList<String>();
        startPosition = mSongsAdapter.getListWithPosition(medias, groupPosition);
    } else {
        startPosition = 0;
        switch (mTabHost.getCurrentTab()) {
        case 0: // albums
            medias = mAlbumsAdapter.getLocations(groupPosition);
            break;
        case 1: // songs
            medias = mSongsAdapter.getLocations(groupPosition);
            break;
        default:
            return true;
        }
    }

    if (append)
        mAudioController.append(medias);
    else
        mAudioController.load(medias, startPosition);

    return super.onContextItemSelected(item);
}

From source file:edu.chalmers.dat255.audiobookplayer.view.BookshelfFragment.java

@Override
public boolean onContextItemSelected(MenuItem item) {
    if (getActivity() == null) {
        return false;
    }/*from  w  w w .java 2 s .  c om*/

    // this method is allowed to have quite a high cyclomatic complexity as
    // it would otherwise cause code duplication
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
    // get the provided book position
    int bookIndex = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    // will be -1 if the type is group
    int trackIndex = ExpandableListView.getPackedPositionChild(info.packedPosition);
    // get the type of the context menu
    int type = ExpandableListView.getPackedPositionType(info.packedPosition);

    // create an empty array to prevent trying to loop over an uninitialized
    // variable
    IContextMenuItem[] menuItems = new IContextMenuItem[0];
    // fill the array with the correct items
    if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        menuItems = ChildContextMenuItem.values();
    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        menuItems = GroupContextMenuItem.values();
    }

    // get an item and store it with its dynamic type
    IContextMenuItem menuItem = menuItems[item.getItemId()];

    // if the type of the context menu is group
    if (menuItem instanceof GroupContextMenuItem) {

        // perform the correct task
        executeGroupMenuItem((GroupContextMenuItem) menuItem, bookIndex);

    }
    // if the type of the context menu is that of a child
    else if (menuItem instanceof ChildContextMenuItem) {
        // perform the correct task
        executeChildMenuItem((ChildContextMenuItem) menuItem, bookIndex, trackIndex);
    }
    return true;
}

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

private boolean handleContextItemSelected(MenuItem item, int position) {
    ContextMenuInfo menuInfo = item.getMenuInfo();

    int startPosition;
    int groupPosition;
    List<String> medias;
    int id = item.getItemId();

    boolean useAllItems = id == R.id.audio_list_browser_play_all;
    boolean append = id == R.id.audio_list_browser_append;

    if (ExpandableListContextMenuInfo.class.isInstance(menuInfo)) {
        ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;
        groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    } else//from  w w w  . j a  va2s. c o m
        groupPosition = position;

    if (id == R.id.audio_list_browser_delete) {
        AlertDialog alertDialog = CommonDialogs.deleteMedia(getActivity(),
                mSongsAdapter.getLocations(groupPosition).get(0),
                new VLCRunnable(mSongsAdapter.getItem(groupPosition)) {
                    @Override
                    public void run(Object o) {
                        AudioBrowserListAdapter.ListItem listItem = (AudioBrowserListAdapter.ListItem) o;
                        Media media = listItem.mMediaList.get(0);
                        mMediaLibrary.getMediaItems().remove(media);
                        mAudioController.removeLocation(media.getLocation());
                        updateLists();
                    }
                });
        alertDialog.show();
        return true;
    }

    if (id == R.id.audio_list_browser_set_song) {
        AudioUtil.setRingtone(mSongsAdapter.getItem(groupPosition).mMediaList.get(0), getActivity());
        return true;
    }

    if (useAllItems) {
        medias = new ArrayList<String>();
        startPosition = mSongsAdapter.getListWithPosition(medias, groupPosition);
    } else {
        startPosition = 0;
        switch (mFlingViewGroup.getPosition()) {
        case MODE_SONG:
            medias = mSongsAdapter.getLocations(groupPosition);
            break;
        case MODE_ARTIST:
            medias = mArtistsAdapter.getLocations(groupPosition);
            break;
        case MODE_ALBUM:
            medias = mAlbumsAdapter.getLocations(groupPosition);
            break;
        case MODE_GENRE:
            medias = mGenresAdapter.getLocations(groupPosition);
            break;
        default:
            return true;
        }
    }

    if (append)
        mAudioController.append(medias);
    else
        mAudioController.load(medias, startPosition);

    return super.onContextItemSelected(item);
}