Java Examples for android.widget.ExpandableListView.ExpandableListContextMenuInfo

The following java examples will help you to understand the usage of android.widget.ExpandableListView.ExpandableListContextMenuInfo. These source code samples are taken from different open source projects.

Example 1
Project: andevcon-2014-jl-master  File: ExpandableList1.java View source code
@Override
public boolean onContextItemSelected(MenuItem item) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
    String title = ((TextView) info.targetView).getText().toString();
    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);
        Toast.makeText(this, title + ": Child " + childPos + " clicked in group " + groupPos, Toast.LENGTH_SHORT).show();
        return true;
    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition);
        Toast.makeText(this, title + ": Group " + groupPos + " clicked", Toast.LENGTH_SHORT).show();
        return true;
    }
    return false;
}
Example 2
Project: android-apidemos-master  File: ExpandableList1.java View source code
@Override
public boolean onContextItemSelected(MenuItem item) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
    String title = ((TextView) info.targetView).getText().toString();
    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);
        Toast.makeText(this, title + ": Child " + childPos + " clicked in group " + groupPos, Toast.LENGTH_SHORT).show();
        return true;
    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition);
        Toast.makeText(this, title + ": Group " + groupPos + " clicked", Toast.LENGTH_SHORT).show();
        return true;
    }
    return false;
}
Example 3
Project: android-maven-plugin-master  File: ExpandableList1.java View source code
@Override
public boolean onContextItemSelected(MenuItem item) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
    String title = ((TextView) info.targetView).getText().toString();
    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);
        Toast.makeText(this, title + ": Child " + childPos + " clicked in group " + groupPos, Toast.LENGTH_SHORT).show();
        return true;
    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition);
        Toast.makeText(this, title + ": Group " + groupPos + " clicked", Toast.LENGTH_SHORT).show();
        return true;
    }
    return false;
}
Example 4
Project: android-privacy-guard-master  File: KeyListActivity.java View source code
@Override
public boolean onContextItemSelected(MenuItem menuItem) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuItem.getMenuInfo();
    int type = ExpandableListView.getPackedPositionType(info.packedPosition);
    int groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    if (type != ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        return super.onContextItemSelected(menuItem);
    }
    switch(menuItem.getItemId()) {
        case Id.menu.export:
            {
                mSelectedItem = groupPosition;
                showDialog(Id.dialog.export_key);
                return true;
            }
        case Id.menu.delete:
            {
                mSelectedItem = groupPosition;
                showDialog(Id.dialog.delete_key);
                return true;
            }
        default:
            {
                return super.onContextItemSelected(menuItem);
            }
    }
}
Example 5
Project: Android-SDK-Samples-master  File: ExpandableList1.java View source code
@Override
public boolean onContextItemSelected(MenuItem item) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
    String title = ((TextView) info.targetView).getText().toString();
    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);
        Toast.makeText(this, title + ": Child " + childPos + " clicked in group " + groupPos, Toast.LENGTH_SHORT).show();
        return true;
    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition);
        Toast.makeText(this, title + ": Group " + groupPos + " clicked", Toast.LENGTH_SHORT).show();
        return true;
    }
    return false;
}
Example 6
Project: apidemo-master  File: ExpandableList1.java View source code
@Override
public boolean onContextItemSelected(MenuItem item) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
    String title = ((TextView) info.targetView).getText().toString();
    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);
        Toast.makeText(this, title + ": Child " + childPos + " clicked in group " + groupPos, Toast.LENGTH_SHORT).show();
        return true;
    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition);
        Toast.makeText(this, title + ": Group " + groupPos + " clicked", Toast.LENGTH_SHORT).show();
        return true;
    }
    return false;
}
Example 7
Project: ApiDemos-master  File: ExpandableList1.java View source code
@Override
public boolean onContextItemSelected(MenuItem item) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
    String title = ((TextView) info.targetView).getText().toString();
    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);
        Toast.makeText(this, title + ": Child " + childPos + " clicked in group " + groupPos, Toast.LENGTH_SHORT).show();
        return true;
    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition);
        Toast.makeText(this, title + ": Group " + groupPos + " clicked", Toast.LENGTH_SHORT).show();
        return true;
    }
    return false;
}
Example 8
Project: ApkLauncher-master  File: ExpandableList1.java View source code
@Override
public boolean onContextItemSelected(MenuItem item) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
    String title = ((TextView) info.targetView).getText().toString();
    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);
        Toast.makeText(this, title + ": Child " + childPos + " clicked in group " + groupPos, Toast.LENGTH_SHORT).show();
        return true;
    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition);
        Toast.makeText(this, title + ": Group " + groupPos + " clicked", Toast.LENGTH_SHORT).show();
        return true;
    }
    return false;
}
Example 9
Project: ApkLauncher_legacy-master  File: ExpandableList1.java View source code
@Override
public boolean onContextItemSelected(MenuItem item) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
    String title = ((TextView) info.targetView).getText().toString();
    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);
        Toast.makeText(this, title + ": Child " + childPos + " clicked in group " + groupPos, Toast.LENGTH_SHORT).show();
        return true;
    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition);
        Toast.makeText(this, title + ": Group " + groupPos + " clicked", Toast.LENGTH_SHORT).show();
        return true;
    }
    return false;
}
Example 10
Project: development_apps_spareparts-master  File: ExpandableList1.java View source code
@Override
public boolean onContextItemSelected(MenuItem item) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
    String title = ((TextView) info.targetView).getText().toString();
    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);
        Toast.makeText(this, title + ": Child " + childPos + " clicked in group " + groupPos, Toast.LENGTH_SHORT).show();
        return true;
    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition);
        Toast.makeText(this, title + ": Group " + groupPos + " clicked", Toast.LENGTH_SHORT).show();
        return true;
    }
    return false;
}
Example 11
Project: felix-on-android-master  File: ExpandableList1.java View source code
@Override
public boolean onContextItemSelected(MenuItem item) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
    String title = ((TextView) info.targetView).getText().toString();
    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);
        Toast.makeText(this, title + ": Child " + childPos + " clicked in group " + groupPos, Toast.LENGTH_SHORT).show();
        return true;
    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition);
        Toast.makeText(this, title + ": Group " + groupPos + " clicked", Toast.LENGTH_SHORT).show();
        return true;
    }
    return false;
}
Example 12
Project: GradleCodeLab-master  File: ExpandableList1.java View source code
@Override
public boolean onContextItemSelected(MenuItem item) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
    String title = ((TextView) info.targetView).getText().toString();
    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);
        Toast.makeText(this, title + ": Child " + childPos + " clicked in group " + groupPos, Toast.LENGTH_SHORT).show();
        return true;
    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition);
        Toast.makeText(this, title + ": Group " + groupPos + " clicked", Toast.LENGTH_SHORT).show();
        return true;
    }
    return false;
}
Example 13
Project: mobile-spec-master  File: ExpandableList1.java View source code
@Override
public boolean onContextItemSelected(MenuItem item) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
    String title = ((TextView) info.targetView).getText().toString();
    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);
        Toast.makeText(this, title + ": Child " + childPos + " clicked in group " + groupPos, Toast.LENGTH_SHORT).show();
        return true;
    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition);
        Toast.makeText(this, title + ": Group " + groupPos + " clicked", Toast.LENGTH_SHORT).show();
        return true;
    }
    return false;
}
Example 14
Project: platform_development-master  File: ExpandableList1.java View source code
@Override
public boolean onContextItemSelected(MenuItem item) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
    String title = ((TextView) info.targetView).getText().toString();
    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);
        Toast.makeText(this, title + ": Child " + childPos + " clicked in group " + groupPos, Toast.LENGTH_SHORT).show();
        return true;
    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition);
        Toast.makeText(this, title + ": Group " + groupPos + " clicked", Toast.LENGTH_SHORT).show();
        return true;
    }
    return false;
}
Example 15
Project: QRCode-APG-master  File: KeyListActivity.java View source code
@Override
public boolean onContextItemSelected(MenuItem menuItem) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuItem.getMenuInfo();
    int type = ExpandableListView.getPackedPositionType(info.packedPosition);
    int groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    if (type != ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        return super.onContextItemSelected(menuItem);
    }
    switch(menuItem.getItemId()) {
        case Id.menu.export:
            {
                mSelectedItem = groupPosition;
                showDialog(Id.dialog.export_key);
                return true;
            }
        case Id.menu.delete:
            {
                mSelectedItem = groupPosition;
                showDialog(Id.dialog.delete_key);
                return true;
            }
        default:
            {
                return super.onContextItemSelected(menuItem);
            }
    }
}
Example 16
Project: Shuttle-Tracker-master  File: EtaActivity.java View source code
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;
    int type = ExpandableListView.getPackedPositionType(info.packedPosition);
    int group = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    //Only create a context menu for child items
    if (type == 1) {
        if (group == 0 && etaAdapter.favoritesVisible())
            menu.add(0, MENU_REMOVE_FAV, 0, getString(R.string.remove_favorite));
        else
            menu.add(0, MENU_ADD_FAV, 0, getString(R.string.add_favorite));
    }
}
Example 17
Project: WS171-development-master  File: ExpandableList1.java View source code
@Override
public boolean onContextItemSelected(MenuItem item) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
    String title = ((TextView) info.targetView).getText().toString();
    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);
        Toast.makeText(this, title + ": Child " + childPos + " clicked in group " + groupPos, Toast.LENGTH_SHORT).show();
        return true;
    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition);
        Toast.makeText(this, title + ": Group " + groupPos + " clicked", Toast.LENGTH_SHORT).show();
        return true;
    }
    return false;
}
Example 18
Project: document-viewer-master  File: RecentActivity.java View source code
protected Object getContextMenuSource(final View v, final ContextMenuInfo menuInfo) {
    Object source = null;
    if (menuInfo instanceof AdapterContextMenuInfo) {
        final AbsListView list = (AbsListView) v;
        final AdapterContextMenuInfo mi = (AdapterContextMenuInfo) menuInfo;
        source = list.getAdapter().getItem(mi.position);
    } else if (menuInfo instanceof ExpandableListContextMenuInfo) {
        final ExpandableListView list = (ExpandableListView) v;
        final ExpandableListAdapter adapter = list.getExpandableListAdapter();
        final ExpandableListContextMenuInfo mi = (ExpandableListContextMenuInfo) menuInfo;
        final long pp = mi.packedPosition;
        final int group = ExpandableListView.getPackedPositionGroup(pp);
        final int child = ExpandableListView.getPackedPositionChild(pp);
        if (child >= 0) {
            source = adapter.getChild(group, child);
        } else {
            source = adapter.getGroup(group);
        }
    }
    return source;
}
Example 19
Project: gaeproxy-master  File: HistoryListActivity.java View source code
@Override
public boolean onContextItemSelected(MenuItem menuItem) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuItem.getMenuInfo();
    int type = ExpandableListView.getPackedPositionType(info.packedPosition);
    if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        int group = ExpandableListView.getPackedPositionGroup(info.packedPosition);
        int child = ExpandableListView.getPackedPositionChild(info.packedPosition);
        HistoryItem item = (HistoryItem) getExpandableListAdapter().getChild(group, child);
        switch(menuItem.getItemId()) {
            case MENU_OPEN_IN_TAB:
                doNavigateToUrl(item.getUrl(), true);
                break;
            case MENU_COPY_URL:
                ApplicationUtils.copyTextToClipboard(this, item.getUrl(), getString(R.string.Commons_UrlCopyToastMessage));
                break;
            case MENU_SHARE:
                ApplicationUtils.sharePage(this, item.getTitle(), item.getUrl());
                break;
            case MENU_DELETE_FROM_HISTORY:
                BookmarksProviderWrapper.deleteHistoryRecord(getContentResolver(), item.getId());
                fillData();
                break;
            default:
                break;
        }
    }
    return super.onContextItemSelected(menuItem);
}
Example 20
Project: ShadowsocksProxy-master  File: HistoryListActivity.java View source code
@Override
public boolean onContextItemSelected(MenuItem menuItem) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuItem.getMenuInfo();
    int type = ExpandableListView.getPackedPositionType(info.packedPosition);
    if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        int group = ExpandableListView.getPackedPositionGroup(info.packedPosition);
        int child = ExpandableListView.getPackedPositionChild(info.packedPosition);
        HistoryItem item = (HistoryItem) getExpandableListAdapter().getChild(group, child);
        switch(menuItem.getItemId()) {
            case MENU_OPEN_IN_TAB:
                doNavigateToUrl(item.getUrl(), true);
                break;
            case MENU_COPY_URL:
                ApplicationUtils.copyTextToClipboard(this, item.getUrl(), getString(R.string.Commons_UrlCopyToastMessage));
                break;
            case MENU_SHARE:
                ApplicationUtils.sharePage(this, item.getTitle(), item.getUrl());
                break;
            case MENU_DELETE_FROM_HISTORY:
                BookmarksProviderWrapper.deleteHistoryRecord(getContentResolver(), item.getId());
                fillData();
                break;
            default:
                break;
        }
    }
    return super.onContextItemSelected(menuItem);
}
Example 21
Project: zircobrowser_android-master  File: HistoryListActivity.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;
    int type = ExpandableListView.getPackedPositionType(info.packedPosition);
    int group = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    int child = ExpandableListView.getPackedPositionChild(info.packedPosition);
    if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        HistoryItem item = (HistoryItem) getExpandableListAdapter().getChild(group, child);
        menu.setHeaderTitle(item.getTitle());
        menu.add(0, MENU_OPEN_IN_TAB, 0, R.string.HistoryListActivity_MenuOpenInTab);
        menu.add(0, MENU_COPY_URL, 0, R.string.BookmarksHistoryActivity_MenuCopyLinkUrl);
        menu.add(0, MENU_SHARE, 0, R.string.Main_MenuShareLinkUrl);
        menu.add(0, MENU_DELETE_FROM_HISTORY, 0, R.string.HistoryListActivity_MenuDelete);
    }
}
Example 22
Project: pyload-android-master  File: AbstractPackageFragment.java View source code
@Override
public boolean onContextItemSelected(MenuItem item) {
    Log.d("pyLoad", dest + " onContextItemSelected " + item);
    // filter event und allow to proceed
    if (!app.isCurrentTab(pos))
        return false;
    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);
        final FileData file;
        try {
            file = data.get(groupPos).links.get(childPos);
        } catch (IndexOutOfBoundsException e) {
            return false;
        }
        switch(item.getItemId()) {
            case R.id.restart:
                app.addTask(new GuiTask(new Runnable() {

                    public void run() {
                        client = app.getClient();
                        client.restartFile(file.fid);
                    }
                }, app.handleSuccess));
                break;
            case R.id.delete:
                app.addTask(new GuiTask(new Runnable() {

                    public void run() {
                        client = app.getClient();
                        ArrayList<Integer> fids = new ArrayList<Integer>();
                        fids.add(file.fid);
                        client.deleteFiles(fids);
                    }
                }, app.handleSuccess));
                break;
            case R.id.move:
                Toast.makeText(getActivity(), R.string.cant_move_files, Toast.LENGTH_SHORT).show();
                break;
            default:
                break;
        }
        return true;
    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition);
        final PackageData pack;
        try {
            pack = data.get(groupPos);
        } catch (IndexOutOfBoundsException e) {
            return false;
        }
        switch(item.getItemId()) {
            case R.id.restart:
                app.addTask(new GuiTask(new Runnable() {

                    public void run() {
                        client = app.getClient();
                        client.restartPackage(pack.pid);
                    }
                }, app.handleSuccess));
                break;
            case R.id.delete:
                app.addTask(new GuiTask(new Runnable() {

                    public void run() {
                        client = app.getClient();
                        ArrayList<Integer> pids = new ArrayList<Integer>();
                        pids.add(pack.pid);
                        client.deletePackages(pids);
                    }
                }, app.handleSuccess));
                break;
            case R.id.move:
                app.addTask(new GuiTask(new Runnable() {

                    public void run() {
                        client = app.getClient();
                        Destination newDest;
                        if (dest == 0) {
                            newDest = Destination.Collector;
                        } else {
                            newDest = Destination.Queue;
                        }
                        client.movePackage(newDest, pack.pid);
                    }
                }, app.handleSuccess));
                break;
            default:
                break;
        }
        return true;
    }
    return false;
}
Example 23
Project: rchip_android-master  File: VideoList.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;
    if (ExpandableListView.getPackedPositionType(info.packedPosition) == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        menu.setHeaderTitle(showGroupNames.get(ExpandableListView.getPackedPositionGroup(info.packedPosition)));
        menu.add(0, v.getId(), 4, getString(R.string.watch_next));
        menu.add(0, v.getId(), 3, getString(R.string.remove_show));
    } else {
        ShowList show = showlist.get((int) ((MyExpandableListAdapter) mAdapter).getlongID(ExpandableListView.getPackedPositionGroup(info.packedPosition), ExpandableListView.getPackedPositionChild(info.packedPosition)));
        menu.setHeaderTitle(show.ShowName + " - " + show.ShowEpisodeName);
        menu.add(0, v.getId(), 0, getString(R.string.watch));
        menu.add(0, v.getId(), 1, getString(R.string.delete));
        menu.add(0, v.getId(), 3, getString(R.string.remove_show));
        menu.add(0, v.getId(), 2, getString(R.string.delete_all));
    }
}
Example 24
Project: Tribler-streaming-master  File: AudioBrowserFragment.java View source code
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
        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) {
                Media aMedia = (Media) o;
                mMediaLibrary.getMediaItems().remove(aMedia);
                updateLists();
            }
        });
        alertDialog.show();
        return true;
    }
    if (id == R.id.audio_list_browser_set_song) {
        //AudioUtil.setRingtone(mSongsAdapter.getItem(groupPosition),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 = mArtistsAdapter.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);
}
Example 25
Project: akvo-flow-mobile-master  File: DrawerFragment.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;
    int type = ExpandableListView.getPackedPositionType(info.packedPosition);
    int group = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    int child = ExpandableListView.getPackedPositionChild(info.packedPosition);
    switch(group) {
        case GROUP_SURVEYS:
            SurveyGroup sg = getSurveyForContextMenu(type, group, child);
            if (sg != null) {
                menu.setHeaderTitle(sg.getName());
                menu.add(0, ID_DELETE_SURVEY, ID_DELETE_SURVEY, R.string.delete);
            }
            break;
        case GROUP_USERS:
            User user = getUserForContextMenu(type, group, child);
            if (user != null) {
                menu.setHeaderTitle(user.getName());
                menu.add(0, ID_EDIT_USER, ID_EDIT_USER, R.string.edit_user);
                menu.add(0, ID_DELETE_USER, ID_DELETE_USER, R.string.delete_user);
            }
            break;
    }
}
Example 26
Project: apps2org-master  File: LabelListActivity.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;
    int type = ExpandableListView.getPackedPositionType(info.packedPosition);
    int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        int childPos = ExpandableListView.getPackedPositionChild(info.packedPosition);
        Cursor c = getExpandableListAdapter().getChild(groupPos, childPos);
        ApplicationContextMenuManager.createMenu(this, menu, c.getString(1), -1);
    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        Cursor c = getExpandableListAdapter().getGroup(groupPos);
        menu.setHeaderTitle(c.getString(1));
        if (!c.isNull(3)) {
            byte[] imageBytes = c.getBlob(3);
            Bitmap bitmap = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length);
            menu.setHeaderIcon(new BitmapDrawable(bitmap));
        } else {
            int icon = c.getInt(2);
            if (icon != 0) {
                menu.setHeaderIcon(Label.convertToIcon(icon));
            } else {
                menu.setHeaderIcon(R.drawable.icon_default);
            }
        }
        MenuItem renameItem = menu.add(0, MENU_ITEM_RENAME, 0, R.string.rename);
        MenuItem deleteItem = menu.add(0, MENU_ITEM_DELETE, 1, R.string.delete);
        MenuItem changeIconItem = menu.add(0, MENU_ITEM_CHANGE_ICON, 2, R.string.change_icon);
        MenuItem chooseAppsItem = menu.add(0, MENU_ITEM_SELECT_APPS, 3, R.string.select_apps);
        menu.add(0, MENU_ITEM_ADD_TO_HOME, 4, R.string.add_to_home);
        if (c.getLong(0) == AppCacheDao.OTHER_LABEL_ID) {
            deleteItem.setEnabled(false);
            renameItem.setEnabled(false);
            changeIconItem.setEnabled(false);
            chooseAppsItem.setEnabled(false);
        }
    }
}
Example 27
Project: FinanceApp-master  File: CategoriesActivity.java View source code
//end of subcategoryPopulate
//Adding a new category
private void categoryAdd(android.view.MenuItem item) {
    //SubCategory Add
    if (item != null) {
        ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
        int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition);
        int childPos = ExpandableListView.getPackedPositionChild(info.packedPosition);
        DialogFragment newFragment = CategoryAddFragment.newInstance(groupPos, childPos);
        newFragment.show(getSupportFragmentManager(), "dialogAdd");
    } else //CategoryAdd
    {
        DialogFragment newFragment = CategoryAddFragment.newInstance();
        newFragment.show(getSupportFragmentManager(), "dialogAdd");
    }
}
Example 28
Project: moneybalance-master  File: ExpenseListActivity.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    if (v.getId() == R.id.expense_list) {
        ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;
        int group = ExpandableListView.getPackedPositionGroup(info.packedPosition);
        int child = ExpandableListView.getPackedPositionChild(info.packedPosition);
        if (child != -1) {
            Expense expense = (Expense) adapter.getChild(group, child);
            menu.setHeaderTitle(expense.getTitle());
            menu.add(0, ITEM_DELETE, 0, R.string.menu_delete);
        }
    }
}
Example 29
Project: OtRChat-master  File: ContactListActivity.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    boolean chatSelected = false;
    boolean contactSelected = false;
    Cursor contactCursor;
    if (mIsFiltering) {
        AdapterView.AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
        mContextMenuHandler.mPosition = info.position;
        contactSelected = true;
        contactCursor = mFilterView.getContactAtPosition(info.position);
    } else {
        ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;
        mContextMenuHandler.mPosition = info.packedPosition;
        contactSelected = mContactListView.isContactAtPosition(info.packedPosition);
        chatSelected = mContactListView.isConversationAtPosition(info.packedPosition);
        contactCursor = mContactListView.getContactAtPosition(info.packedPosition);
    }
    boolean allowBlock = true;
    if (contactCursor != null) {
        //XXX HACK: Yahoo! doesn't allow to block a friend. We can only block a temporary contact.
        ProviderDef provider = mApp.getProvider(mProviderId);
        if (Imps.ProviderNames.YAHOO.equals(provider.mName)) {
            int type = contactCursor.getInt(contactCursor.getColumnIndexOrThrow(Imps.Contacts.TYPE));
            allowBlock = (type == Imps.Contacts.TYPE_TEMPORARY);
        }
        int nickNameIndex = contactCursor.getColumnIndexOrThrow(Imps.Contacts.NICKNAME);
        menu.setHeaderTitle(contactCursor.getString(nickNameIndex));
    }
    BrandingResources brandingRes = mApp.getBrandingResource(mProviderId);
    String menu_end_conversation = brandingRes.getString(BrandingResourceIDs.STRING_MENU_END_CHAT);
    String menu_view_profile = brandingRes.getString(BrandingResourceIDs.STRING_MENU_VIEW_PROFILE);
    String menu_block_contact = brandingRes.getString(BrandingResourceIDs.STRING_MENU_BLOCK_CONTACT);
    String menu_start_conversation = brandingRes.getString(BrandingResourceIDs.STRING_MENU_START_CHAT);
    String menu_delete_contact = brandingRes.getString(BrandingResourceIDs.STRING_MENU_DELETE_CONTACT);
    if (chatSelected) {
        menu.add(0, MENU_END_CONVERSATION, 0, menu_end_conversation).setOnMenuItemClickListener(//TODO .setIcon(info.guardianproject.otr.app.internal.R.drawable.ic_menu_end_conversation)
        mContextMenuHandler);
        menu.add(0, MENU_VIEW_PROFILE, 0, menu_view_profile).setIcon(R.drawable.ic_menu_my_profile).setOnMenuItemClickListener(mContextMenuHandler);
        if (allowBlock) {
            menu.add(0, MENU_BLOCK_CONTACT, 0, menu_block_contact).setOnMenuItemClickListener(//.setIcon(info.guardianproject.otr.app.internal.R.drawable.ic_menu_block)
            mContextMenuHandler);
        }
    } else if (contactSelected) {
        menu.add(0, MENU_START_CONVERSATION, 0, menu_start_conversation).setOnMenuItemClickListener(//.setIcon(info.guardianproject.otr.app.internal.R.drawable.ic_menu_start_conversation)
        mContextMenuHandler);
        menu.add(0, MENU_VIEW_PROFILE, 0, menu_view_profile).setIcon(R.drawable.ic_menu_view_profile).setOnMenuItemClickListener(mContextMenuHandler);
        if (allowBlock) {
            menu.add(0, MENU_BLOCK_CONTACT, 0, menu_block_contact).setOnMenuItemClickListener(//.setIcon(info.guardianproject.otr.app.internal.R.drawable.ic_menu_block)
            mContextMenuHandler);
        }
        menu.add(0, MENU_DELETE_CONTACT, 0, menu_delete_contact).setIcon(android.R.drawable.ic_menu_delete).setOnMenuItemClickListener(mContextMenuHandler);
    }
}
Example 30
Project: platform_packages_apps_im-master  File: ContactListActivity.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    boolean chatSelected = false;
    boolean contactSelected = false;
    Cursor contactCursor;
    if (mIsFiltering) {
        AdapterView.AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
        mContextMenuHandler.mPosition = info.position;
        contactSelected = true;
        contactCursor = mFilterView.getContactAtPosition(info.position);
    } else {
        ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;
        mContextMenuHandler.mPosition = info.packedPosition;
        contactSelected = mContactListView.isContactAtPosition(info.packedPosition);
        chatSelected = mContactListView.isConversationAtPosition(info.packedPosition);
        contactCursor = mContactListView.getContactAtPosition(info.packedPosition);
    }
    boolean allowBlock = true;
    if (contactCursor != null) {
        //XXX HACK: Yahoo! doesn't allow to block a friend. We can only block a temporary contact.
        ProviderDef provider = mApp.getProvider(mProviderId);
        if (Imps.ProviderNames.YAHOO.equals(provider.mName)) {
            int type = contactCursor.getInt(contactCursor.getColumnIndexOrThrow(Imps.Contacts.TYPE));
            allowBlock = (type == Imps.Contacts.TYPE_TEMPORARY);
        }
        int nickNameIndex = contactCursor.getColumnIndexOrThrow(Imps.Contacts.NICKNAME);
        menu.setHeaderTitle(contactCursor.getString(nickNameIndex));
    }
    BrandingResources brandingRes = mApp.getBrandingResource(mProviderId);
    String menu_end_conversation = brandingRes.getString(BrandingResourceIDs.STRING_MENU_END_CHAT);
    String menu_view_profile = brandingRes.getString(BrandingResourceIDs.STRING_MENU_VIEW_PROFILE);
    String menu_block_contact = brandingRes.getString(BrandingResourceIDs.STRING_MENU_BLOCK_CONTACT);
    String menu_start_conversation = brandingRes.getString(BrandingResourceIDs.STRING_MENU_START_CHAT);
    String menu_delete_contact = brandingRes.getString(BrandingResourceIDs.STRING_MENU_DELETE_CONTACT);
    if (chatSelected) {
        menu.add(0, MENU_END_CONVERSATION, 0, menu_end_conversation).setIcon(com.android.internal.R.drawable.ic_menu_end_conversation).setOnMenuItemClickListener(mContextMenuHandler);
        menu.add(0, MENU_VIEW_PROFILE, 0, menu_view_profile).setIcon(R.drawable.ic_menu_my_profile).setOnMenuItemClickListener(mContextMenuHandler);
        if (allowBlock) {
            menu.add(0, MENU_BLOCK_CONTACT, 0, menu_block_contact).setIcon(com.android.internal.R.drawable.ic_menu_block).setOnMenuItemClickListener(mContextMenuHandler);
        }
    } else if (contactSelected) {
        menu.add(0, MENU_START_CONVERSATION, 0, menu_start_conversation).setIcon(com.android.internal.R.drawable.ic_menu_start_conversation).setOnMenuItemClickListener(mContextMenuHandler);
        menu.add(0, MENU_VIEW_PROFILE, 0, menu_view_profile).setIcon(R.drawable.ic_menu_view_profile).setOnMenuItemClickListener(mContextMenuHandler);
        if (allowBlock) {
            menu.add(0, MENU_BLOCK_CONTACT, 0, menu_block_contact).setIcon(com.android.internal.R.drawable.ic_menu_block).setOnMenuItemClickListener(mContextMenuHandler);
        }
        menu.add(0, MENU_DELETE_CONTACT, 0, menu_delete_contact).setIcon(android.R.drawable.ic_menu_delete).setOnMenuItemClickListener(mContextMenuHandler);
    }
}
Example 31
Project: SealBrowser-master  File: HistoryFragment.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    BookmarkHistoryItem selectedItem = null;
    if (mTwoPaneMode) {
        AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
        int group = mChildAdapter.getSelectedGroup();
        int child = info.position;
        selectedItem = (BookmarkHistoryItem) mAdapter.getChild(group, child);
    } else {
        ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;
        int type = ExpandableListView.getPackedPositionType(info.packedPosition);
        if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
            int group = ExpandableListView.getPackedPositionGroup(info.packedPosition);
            int child = ExpandableListView.getPackedPositionChild(info.packedPosition);
            selectedItem = (BookmarkHistoryItem) mAdapter.getChild(group, child);
        }
    }
    if (selectedItem != null) {
        BitmapDrawable icon = ApplicationUtils.getApplicationButtonImage(getActivity(), selectedItem.getFavicon());
        if (icon != null) {
            menu.setHeaderIcon(icon);
        }
        menu.setHeaderTitle(selectedItem.getTitle());
        menu.add(0, CONTEXT_MENU_OPEN_IN_TAB, 0, R.string.OpenInTab);
        menu.add(0, CONTEXT_MENU_COPY_URL, 0, R.string.CopyUrl);
        menu.add(0, CONTEXT_MENU_SHARE_URL, 0, R.string.ContextMenuShareUrl);
        menu.add(0, CONTEXT_MENU_DELETE_HISTORY_ITEM, 0, R.string.DeleteHistoryItem);
        List<AddonMenuItem> addonsContributions = Controller.getInstance().getAddonManager().getContributedHistoryContextMenuItems(mUIManager.getCurrentWebView());
        for (AddonMenuItem item : addonsContributions) {
            menu.add(0, item.getAddon().getMenuId(), 0, item.getMenuItem());
        }
    }
}
Example 32
Project: TintBrowser-master  File: HistoryFragment.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    BookmarkHistoryItem selectedItem = null;
    if (mTwoPaneMode) {
        AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
        int group = mChildAdapter.getSelectedGroup();
        int child = info.position;
        selectedItem = (BookmarkHistoryItem) mAdapter.getChild(group, child);
    } else {
        ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;
        int type = ExpandableListView.getPackedPositionType(info.packedPosition);
        if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
            int group = ExpandableListView.getPackedPositionGroup(info.packedPosition);
            int child = ExpandableListView.getPackedPositionChild(info.packedPosition);
            selectedItem = (BookmarkHistoryItem) mAdapter.getChild(group, child);
        }
    }
    if (selectedItem != null) {
        BitmapDrawable icon = ApplicationUtils.getApplicationButtonImage(getActivity(), selectedItem.getFavicon());
        if (icon != null) {
            menu.setHeaderIcon(icon);
        }
        menu.setHeaderTitle(selectedItem.getTitle());
        menu.add(0, CONTEXT_MENU_OPEN_IN_TAB, 0, R.string.OpenInTab);
        menu.add(0, CONTEXT_MENU_COPY_URL, 0, R.string.CopyUrl);
        menu.add(0, CONTEXT_MENU_SHARE_URL, 0, R.string.ContextMenuShareUrl);
        menu.add(0, CONTEXT_MENU_DELETE_HISTORY_ITEM, 0, R.string.DeleteHistoryItem);
        List<AddonMenuItem> addonsContributions = Controller.getInstance().getAddonManager().getContributedHistoryContextMenuItems(mUIManager.getCurrentWebView());
        for (AddonMenuItem item : addonsContributions) {
            menu.add(0, item.getAddon().getMenuId(), 0, item.getMenuItem());
        }
    }
}
Example 33
Project: WS171-packages-apps-Browser-master  File: BrowserHistoryPage.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    ExpandableListContextMenuInfo i = (ExpandableListContextMenuInfo) menuInfo;
    // Do not allow a context menu to come up from the group views.
    if (!(i.targetView instanceof HistoryItem)) {
        return;
    }
    // Inflate the menu
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.historycontext, menu);
    // Setup the header
    menu.setHeaderTitle(((HistoryItem) i.targetView).getUrl());
    // Only show open in new tab if we have not maxed out available tabs
    menu.findItem(R.id.new_window_context_menu_id).setVisible(!mMaxTabsOpen);
    // decide whether to show the share link option
    PackageManager pm = getPackageManager();
    Intent send = new Intent(Intent.ACTION_SEND);
    send.setType("text/plain");
    ResolveInfo ri = pm.resolveActivity(send, PackageManager.MATCH_DEFAULT_ONLY);
    menu.findItem(R.id.share_link_context_menu_id).setVisible(ri != null);
    super.onCreateContextMenu(menu, v, menuInfo);
}
Example 34
Project: gcmobile-master  File: I18nList.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;
    int type = ExpandableListView.getPackedPositionType(info.packedPosition);
    if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.formbuilderi18nlist_cmenu, menu);
    }
}
Example 35
Project: prive-android-master  File: ContactListActivity.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    boolean chatSelected = false;
    boolean contactSelected = false;
    Cursor contactCursor;
    if (mIsFiltering) {
        AdapterView.AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
        mContextMenuHandler.mPosition = info.position;
        contactSelected = true;
        contactCursor = mFilterView.getContactAtPosition(info.position);
    } else {
        ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;
        mContextMenuHandler.mPosition = info.packedPosition;
        contactSelected = mContactListView.isContactAtPosition(info.packedPosition);
        contactCursor = mContactListView.getContactAtPosition(info.packedPosition);
    }
    boolean allowBlock = true;
    if (contactCursor != null) {
        //XXX HACK: Yahoo! doesn't allow to block a friend. We can only block a temporary contact.
        ProviderDef provider = mApp.getProvider(mProviderId);
        if (Imps.ProviderNames.YAHOO.equals(provider.mName)) {
            int type = contactCursor.getInt(contactCursor.getColumnIndexOrThrow(Imps.Contacts.TYPE));
            allowBlock = (type == Imps.Contacts.TYPE_TEMPORARY);
        }
        int nickNameIndex = contactCursor.getColumnIndexOrThrow(Imps.Contacts.NICKNAME);
        menu.setHeaderTitle(contactCursor.getString(nickNameIndex));
    }
    BrandingResources brandingRes = mApp.getBrandingResource(mProviderId);
    String menu_end_conversation = brandingRes.getString(BrandingResourceIDs.STRING_MENU_END_CHAT);
    String menu_view_profile = brandingRes.getString(BrandingResourceIDs.STRING_MENU_VIEW_PROFILE);
    String menu_block_contact = brandingRes.getString(BrandingResourceIDs.STRING_MENU_BLOCK_CONTACT);
    String menu_start_conversation = brandingRes.getString(BrandingResourceIDs.STRING_MENU_START_CHAT);
    String menu_delete_contact = brandingRes.getString(BrandingResourceIDs.STRING_MENU_DELETE_CONTACT);
    if (chatSelected) {
        menu.add(0, MENU_END_CONVERSATION, 0, menu_end_conversation).setOnMenuItemClickListener(mContextMenuHandler);
        menu.add(0, MENU_VIEW_PROFILE, 0, menu_view_profile).setIcon(R.drawable.ic_menu_my_profile).setOnMenuItemClickListener(mContextMenuHandler);
        if (allowBlock) {
            menu.add(0, MENU_BLOCK_CONTACT, 0, menu_block_contact).setOnMenuItemClickListener(mContextMenuHandler);
        }
    } else if (contactSelected) {
        menu.add(0, MENU_START_CONVERSATION, 0, menu_start_conversation).setOnMenuItemClickListener(mContextMenuHandler);
        menu.add(0, MENU_VIEW_PROFILE, 0, menu_view_profile).setIcon(R.drawable.ic_menu_view_profile).setOnMenuItemClickListener(mContextMenuHandler);
        if (allowBlock) {
            menu.add(0, MENU_BLOCK_CONTACT, 0, menu_block_contact).setOnMenuItemClickListener(mContextMenuHandler);
        }
        menu.add(0, MENU_DELETE_CONTACT, 0, menu_delete_contact).setIcon(android.R.drawable.ic_menu_delete).setOnMenuItemClickListener(mContextMenuHandler);
    }
