Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ae2b732d authored by Philip P. Moltmann's avatar Philip P. Moltmann
Browse files

Don't attempt to create context menu for 'add printer' entry

As the 'printer' variable becomes null and the activity crashes.

This could also be solved to register context menu's for each printer
entry (and not for the 'add printer' entry). Then we would need to
create a custom view for the printer entry that returns a
ContextMenuInfo containing the printer ID. While this solution is
cleaner, it is much more complex.

Test: Tried to open context menu in 'add printer' entry
Change-Id: I23dcba2dd876cff27b5cad9736f5ec4524985bac
Fixes: 73126748
parent e047522e
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -285,6 +285,11 @@ public final class SelectPrinterActivity extends Activity implements
            final int position = ((AdapterContextMenuInfo) menuInfo).position;
            PrinterInfo printer = (PrinterInfo) mListView.getAdapter().getItem(position);

            // Printer is null if this is a context menu for the "add printer" entry
            if (printer == null) {
                return;
            }

            menu.setHeaderTitle(printer.getName());

            // Add the select menu item if applicable.