Search in sources :

Example 1 with AdapterContextMenuInfo

use of android.widget.AdapterView.AdapterContextMenuInfo in project k-9 by k9mail.

the class MessageListFragment method onCreateContextMenu.

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    Cursor cursor = (Cursor) listView.getItemAtPosition(info.position);
    if (cursor == null) {
        return;
    }
    getActivity().getMenuInflater().inflate(R.menu.message_list_item_context, menu);
    menu.findItem(R.id.debug_delete_locally).setVisible(BuildConfig.DEBUG);
    contextMenuUniqueId = cursor.getLong(uniqueIdColumn);
    Account account = getAccountFromCursor(cursor);
    String subject = cursor.getString(SUBJECT_COLUMN);
    boolean read = (cursor.getInt(READ_COLUMN) == 1);
    boolean flagged = (cursor.getInt(FLAGGED_COLUMN) == 1);
    menu.setHeaderTitle(subject);
    if (selected.contains(contextMenuUniqueId)) {
        menu.findItem(R.id.select).setVisible(false);
    } else {
        menu.findItem(R.id.deselect).setVisible(false);
    }
    if (read) {
        menu.findItem(R.id.mark_as_read).setVisible(false);
    } else {
        menu.findItem(R.id.mark_as_unread).setVisible(false);
    }
    if (flagged) {
        menu.findItem(R.id.flag).setVisible(false);
    } else {
        menu.findItem(R.id.unflag).setVisible(false);
    }
    if (!messagingController.isCopyCapable(account)) {
        menu.findItem(R.id.copy).setVisible(false);
    }
    if (!messagingController.isMoveCapable(account)) {
        menu.findItem(R.id.move).setVisible(false);
        menu.findItem(R.id.archive).setVisible(false);
        menu.findItem(R.id.spam).setVisible(false);
    }
    if (!account.hasArchiveFolder()) {
        menu.findItem(R.id.archive).setVisible(false);
    }
    if (!account.hasSpamFolder()) {
        menu.findItem(R.id.spam).setVisible(false);
    }
}
Also used : Account(com.fsck.k9.Account) AdapterContextMenuInfo(android.widget.AdapterView.AdapterContextMenuInfo) Cursor(android.database.Cursor)

Example 2 with AdapterContextMenuInfo

use of android.widget.AdapterView.AdapterContextMenuInfo in project tree-view-list-android by Polidea.

the class TreeViewListDemo method onContextItemSelected.

@Override
public boolean onContextItemSelected(final MenuItem item) {
    final AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    final long id = info.id;
    if (item.getItemId() == R.id.context_menu_collapse) {
        manager.collapseChildren(id);
        return true;
    } else if (item.getItemId() == R.id.context_menu_expand_all) {
        manager.expandEverythingBelow(id);
        return true;
    } else if (item.getItemId() == R.id.context_menu_expand_item) {
        manager.expandDirectChildren(id);
        return true;
    } else if (item.getItemId() == R.id.context_menu_delete) {
        manager.removeNodeRecursively(id);
        return true;
    } else {
        return super.onContextItemSelected(item);
    }
}
Also used : AdapterContextMenuInfo(android.widget.AdapterView.AdapterContextMenuInfo)

Example 3 with AdapterContextMenuInfo

use of android.widget.AdapterView.AdapterContextMenuInfo in project android_frameworks_base by ResurrectionRemix.

the class SelectPrinterActivity method onCreateContextMenu.