//  contactCursor.close();
}
Example 36
Project: TrainOse-master  File: Timetables.java View source code
/**
     * Handler for pressing a context menu item for a timetable.
     */
@Override
public boolean onContextItemSelected(MenuItem item) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
    mTimetableId = info.id;
    Log.w("TEST", "" + mTimetableId);
    switch(item.getItemId()) {
        case COPY_ID:
            this.copyTimetableToClipboard(mTimetableId);
            return true;
        case DETAILS_ID:
            this.showDialog(DIALOG_DETAIL_ID);
            return true;
        case SEATS_ID:
            this.showDialog(DIALOG_SEATS_ID);
            return true;
    }
    return super.onContextItemSelected(item);
}
Example 37
Project: VBoxManager-master  File: StorageListFragment.java View source code
@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
    int groupNum = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    switch(ExpandableListView.getPackedPositionType(info.packedPosition)) {
        case ExpandableListView.PACKED_POSITION_TYPE_GROUP:
            IStorageController controller = (IStorageController) _listAdapter.getGroup(groupNum);
            new DeleteControllerTask().execute(controller);
            break;
        case ExpandableListView.PACKED_POSITION_TYPE_CHILD:
            int childNum = ExpandableListView.getPackedPositionChild(info.packedPosition);
            IMediumAttachment attachment = (IMediumAttachment) _listAdapter.getChild(groupNum, childNum);
            new DetachMediumTask().execute(attachment);
            break;
    }
    return false;
}
Example 38
Project: Android-Application-Using-CAF-Library-master  File: ArtistAlbumBrowserActivity.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfoIn) {
    menu.add(0, PLAY_SELECTION, 0, R.string.play_selection);
    SubMenu sub = menu.addSubMenu(0, ADD_TO_PLAYLIST, 0, R.string.add_to_playlist);
    MusicUtils.makePlaylistMenu(this, sub);
    menu.add(0, DELETE_ITEM, 0, R.string.delete_item);
    ExpandableListContextMenuInfo mi = (ExpandableListContextMenuInfo) menuInfoIn;
    int itemtype = ExpandableListView.getPackedPositionType(mi.packedPosition);
    int gpos = ExpandableListView.getPackedPositionGroup(mi.packedPosition);
    int cpos = ExpandableListView.getPackedPositionChild(mi.packedPosition);
    if (itemtype == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        if (gpos == -1) {
            // this shouldn't happen
            Log.d("Artist/Album", "no group");
            return;
        }
        gpos = gpos - getExpandableListView().getHeaderViewsCount();
        mArtistCursor.moveToPosition(gpos);
        mCurrentArtistId = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists._ID));
        mCurrentArtistName = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists.ARTIST));
        mCurrentAlbumId = null;
        mIsUnknownArtist = mCurrentArtistName == null || mCurrentArtistName.equals(MediaStore.UNKNOWN_STRING);
        mIsUnknownAlbum = true;
        if (mIsUnknownArtist) {
            menu.setHeaderTitle(getString(R.string.unknown_artist_name));
        } else {
            menu.setHeaderTitle(mCurrentArtistName);
            menu.add(0, SEARCH, 0, R.string.search_title);
        }
        return;
    } else if (itemtype == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        if (cpos == -1) {
            // this shouldn't happen
            Log.d("Artist/Album", "no child");
            return;
        }
        Cursor c = (Cursor) getExpandableListAdapter().getChild(gpos, cpos);
        c.moveToPosition(cpos);
        mCurrentArtistId = null;
        mCurrentAlbumId = Long.valueOf(mi.id).toString();
        mCurrentAlbumName = c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.Albums.ALBUM));
        gpos = gpos - getExpandableListView().getHeaderViewsCount();
        mArtistCursor.moveToPosition(gpos);
        mCurrentArtistNameForAlbum = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists.ARTIST));
        mIsUnknownArtist = mCurrentArtistNameForAlbum == null || mCurrentArtistNameForAlbum.equals(MediaStore.UNKNOWN_STRING);
        mIsUnknownAlbum = mCurrentAlbumName == null || mCurrentAlbumName.equals(MediaStore.UNKNOWN_STRING);
        if (mIsUnknownAlbum) {
            menu.setHeaderTitle(getString(R.string.unknown_album_name));
        } else {
            menu.setHeaderTitle(mCurrentAlbumName);
        }
        if (!mIsUnknownAlbum || !mIsUnknownArtist) {
            menu.add(0, SEARCH, 0, R.string.search_title);
        }
    }
}
Example 39
Project: AndroidYaxIm-master  File: MainWindow.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    ExpandableListView.ExpandableListContextMenuInfo info;
    try {
        info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;
    } catch (ClassCastException e) {
        Log.e(TAG, "bad menuinfo: ", e);
        return;
    }
    long packedPosition = info.packedPosition;
    boolean isChild = isChild(packedPosition);
    // get the entry name for the item
    String menuName;
    if (isChild) {
        getMenuInflater().inflate(R.menu.roster_item_contextmenu, menu);
        menuName = String.format("%s (%s)", getPackedItemRow(packedPosition, RosterConstants.ALIAS), getPackedItemRow(packedPosition, RosterConstants.JID));
    } else {
        menuName = getPackedItemRow(packedPosition, RosterConstants.GROUP);
        if (menuName.equals(""))
            // no options for default menu
            return;
        getMenuInflater().inflate(R.menu.roster_group_contextmenu, menu);
    }
    menu.setHeaderTitle(getString(R.string.roster_contextmenu_title, menuName));
}
Example 40
Project: android_packages_apps-master  File: ArtistAlbumBrowserActivity.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfoIn) {
    menu.add(0, PLAY_SELECTION, 0, R.string.play_selection);
    SubMenu sub = menu.addSubMenu(0, ADD_TO_PLAYLIST, 0, R.string.add_to_playlist);
    MusicUtils.makePlaylistMenu(this, sub);
    menu.add(0, DELETE_ITEM, 0, R.string.delete_item);
    ExpandableListContextMenuInfo mi = (ExpandableListContextMenuInfo) menuInfoIn;
    int itemtype = ExpandableListView.getPackedPositionType(mi.packedPosition);
    int gpos = ExpandableListView.getPackedPositionGroup(mi.packedPosition);
    int cpos = ExpandableListView.getPackedPositionChild(mi.packedPosition);
    if (itemtype == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        if (gpos == -1) {
            // this shouldn't happen
            Log.d("Artist/Album", "no group");
            return;
        }
        gpos = gpos - getExpandableListView().getHeaderViewsCount();
        mArtistCursor.moveToPosition(gpos);
        mCurrentArtistId = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists._ID));
        mCurrentArtistName = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists.ARTIST));
        mCurrentAlbumId = null;
        mIsUnknownArtist = mCurrentArtistName == null || mCurrentArtistName.equals(MediaStore.UNKNOWN_STRING);
        mIsUnknownAlbum = true;
        if (mIsUnknownArtist) {
            menu.setHeaderTitle(getString(R.string.unknown_artist_name));
        } else {
            menu.setHeaderTitle(mCurrentArtistName);
            menu.add(0, SEARCH, 0, R.string.search_title);
        }
        return;
    } else if (itemtype == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        if (cpos == -1) {
            // this shouldn't happen
            Log.d("Artist/Album", "no child");
            return;
        }
        Cursor c = (Cursor) getExpandableListAdapter().getChild(gpos, cpos);
        c.moveToPosition(cpos);
        mCurrentArtistId = null;
        mCurrentAlbumId = Long.valueOf(mi.id).toString();
        mCurrentAlbumName = c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.Albums.ALBUM));
        gpos = gpos - getExpandableListView().getHeaderViewsCount();
        mArtistCursor.moveToPosition(gpos);
        mCurrentArtistNameForAlbum = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists.ARTIST));
        mIsUnknownArtist = mCurrentArtistNameForAlbum == null || mCurrentArtistNameForAlbum.equals(MediaStore.UNKNOWN_STRING);
        mIsUnknownAlbum = mCurrentAlbumName == null || mCurrentAlbumName.equals(MediaStore.UNKNOWN_STRING);
        if (mIsUnknownAlbum) {
            menu.setHeaderTitle(getString(R.string.unknown_album_name));
        } else {
            menu.setHeaderTitle(mCurrentAlbumName);
        }
        if (!mIsUnknownAlbum || !mIsUnknownArtist) {
            menu.add(0, SEARCH, 0, R.string.search_title);
        }
    }
}
Example 41
Project: android_packages_apps_Music-master  File: ArtistAlbumBrowserActivity.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfoIn) {
    menu.add(0, PLAY_SELECTION, 0, R.string.play_selection);
    SubMenu sub = menu.addSubMenu(0, ADD_TO_PLAYLIST, 0, R.string.add_to_playlist);
    MusicUtils.makePlaylistMenu(this, sub);
    menu.add(0, DELETE_ITEM, 0, R.string.delete_item);
    menu.add(0, SEARCH, 0, R.string.search_title);
    ExpandableListContextMenuInfo mi = (ExpandableListContextMenuInfo) menuInfoIn;
    int itemtype = ExpandableListView.getPackedPositionType(mi.packedPosition);
    int gpos = ExpandableListView.getPackedPositionGroup(mi.packedPosition);
    int cpos = ExpandableListView.getPackedPositionChild(mi.packedPosition);
    if (itemtype == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        if (gpos == -1) {
            // this shouldn't happen
            Log.d("Artist/Album", "no group");
            return;
        }
        gpos = gpos - getExpandableListView().getHeaderViewsCount();
        mArtistCursor.moveToPosition(gpos);
        mCurrentArtistId = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists._ID));
        mCurrentArtistName = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists.ARTIST));
        mCurrentAlbumId = null;
        if (mCurrentArtistName == null || mCurrentArtistName.equals(MediaFile.UNKNOWN_STRING)) {
            menu.setHeaderTitle(getString(R.string.unknown_artist_name));
        } else {
            menu.setHeaderTitle(mCurrentArtistName);
        }
        return;
    } else if (itemtype == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        if (cpos == -1) {
            // this shouldn't happen
            Log.d("Artist/Album", "no child");
            return;
        }
        Cursor c = (Cursor) getExpandableListAdapter().getChild(gpos, cpos);
        c.moveToPosition(cpos);
        mCurrentArtistId = null;
        mCurrentAlbumId = Long.valueOf(mi.id).toString();
        mCurrentAlbumName = c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.Albums.ALBUM));
        gpos = gpos - getExpandableListView().getHeaderViewsCount();
        mArtistCursor.moveToPosition(gpos);
        mCurrentArtistNameForAlbum = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists.ARTIST));
        if (mCurrentAlbumName == null || mCurrentAlbumName.equals(MediaFile.UNKNOWN_STRING)) {
            menu.setHeaderTitle(getString(R.string.unknown_album_name));
        } else {
            menu.setHeaderTitle(mCurrentAlbumName);
        }
    }
}
Example 42
Project: AOSP-Music-Player-master  File: ArtistAlbumBrowserActivity.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfoIn) {
    menu.add(0, PLAY_SELECTION, 0, R.string.play_selection);
    SubMenu sub = menu.addSubMenu(0, ADD_TO_PLAYLIST, 0, R.string.add_to_playlist);
    MusicUtils.makePlaylistMenu(this, sub);
    menu.add(0, DELETE_ITEM, 0, R.string.delete_item);
    ExpandableListContextMenuInfo mi = (ExpandableListContextMenuInfo) menuInfoIn;
    int itemtype = ExpandableListView.getPackedPositionType(mi.packedPosition);
    int gpos = ExpandableListView.getPackedPositionGroup(mi.packedPosition);
    int cpos = ExpandableListView.getPackedPositionChild(mi.packedPosition);
    if (itemtype == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        if (gpos == -1) {
            // this shouldn't happen
            Log.d("Artist/Album", "no group");
            return;
        }
        gpos = gpos - getExpandableListView().getHeaderViewsCount();
        mArtistCursor.moveToPosition(gpos);
        mCurrentArtistId = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists._ID));
        mCurrentArtistName = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists.ARTIST));
        mCurrentAlbumId = null;
        mIsUnknownArtist = mCurrentArtistName == null || mCurrentArtistName.equals(MediaStore.UNKNOWN_STRING);
        mIsUnknownAlbum = true;
        if (mIsUnknownArtist) {
            menu.setHeaderTitle(getString(R.string.unknown_artist_name));
        } else {
            menu.setHeaderTitle(mCurrentArtistName);
            menu.add(0, SEARCH, 0, R.string.search_title);
        }
        return;
    } else if (itemtype == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        if (cpos == -1) {
            // this shouldn't happen
            Log.d("Artist/Album", "no child");
            return;
        }
        Cursor c = (Cursor) getExpandableListAdapter().getChild(gpos, cpos);
        c.moveToPosition(cpos);
        mCurrentArtistId = null;
        mCurrentAlbumId = Long.valueOf(mi.id).toString();
        mCurrentAlbumName = c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.Albums.ALBUM));
        gpos = gpos - getExpandableListView().getHeaderViewsCount();
        mArtistCursor.moveToPosition(gpos);
        mCurrentArtistNameForAlbum = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists.ARTIST));
        mIsUnknownArtist = mCurrentArtistNameForAlbum == null || mCurrentArtistNameForAlbum.equals(MediaStore.UNKNOWN_STRING);
        mIsUnknownAlbum = mCurrentAlbumName == null || mCurrentAlbumName.equals(MediaStore.UNKNOWN_STRING);
        if (mIsUnknownAlbum) {
            menu.setHeaderTitle(getString(R.string.unknown_album_name));
        } else {
            menu.setHeaderTitle(mCurrentAlbumName);
        }
        if (!mIsUnknownAlbum || !mIsUnknownArtist) {
            menu.add(0, SEARCH, 0, R.string.search_title);
        }
    }
}
Example 43
Project: armatus-master  File: ConsoleActivity.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    switch(v.getId()) {
        case R.id.console_empty_space:
            super.onCreateContextMenu(menu, v, menuInfo);
            menu.setHeaderTitle("Input options");
            getMenuInflater().inflate(R.menu.console_empty_space_context_menu, menu);
            if (getInputLength() == 0) {
                menu.findItem(R.id.console_input_paste_append).setTitle("Paste");
                menu.findItem(R.id.console_input_paste_append).setTitleCondensed("Paste");
                menu.findItem(R.id.console_input_paste_replace).setVisible(false);
            }
            break;
        case R.id.console_list_view:
            if (!(menuInfo instanceof AdapterContextMenuInfo)) {
                ExpandableListContextMenuInfo expInfo = (ExpandableListContextMenuInfo) menuInfo;
                int groupPos = ExpandableListView.getPackedPositionGroup(expInfo.packedPosition);
                if (//To prevent empty lines
                !mConsoleEntries.get(groupPos).getShortContents().toString().isEmpty()) {
                    super.onCreateContextMenu(menu, v, menuInfo);
                    menu.setHeaderTitle("Entry " + groupPos + ": Commands found");
                    menu.add(Menu.NONE, Menu.NONE, 1, "Sample transformation (does nothing)");
                }
            }
            break;
    }
}
Example 44
Project: AudioBook-master  File: BookshelfFragment.java View source code
// these warnings can be suppressed as the type has already been checked
@SuppressWarnings("rawtypes")
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    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);
        // 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());
        }
    }
}
Example 45
Project: Contacts_Eclair_Mod-master  File: DisplayGroupsActivity.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, view, menuInfo);
    // Bail if not working with expandable long-press, or if not child
    if (!(menuInfo instanceof ExpandableListContextMenuInfo))
        return;
    final ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;
    final int groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    final int childPosition = ExpandableListView.getPackedPositionChild(info.packedPosition);
    // Skip long-press on expandable parents
    if (childPosition == -1)
        return;
    final AccountDisplay account = (AccountDisplay) mAdapter.getGroup(groupPosition);
    final GroupDelta child = (GroupDelta) mAdapter.getChild(groupPosition, childPosition);
    // Ignore when selective syncing unsupported
    final int syncMode = getSyncMode(account);
    if (syncMode == SYNC_MODE_UNSUPPORTED)
        return;
    if (child != null) {
        showRemoveSync(menu, account, child, syncMode);
    } else {
        showAddSync(menu, account, syncMode);
    }
}
Example 46
Project: MySnippetRepo-master  File: ArtistAlbumBrowserActivity.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfoIn) {
    menu.add(0, PLAY_SELECTION, 0, R.string.play_selection);
    SubMenu sub = menu.addSubMenu(0, ADD_TO_PLAYLIST, 0, R.string.add_to_playlist);
    MusicUtils.makePlaylistMenu(this, sub);
    menu.add(0, DELETE_ITEM, 0, R.string.delete_item);
    ExpandableListContextMenuInfo mi = (ExpandableListContextMenuInfo) menuInfoIn;
    int itemtype = ExpandableListView.getPackedPositionType(mi.packedPosition);
    int gpos = ExpandableListView.getPackedPositionGroup(mi.packedPosition);
    int cpos = ExpandableListView.getPackedPositionChild(mi.packedPosition);
    if (itemtype == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        if (gpos == -1) {
            // this shouldn't happen
            Log.d("Artist/Album", "no group");
            return;
        }
        gpos = gpos - getExpandableListView().getHeaderViewsCount();
        mArtistCursor.moveToPosition(gpos);
        mCurrentArtistId = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists._ID));
        mCurrentArtistName = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists.ARTIST));
        mCurrentAlbumId = null;
        mIsUnknownArtist = mCurrentArtistName == null || mCurrentArtistName.equals(MediaStore.UNKNOWN_STRING);
        mIsUnknownAlbum = true;
        if (mIsUnknownArtist) {
            menu.setHeaderTitle(getString(R.string.unknown_artist_name));
        } else {
            menu.setHeaderTitle(mCurrentArtistName);
            menu.add(0, SEARCH, 0, R.string.search_title);
        }
        return;
    } else if (itemtype == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        if (cpos == -1) {
            // this shouldn't happen
            Log.d("Artist/Album", "no child");
            return;
        }
        Cursor c = (Cursor) getExpandableListAdapter().getChild(gpos, cpos);
        c.moveToPosition(cpos);
        mCurrentArtistId = null;
        mCurrentAlbumId = Long.valueOf(mi.id).toString();
        mCurrentAlbumName = c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.Albums.ALBUM));
        gpos = gpos - getExpandableListView().getHeaderViewsCount();
        mArtistCursor.moveToPosition(gpos);
        mCurrentArtistNameForAlbum = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists.ARTIST));
        mIsUnknownArtist = mCurrentArtistNameForAlbum == null || mCurrentArtistNameForAlbum.equals(MediaStore.UNKNOWN_STRING);
        mIsUnknownAlbum = mCurrentAlbumName == null || mCurrentAlbumName.equals(MediaStore.UNKNOWN_STRING);
        if (mIsUnknownAlbum) {
            menu.setHeaderTitle(getString(R.string.unknown_album_name));
        } else {
            menu.setHeaderTitle(mCurrentAlbumName);
        }
        if (!mIsUnknownAlbum || !mIsUnknownArtist) {
            menu.add(0, SEARCH, 0, R.string.search_title);
        }
    }
}
Example 47
Project: packages-apps-Music-master  File: ArtistAlbumBrowserActivity.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfoIn) {
    menu.add(0, PLAY_SELECTION, 0, R.string.play_selection);
    SubMenu sub = menu.addSubMenu(0, ADD_TO_PLAYLIST, 0, R.string.add_to_playlist);
    MusicUtils.makePlaylistMenu(this, sub);
    menu.add(0, DELETE_ITEM, 0, R.string.delete_item);
    ExpandableListContextMenuInfo mi = (ExpandableListContextMenuInfo) menuInfoIn;
    int itemtype = ExpandableListView.getPackedPositionType(mi.packedPosition);
    int gpos = ExpandableListView.getPackedPositionGroup(mi.packedPosition);
    int cpos = ExpandableListView.getPackedPositionChild(mi.packedPosition);
    if (itemtype == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        if (gpos == -1) {
            // this shouldn't happen
            Log.d("Artist/Album", "no group");
            return;
        }
        gpos = gpos - getExpandableListView().getHeaderViewsCount();
        mArtistCursor.moveToPosition(gpos);
        mCurrentArtistId = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists._ID));
        mCurrentArtistName = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists.ARTIST));
        mCurrentAlbumId = null;
        mIsUnknownArtist = mCurrentArtistName == null || mCurrentArtistName.equals(MediaStore.UNKNOWN_STRING);
        mIsUnknownAlbum = true;
        if (mIsUnknownArtist) {
            menu.setHeaderTitle(getString(R.string.unknown_artist_name));
        } else {
            menu.setHeaderTitle(mCurrentArtistName);
            menu.add(0, SEARCH, 0, R.string.search_title);
        }
        return;
    } else if (itemtype == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        if (cpos == -1) {
            // this shouldn't happen
            Log.d("Artist/Album", "no child");
            return;
        }
        Cursor c = (Cursor) getExpandableListAdapter().getChild(gpos, cpos);
        c.moveToPosition(cpos);
        mCurrentArtistId = null;
        mCurrentAlbumId = Long.valueOf(mi.id).toString();
        mCurrentAlbumName = c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.Albums.ALBUM));
        gpos = gpos - getExpandableListView().getHeaderViewsCount();
        mArtistCursor.moveToPosition(gpos);
        mCurrentArtistNameForAlbum = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists.ARTIST));
        mIsUnknownArtist = mCurrentArtistNameForAlbum == null || mCurrentArtistNameForAlbum.equals(MediaStore.UNKNOWN_STRING);
        mIsUnknownAlbum = mCurrentAlbumName == null || mCurrentAlbumName.equals(MediaStore.UNKNOWN_STRING);
        if (mIsUnknownAlbum) {
            menu.setHeaderTitle(getString(R.string.unknown_album_name));
        } else {
            menu.setHeaderTitle(mCurrentAlbumName);
        }
        if (!mIsUnknownAlbum || !mIsUnknownArtist) {
            menu.add(0, SEARCH, 0, R.string.search_title);
        }
    }
}
Example 48
Project: platform_packages_apps_music-master  File: ArtistAlbumBrowserActivity.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfoIn) {
    menu.add(0, PLAY_SELECTION, 0, R.string.play_selection);
    SubMenu sub = menu.addSubMenu(0, ADD_TO_PLAYLIST, 0, R.string.add_to_playlist);
    MusicUtils.makePlaylistMenu(this, sub);
    menu.add(0, DELETE_ITEM, 0, R.string.delete_item);
    ExpandableListContextMenuInfo mi = (ExpandableListContextMenuInfo) menuInfoIn;
    int itemtype = ExpandableListView.getPackedPositionType(mi.packedPosition);
    int gpos = ExpandableListView.getPackedPositionGroup(mi.packedPosition);
    int cpos = ExpandableListView.getPackedPositionChild(mi.packedPosition);
    if (itemtype == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        if (gpos == -1) {
            // this shouldn't happen
            Log.d("Artist/Album", "no group");
            return;
        }
        gpos = gpos - getExpandableListView().getHeaderViewsCount();
        mArtistCursor.moveToPosition(gpos);
        mCurrentArtistId = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists._ID));
        mCurrentArtistName = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists.ARTIST));
        mCurrentAlbumId = null;
        mIsUnknownArtist = mCurrentArtistName == null || mCurrentArtistName.equals(MediaStore.UNKNOWN_STRING);
        mIsUnknownAlbum = true;
        if (mIsUnknownArtist) {
            menu.setHeaderTitle(getString(R.string.unknown_artist_name));
        } else {
            menu.setHeaderTitle(mCurrentArtistName);
            menu.add(0, SEARCH, 0, R.string.search_title);
        }
        return;
    } else if (itemtype == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        if (cpos == -1) {
            // this shouldn't happen
            Log.d("Artist/Album", "no child");
            return;
        }
        Cursor c = (Cursor) getExpandableListAdapter().getChild(gpos, cpos);
        c.moveToPosition(cpos);
        mCurrentArtistId = null;
        mCurrentAlbumId = Long.valueOf(mi.id).toString();
        mCurrentAlbumName = c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.Albums.ALBUM));
        gpos = gpos - getExpandableListView().getHeaderViewsCount();
        mArtistCursor.moveToPosition(gpos);
        mCurrentArtistNameForAlbum = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists.ARTIST));
        mIsUnknownArtist = mCurrentArtistNameForAlbum == null || mCurrentArtistNameForAlbum.equals(MediaStore.UNKNOWN_STRING);
        mIsUnknownAlbum = mCurrentAlbumName == null || mCurrentAlbumName.equals(MediaStore.UNKNOWN_STRING);
        if (mIsUnknownAlbum) {
            menu.setHeaderTitle(getString(R.string.unknown_album_name));
        } else {
            menu.setHeaderTitle(mCurrentAlbumName);
        }
        if (!mIsUnknownAlbum || !mIsUnknownArtist) {
            menu.add(0, SEARCH, 0, R.string.search_title);
        }
    }
}
Example 49
Project: ppc1-master  File: RSSReaderActivity.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    // TODO Auto-generated method stub
    ExpandableListContextMenuInfo mInfo = (ExpandableListContextMenuInfo) menuInfo;
    int type = ExpandableListView.getPackedPositionType(mInfo.packedPosition);
    if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        menu.add(0, EDIT, Menu.NONE, "±à¼­");
        menu.add(0, DELETE, Menu.NONE, "ɾ³ý");
    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        menu.add(0, DELETE, Menu.NONE, "ɾ³ý");
    }
}
Example 50
Project: SPD8810GA-master  File: ContactsPreferencesActivity.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, view, menuInfo);
    // Bail if not working with expandable long-press, or if not child
    if (!(menuInfo instanceof ExpandableListContextMenuInfo))
        return;
    final ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;
    final int groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    final int childPosition = ExpandableListView.getPackedPositionChild(info.packedPosition);
    // Skip long-press on expandable parents
    if (childPosition == -1)
        return;
    final AccountDisplay account = (AccountDisplay) mAdapter.getGroup(groupPosition);
    final GroupDelta child = (GroupDelta) mAdapter.getChild(groupPosition, childPosition);
    // Ignore when selective syncing unsupported
    final int syncMode = getSyncMode(account);
    if (syncMode == SYNC_MODE_UNSUPPORTED)
        return;
    if (child != null) {
        showRemoveSync(menu, account, child, syncMode);
    } else {
        showAddSync(menu, account, syncMode);
    }
}
Example 51
Project: themes-platform-packages-apps-Contacts-master  File: ContactsPreferencesActivity.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, view, menuInfo);
    // Bail if not working with expandable long-press, or if not child
    if (!(menuInfo instanceof ExpandableListContextMenuInfo))
        return;
    final ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;
    final int groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    final int childPosition = ExpandableListView.getPackedPositionChild(info.packedPosition);
    // Skip long-press on expandable parents
    if (childPosition == -1)
        return;
    final AccountDisplay account = (AccountDisplay) mAdapter.getGroup(groupPosition);
    final GroupDelta child = (GroupDelta) mAdapter.getChild(groupPosition, childPosition);
    // Ignore when selective syncing unsupported
    final int syncMode = getSyncMode(account);
    if (syncMode == SYNC_MODE_UNSUPPORTED)
        return;
    if (child != null) {
        showRemoveSync(menu, account, child, syncMode);
    } else {
        showAddSync(menu, account, syncMode);
    }
}
Example 52
Project: themes-platform-packages-apps-Music-master  File: ArtistAlbumBrowserActivity.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfoIn) {
    menu.add(0, PLAY_SELECTION, 0, R.string.play_selection);
    SubMenu sub = menu.addSubMenu(0, ADD_TO_PLAYLIST, 0, R.string.add_to_playlist);
    MusicUtils.makePlaylistMenu(this, sub);
    menu.add(0, DELETE_ITEM, 0, R.string.delete_item);
    ExpandableListContextMenuInfo mi = (ExpandableListContextMenuInfo) menuInfoIn;
    int itemtype = ExpandableListView.getPackedPositionType(mi.packedPosition);
    int gpos = ExpandableListView.getPackedPositionGroup(mi.packedPosition);
    int cpos = ExpandableListView.getPackedPositionChild(mi.packedPosition);
    if (itemtype == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        if (gpos == -1) {
            // this shouldn't happen
            Log.d("Artist/Album", "no group");
            return;
        }
        gpos = gpos - getExpandableListView().getHeaderViewsCount();
        mArtistCursor.moveToPosition(gpos);
        mCurrentArtistId = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists._ID));
        mCurrentArtistName = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists.ARTIST));
        mCurrentAlbumId = null;
        mIsUnknownArtist = mCurrentArtistName == null || mCurrentArtistName.equals(MediaStore.UNKNOWN_STRING);
        mIsUnknownAlbum = true;
        if (mIsUnknownArtist) {
            menu.setHeaderTitle(getString(R.string.unknown_artist_name));
        } else {
            menu.setHeaderTitle(mCurrentArtistName);
            menu.add(0, SEARCH, 0, R.string.search_title);
        }
        return;
    } else if (itemtype == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        if (cpos == -1) {
            // this shouldn't happen
            Log.d("Artist/Album", "no child");
            return;
        }
        Cursor c = (Cursor) getExpandableListAdapter().getChild(gpos, cpos);
        c.moveToPosition(cpos);
        mCurrentArtistId = null;
        mCurrentAlbumId = Long.valueOf(mi.id).toString();
        mCurrentAlbumName = c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.Albums.ALBUM));
        gpos = gpos - getExpandableListView().getHeaderViewsCount();
        mArtistCursor.moveToPosition(gpos);
        mCurrentArtistNameForAlbum = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists.ARTIST));
        mIsUnknownArtist = mCurrentArtistNameForAlbum == null || mCurrentArtistNameForAlbum.equals(MediaStore.UNKNOWN_STRING);
        mIsUnknownAlbum = mCurrentAlbumName == null || mCurrentAlbumName.equals(MediaStore.UNKNOWN_STRING);
        if (mIsUnknownAlbum) {
            menu.setHeaderTitle(getString(R.string.unknown_album_name));
        } else {
            menu.setHeaderTitle(mCurrentAlbumName);
        }
        if (!mIsUnknownAlbum || !mIsUnknownArtist) {
            menu.add(0, SEARCH, 0, R.string.search_title);
        }
    }
}
Example 53
Project: TSoft-HGJ-master  File: DisplayGroupsActivity.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, view, menuInfo);
    // Bail if not working with expandable long-press, or if not child
    if (!(menuInfo instanceof ExpandableListContextMenuInfo))
        return;
    final ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) menuInfo;
    final int groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    final int childPosition = ExpandableListView.getPackedPositionChild(info.packedPosition);
    // Skip long-press on expandable parents
    if (childPosition == -1)
        return;
    final AccountDisplay account = (AccountDisplay) mAdapter.getGroup(groupPosition);
    final GroupDelta child = (GroupDelta) mAdapter.getChild(groupPosition, childPosition);
    // Ignore when selective syncing unsupported
    final int syncMode = getSyncMode(account);
    if (syncMode == SYNC_MODE_UNSUPPORTED)
        return;
    if (child != null) {
        showRemoveSync(menu, account, child, syncMode);
    } else {
        showAddSync(menu, account, syncMode);
    }
}
Example 54
Project: TUMensa-master  File: MensaMeals.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    if (v instanceof ExpandableListView) {
        ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;
        int type = ExpandableListView.getPackedPositionType(info.packedPosition);
        // Only create a context menu for child items
        if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
            menu.setHeaderTitle(getResources().getString(R.string.contextmenu_meals));
            menu.add(MENU_GROUP_MEAL_ID, MENU_SHARE_ID, 0, getResources().getString(R.string.contextmenu_share_with_friends));
            if (mSettings.m_bEnableVoting && (mToday.before(Calendar.getInstance()) || mToday.equals(Calendar.getInstance()))) {
                menu.add(MENU_GROUP_MEAL_ID, MENU_VOTE_ID, 1, getResources().getString(R.string.contextmenu_vote));
            }
        }
    } else if (v instanceof Button) {
        menu.setHeaderTitle(getResources().getString(R.string.pref_MensaLocationLabel));
        int pos = 0;
        for (String loc : getResources().getStringArray(R.array.MensaLocations)) {
            menu.add(MENU_GROUP_MENSA_ID, pos, pos, loc);
            pos++;
        }
    }
}
Example 55
Project: WS171-packages-apps-Music-master  File: ArtistAlbumBrowserActivity.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfoIn) {
    menu.add(0, PLAY_SELECTION, 0, R.string.play_selection);
    SubMenu sub = menu.addSubMenu(0, ADD_TO_PLAYLIST, 0, R.string.add_to_playlist);
    MusicUtils.makePlaylistMenu(this, sub);
    menu.add(0, DELETE_ITEM, 0, R.string.delete_item);
    menu.add(0, SEARCH, 0, R.string.search_title);
    ExpandableListContextMenuInfo mi = (ExpandableListContextMenuInfo) menuInfoIn;
    int itemtype = ExpandableListView.getPackedPositionType(mi.packedPosition);
    int gpos = ExpandableListView.getPackedPositionGroup(mi.packedPosition);
    int cpos = ExpandableListView.getPackedPositionChild(mi.packedPosition);
    if (itemtype == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        if (gpos == -1) {
            // this shouldn't happen
            Log.d("Artist/Album", "no group");
            return;
        }
        gpos = gpos - getExpandableListView().getHeaderViewsCount();
        mArtistCursor.moveToPosition(gpos);
        mCurrentArtistId = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists._ID));
        mCurrentArtistName = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists.ARTIST));
        mCurrentAlbumId = null;
        menu.setHeaderTitle(mCurrentArtistName);
        return;
    } else if (itemtype == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        if (cpos == -1) {
            // this shouldn't happen
            Log.d("Artist/Album", "no child");
            return;
        }
        Cursor c = (Cursor) getExpandableListAdapter().getChild(gpos, cpos);
        c.moveToPosition(cpos);
        mCurrentArtistId = null;
        mCurrentAlbumId = Long.valueOf(mi.id).toString();
        mCurrentAlbumName = c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.Albums.ALBUM));
        gpos = gpos - getExpandableListView().getHeaderViewsCount();
        mArtistCursor.moveToPosition(gpos);
        mCurrentArtistNameForAlbum = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists.ARTIST));
        menu.setHeaderTitle(mCurrentAlbumName);
    }
}
Example 56
Project: zhong-master  File: ArtistAlbumBrowserActivity.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfoIn) {
    menu.add(0, PLAY_SELECTION, 0, R.string.play_selection);
    SubMenu sub = menu.addSubMenu(0, ADD_TO_PLAYLIST, 0, R.string.add_to_playlist);
    MusicUtils.makePlaylistMenu(this, sub);
    menu.add(0, DELETE_ITEM, 0, R.string.delete_item);
    ExpandableListContextMenuInfo mi = (ExpandableListContextMenuInfo) menuInfoIn;
    int itemtype = ExpandableListView.getPackedPositionType(mi.packedPosition);
    int gpos = ExpandableListView.getPackedPositionGroup(mi.packedPosition);
    int cpos = ExpandableListView.getPackedPositionChild(mi.packedPosition);
    if (itemtype == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        if (gpos == -1) {
            // this shouldn't happen
            Log.d("Artist/Album", "no group");
            return;
        }
        gpos = gpos - getExpandableListView().getHeaderViewsCount();
        mArtistCursor.moveToPosition(gpos);
        mCurrentArtistId = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists._ID));
        mCurrentArtistName = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists.ARTIST));
        mCurrentAlbumId = null;
        mIsUnknownArtist = mCurrentArtistName == null || mCurrentArtistName.equals(Const.UNKNOWN_STRING);
        mIsUnknownAlbum = true;
        if (mIsUnknownArtist) {
            menu.setHeaderTitle(getString(R.string.unknown_artist_name));
        } else {
            menu.setHeaderTitle(MusicUtils.convertGBK(mCurrentArtistName));
            menu.add(0, SEARCH, 0, R.string.search_title);
        }
        return;
    } else if (itemtype == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        if (cpos == -1) {
            // this shouldn't happen
            Log.d("Artist/Album", "no child");
            return;
        }
        Cursor c = (Cursor) getExpandableListAdapter().getChild(gpos, cpos);
        c.moveToPosition(cpos);
        mCurrentArtistId = null;
        mCurrentAlbumId = Long.valueOf(mi.id).toString();
        mCurrentAlbumName = c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.Albums.ALBUM));
        gpos = gpos - getExpandableListView().getHeaderViewsCount();
        mArtistCursor.moveToPosition(gpos);
        mCurrentArtistNameForAlbum = mArtistCursor.getString(mArtistCursor.getColumnIndexOrThrow(MediaStore.Audio.Artists.ARTIST));
        mIsUnknownArtist = mCurrentArtistNameForAlbum == null || mCurrentArtistNameForAlbum.equals(Const.UNKNOWN_STRING);
        mIsUnknownAlbum = mCurrentAlbumName == null || mCurrentAlbumName.equals(Const.UNKNOWN_STRING);
        if (mIsUnknownAlbum) {
            menu.setHeaderTitle(getString(R.string.unknown_album_name));
        } else {
            menu.setHeaderTitle(MusicUtils.convertGBK(mCurrentAlbumName));
        }
        if (!mIsUnknownAlbum || !mIsUnknownArtist) {
            menu.add(0, SEARCH, 0, R.string.search_title);
        }
    }
}
Example 57
Project: MyBusEdinburgh-master  File: DisplayStopDataFragment.java View source code
/**
     * {@inheritDoc}
     */