@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
    if (view == mListView) {
        final int position = ((AdapterContextMenuInfo) menuInfo).position;
        PrinterInfo printer = (PrinterInfo) mListView.getAdapter().getItem(position);
        menu.setHeaderTitle(printer.getName());
        // Add the select menu item if applicable.
        if (printer.getStatus() != PrinterInfo.STATUS_UNAVAILABLE) {
            MenuItem selectItem = menu.add(Menu.NONE, R.string.print_select_printer, Menu.NONE, R.string.print_select_printer);
            Intent intent = new Intent();
            intent.putExtra(EXTRA_PRINTER, printer);
            selectItem.setIntent(intent);
        }
        // Add the forget menu item if applicable.
        if (mPrinterRegistry.isFavoritePrinter(printer.getId())) {
            MenuItem forgetItem = menu.add(Menu.NONE, R.string.print_forget_printer, Menu.NONE, R.string.print_forget_printer);
            Intent intent = new Intent();
            intent.putExtra(EXTRA_PRINTER_ID, printer.getId());
            forgetItem.setIntent(intent);
        }
    }
}
Also used : AdapterContextMenuInfo(android.widget.AdapterView.AdapterContextMenuInfo) MenuItem(android.view.MenuItem) Intent(android.content.Intent) PrinterInfo(android.print.PrinterInfo)

Example 4 with AdapterContextMenuInfo

use of android.widget.AdapterView.AdapterContextMenuInfo in project UltimateAndroid by cymcsg.

the class TeamDetails method onContextItemSelected.

@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    switch(item.getItemId()) {
        case R.id.delete_meeting:
            positionOfMeetingToDelete = info.position;
            showDialog(CONFIRM_DELETE_MEETING_DIALOG);
            return true;
        default:
            return super.onContextItemSelected(item);
    }
}
Also used : AdapterContextMenuInfo(android.widget.AdapterView.AdapterContextMenuInfo)

Example 5 with AdapterContextMenuInfo

use of android.widget.AdapterView.AdapterContextMenuInfo in project android_frameworks_base by AOSPA.

the class SelectPrinterActivity method onCreateContextMenu.

@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
    if (view == mListView) {
        final int position = ((AdapterContextMenuInfo) menuInfo).position;
        PrinterInfo printer = (PrinterInfo) mListView.getAdapter().getItem(position);
        menu.setHeaderTitle(printer.getName());
        // Add the select menu item if applicable.
        if (printer.getStatus() != PrinterInfo.STATUS_UNAVAILABLE) {
            MenuItem selectItem = menu.add(Menu.NONE, R.string.print_select_printer, Menu.NONE, R.string.print_select_printer);
            Intent intent = new Intent();
            intent.putExtra(EXTRA_PRINTER, printer);
            selectItem.setIntent(intent);
        }
        // Add the forget menu item if applicable.
        if (mPrinterRegistry.isFavoritePrinter(printer.getId())) {
            MenuItem forgetItem = menu.add(Menu.NONE, R.string.print_forget_printer, Menu.NONE, R.string.print_forget_printer);
            Intent intent = new Intent();
            intent.putExtra(EXTRA_PRINTER_ID, printer.getId());
            forgetItem.setIntent(intent);
        }
    }
}
Also used : AdapterContextMenuInfo(android.widget.AdapterView.AdapterContextMenuInfo) MenuItem(android.view.MenuItem) Intent(android.content.Intent) PrinterInfo(android.print.PrinterInfo)

Aggregations

AdapterContextMenuInfo (android.widget.AdapterView.AdapterContextMenuInfo)54 Intent (android.content.Intent)9 MenuItem (android.view.MenuItem)7 Cursor (android.database.Cursor)6 PrinterInfo (android.print.PrinterInfo)5 MenuInflater (android.view.MenuInflater)5 AdapterView (android.widget.AdapterView)5 AlertDialog (android.app.AlertDialog)3 DialogInterface (android.content.DialogInterface)3 ContextMenuInfo (android.view.ContextMenu.ContextMenuInfo)3 SuppressLint (android.annotation.SuppressLint)2 CheckBoxPreference (android.preference.CheckBoxPreference)2 Preference (android.preference.Preference)2 SubMenu (android.view.SubMenu)2 Account (com.fsck.k9.Account)2 MalformedURLException (java.net.MalformedURLException)2 DatePickerDialog (android.app.DatePickerDialog)1 VpnProfile (android.net.vpn.VpnProfile)1 VpnState (android.net.vpn.VpnState)1 SparseBooleanArray (android.util.SparseBooleanArray)1