@Override
public boolean onContextItemSelected(final MenuItem item) {
    // Cast the information parameter.
    final ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
    switch(item.getItemId()) {
        case R.id.displaystopdata_context_menu_addarrivalalert:
            // Get the position where this data lives.
            final int position = ExpandableListView.getPackedPositionGroup(info.packedPosition);
            if (listAdapter != null && position < listAdapter.getGroupCount()) {
                final HashMap<String, String> groupData = (HashMap<String, String>) listAdapter.getGroup(position);
                // Fire off the Activity.
                callbacks.onShowAddTimeAlert(stopCode, new String[] { groupData.get(SERVICE_NAME_KEY) });
            }
            return true;
        default:
            return super.onContextItemSelected(item);
    }
}
Example 58
Project: Osmand-master  File: LocalIndexesFragment.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    long packedPos = ((ExpandableListContextMenuInfo) menuInfo).packedPosition;
    int group = ExpandableListView.getPackedPositionGroup(packedPos);
    int child = ExpandableListView.getPackedPositionChild(packedPos);
    if (child >= 0 && group >= 0) {
        final LocalIndexInfo point = listAdapter.getChild(group, child);
        showContextMenu(point);
    }
}
Example 59
Project: WS171-packages-apps-Email-master  File: FolderMessageList.java View source code
@Override
public boolean onContextItemSelected(MenuItem item) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
    int groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    int childPosition = ExpandableListView.getPackedPositionChild(info.packedPosition);
    FolderInfoHolder folder = (FolderInfoHolder) mAdapter.getGroup(groupPosition);
    if (childPosition < mAdapter.getChildrenCount(groupPosition)) {
        MessageInfoHolder holder = (MessageInfoHolder) mAdapter.getChild(groupPosition, childPosition);
        switch(item.getItemId()) {
            case R.id.open:
                onOpenMessage(folder, holder);
                break;
            case R.id.delete:
                onDelete(holder);
                break;
            case R.id.reply:
                onReply(holder);
                break;
            case R.id.reply_all:
                onReplyAll(holder);
                break;
            case R.id.forward:
                onForward(holder);
                break;
            case R.id.mark_as_read:
                onToggleRead(holder);
                break;
        }
    }
    return super.onContextItemSelected(item);
}
Example 60
Project: yax-master  File: MainWindow.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    ExpandableListView.ExpandableListContextMenuInfo info;
    try {
        info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;
    } catch (ClassCastException e) {
        Log.e(TAG, "bad menuinfo: ", e);
        return;
    }
    long packedPosition = info.packedPosition;
    boolean isChild = isChild(packedPosition);
    // get the entry name for the item
    String menuName;
    boolean isMuc = false;
    if (isChild) {
        // do not show context menu before a contact has been added
        if (getItemStatusMode(packedPosition) == StatusMode.subscribe)
            return;
        getMenuInflater().inflate(R.menu.roster_item_contextmenu, menu);
        menuName = String.format("%s (%s)", getPackedItemRow(packedPosition, RosterConstants.ALIAS), getPackedItemRow(packedPosition, RosterConstants.JID));
        isMuc = ChatRoomHelper.isRoom(this, getPackedItemRow(packedPosition, RosterConstants.JID));
        if (isMuc) {
            getMenuInflater().inflate(R.menu.muc_options, menu);
            menu.findItem(R.id.chat_optionsmenu_userlist).setVisible(false);
        } else
            getMenuInflater().inflate(R.menu.contact_options, menu);
    } else {
        menuName = getPackedItemRow(packedPosition, RosterConstants.GROUP);
        if (menuName.equals("") || menuName.equals(RosterConstants.MUCS))
            // no options for default menu
            return;
        getMenuInflater().inflate(R.menu.roster_group_contextmenu, menu);
    }
    menu.setHeaderTitle(menuName);
}
Example 61
Project: yaxim-master  File: MainWindow.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    ExpandableListView.ExpandableListContextMenuInfo info;
    try {
        info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;
    } catch (ClassCastException e) {
        Log.e(TAG, "bad menuinfo: ", e);
        return;
    }
    long packedPosition = info.packedPosition;
    boolean isChild = isChild(packedPosition);
    // get the entry name for the item
    String menuName;
    boolean isMuc = false;
    if (isChild) {
        // do not show context menu before a contact has been added
        if (getItemStatusMode(packedPosition) == StatusMode.subscribe)
            return;
        getMenuInflater().inflate(R.menu.roster_item_contextmenu, menu);
        menuName = String.format("%s (%s)", getPackedItemRow(packedPosition, RosterConstants.ALIAS), getPackedItemRow(packedPosition, RosterConstants.JID));
        isMuc = ChatRoomHelper.isRoom(this, getPackedItemRow(packedPosition, RosterConstants.JID));
        if (isMuc) {
            getMenuInflater().inflate(R.menu.muc_options, menu);
            menu.findItem(R.id.chat_optionsmenu_userlist).setVisible(false);
        } else
            getMenuInflater().inflate(R.menu.contact_options, menu);
    } else {
        menuName = getPackedItemRow(packedPosition, RosterConstants.GROUP);
        if (menuName.equals("") || menuName.equals(RosterConstants.MUCS))
            // no options for default menu
            return;
        getMenuInflater().inflate(R.menu.roster_group_contextmenu, menu);
    }
    menu.setHeaderTitle(menuName);
}
Example 62
Project: android_packages_apps_Email-master  File: FolderMessageList.java View source code
@Override
public boolean onContextItemSelected(MenuItem item) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
    int groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    int childPosition = ExpandableListView.getPackedPositionChild(info.packedPosition);
    if (childPosition < mAdapter.getChildrenCount(groupPosition)) {
        switch(item.getItemId()) {
            case R.id.open:
                onOpenMessage(groupPosition, childPosition);
                break;
        }
    // TODO: completely rewrite this.  For now, just don't crash.
    /*
            FolderInfoHolder folder = (FolderInfoHolder) mAdapter.getGroup(groupPosition);
            MessageInfoHolder holder =
                (MessageInfoHolder) mAdapter.getChild(groupPosition, childPosition);
            switch (item.getItemId()) {
                case R.id.open:
                    onOpenMessage(folder, holder);
                    break;
                case R.id.delete:
                    onDelete(holder);
                    break;
                case R.id.reply:
                    onReply(holder);
                    break;
                case R.id.reply_all:
                    onReplyAll(holder);
                    break;
                case R.id.forward:
                    onForward(holder);
                    break;
                case R.id.mark_as_read:
                    onToggleRead(holder);
                    break;
            }
*/
    }
    return super.onContextItemSelected(item);
}
Example 63
Project: Book-Catalogue-master  File: BookCatalogueClassic.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;
    try {
        // Only delete titles, not authors
        if (ExpandableListView.getPackedPositionType(info.packedPosition) == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
            MenuItem delete = menu.add(0, DELETE_ID, 0, R.string.menu_delete);
            delete.setIcon(android.R.drawable.ic_menu_delete);
            MenuItem edit_book = menu.add(0, EDIT_BOOK, 0, R.string.edit_book);
            edit_book.setIcon(android.R.drawable.ic_menu_edit);
            MenuItem edit_book_notes = menu.add(0, EDIT_BOOK_NOTES, 0, R.string.edit_book_notes);
            edit_book_notes.setIcon(R.drawable.ic_menu_compose);
            MenuItem edit_book_friends = menu.add(0, EDIT_BOOK_FRIENDS, 0, R.string.edit_book_friends);
            edit_book_friends.setIcon(R.drawable.ic_menu_cc);
            // Send book to goodreads
            MenuItem edit_book_send_to_gr = menu.add(0, EDIT_BOOK_SEND_TO_GR, 0, R.string.edit_book_send_to_gr);
            edit_book_send_to_gr.setIcon(R.drawable.ic_menu_cc);
        } else if (ExpandableListView.getPackedPositionType(info.packedPosition) == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
            switch(sort) {
                case SORT_AUTHOR:
                case SORT_AUTHOR_GIVEN:
                    {
                        MenuItem edit_book = menu.add(0, EDIT_AUTHOR_ID, 0, R.string.menu_edit_author);
                        edit_book.setIcon(android.R.drawable.ic_menu_edit);
                        break;
                    }
                case SORT_SERIES:
                    {
                        MenuItem delete = menu.add(0, DELETE_SERIES_ID, 0, R.string.menu_delete_series);
                        delete.setIcon(android.R.drawable.ic_menu_delete);
                        MenuItem edit_book = menu.add(0, EDIT_SERIES_ID, 0, R.string.menu_edit_series);
                        edit_book.setIcon(android.R.drawable.ic_menu_edit);
                        break;
                    }
            }
        }
    } catch (NullPointerException e) {
        Logger.logError(e);
    }
}
Example 64
Project: networklog-master  File: AppFragment.java View source code
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;
    int type = ExpandableListView.getPackedPositionType(info.packedPosition);
    int group = ExpandableListView.getPackedPositionGroup(info.packedPosition);
    int child = ExpandableListView.getPackedPositionChild(info.packedPosition);
    MenuInflater inflater = getActivity().getMenuInflater();
    inflater.inflate(R.layout.app_context_menu, menu);
    if (type != ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        menu.findItem(R.id.app_copy_ip).setVisible(false);
        menu.findItem(R.id.app_whois_ip).setVisible(false);
    }
    GroupItem groupItem = (GroupItem) adapter.getGroup(group);
    if (NetworkLogService.toastBlockedApps.get(groupItem.app.packageName) != null) {
        menu.findItem(R.id.app_toggle_app_notifications).setTitle(R.string.enable_notifications);
    } else {
        menu.findItem(R.id.app_toggle_app_notifications).setTitle(R.string.disable_notifications);
    }
    if (NetworkLogService.blockedApps.get(groupItem.app.packageName) != null) {
        menu.findItem(R.id.app_toggle_app_logging).setTitle(R.string.unblock_app);
    } else {
        menu.findItem(R.id.app_toggle_app_logging).setTitle(R.string.block_app);
    }
}
Example 65
Project: android_Browser-master  File: BrowserHistoryPage.java View source code
View getTargetView(ContextMenuInfo menuInfo) {
    if (menuInfo instanceof AdapterContextMenuInfo) {
        return ((AdapterContextMenuInfo) menuInfo).targetView;
    }
    if (menuInfo instanceof ExpandableListContextMenuInfo) {
        return ((ExpandableListContextMenuInfo) menuInfo).targetView;
    }
    return null;
}
Example 66
Project: browser.apk-master  File: BrowserHistoryPage.java View source code
View getTargetView(ContextMenuInfo menuInfo) {
    if (menuInfo instanceof AdapterContextMenuInfo) {
        return ((AdapterContextMenuInfo) menuInfo).targetView;
    }
    if (menuInfo instanceof ExpandableListContextMenuInfo) {
        return ((ExpandableListContextMenuInfo) menuInfo).targetView;
    }
    return null;
}
Example 67
Project: platform_packages_apps_browser-master  File: BrowserHistoryPage.java View source code
View getTargetView(ContextMenuInfo menuInfo) {
    if (menuInfo instanceof AdapterContextMenuInfo) {
        return ((AdapterContextMenuInfo) menuInfo).targetView;
    }
    if (menuInfo instanceof ExpandableListContextMenuInfo) {
        return ((ExpandableListContextMenuInfo) menuInfo).targetView;
    }
    return null;
}
Example 68
Project: RocBrowser-master  File: BrowserHistoryPage.java View source code
View getTargetView(ContextMenuInfo menuInfo) {
    if (menuInfo instanceof AdapterContextMenuInfo) {
        return ((AdapterContextMenuInfo) menuInfo).targetView;
    }
    if (menuInfo instanceof ExpandableListContextMenuInfo) {
        return ((ExpandableListContextMenuInfo) menuInfo).targetView;
    }
    return null;
}
Example 69
Project: XBrowser-master  File: BrowserHistoryPage.java View source code
View getTargetView(ContextMenuInfo menuInfo) {
    if (menuInfo instanceof AdapterContextMenuInfo) {
        return ((AdapterContextMenuInfo) menuInfo).targetView;
    }
    if (menuInfo instanceof ExpandableListContextMenuInfo) {
        return ((ExpandableListContextMenuInfo) menuInfo).targetView;
    }
    return null;
}