Exemple #1
0
        public override bool onOptionsItemSelected(MenuItem item)
        {
            switch (item.ItemId)
            {
            case R.id.action_add_entry:
                EntryDialogFragment.showDialog(SupportFragmentManager, "Add entry", null);
                return(true);

            default:
                return(base.onOptionsItemSelected(item));
            }
        }
Exemple #2
0
        public override bool onContextItemSelected(MenuItem item)
        {
            AdapterContextMenuInfo info = (AdapterContextMenuInfo)item.MenuInfo;
            string logicalName          = ((TextView)info.targetView).Text.ToString();

            switch (item.ItemId)
            {
            case R.id.context_modify_entry:
                int    deviceCategory = bxlConfigLoader.getDeviceCategory(logicalName);
                string dc             = null;
                switch (deviceCategory)
                {
                case BXLConfigLoader.DEVICE_CATEGORY_CASH_DRAWER:
                    dc = Resources.getStringArray(R.array.device_categories)[0];
                    break;

                case BXLConfigLoader.DEVICE_CATEGORY_MSR:
                    dc = Resources.getStringArray(R.array.device_categories)[1];
                    break;

                case BXLConfigLoader.DEVICE_CATEGORY_POS_PRINTER:
                    dc = Resources.getStringArray(R.array.device_categories)[2];
                    break;

                case BXLConfigLoader.DEVICE_CATEGORY_SMART_CARD_RW:
                    dc = Resources.getStringArray(R.array.device_categories)[3];
                    break;
                }

                int    deviceBus = bxlConfigLoader.getDeviceBus(logicalName);
                string db        = null;
                switch (deviceBus)
                {
                case BXLConfigLoader.DEVICE_BUS_BLUETOOTH:
                    db = Resources.getStringArray(R.array.device_bus)[0];
                    break;

                case BXLConfigLoader.DEVICE_BUS_ETHERNET:
                    db = Resources.getStringArray(R.array.device_bus)[1];
                    break;

                case BXLConfigLoader.DEVICE_BUS_USB:
                    db = Resources.getStringArray(R.array.device_bus)[2];
                    break;

                case BXLConfigLoader.DEVICE_BUS_WIFI:
                    db = Resources.getStringArray(R.array.device_bus)[3];
                    break;

                case BXLConfigLoader.DEVICE_BUS_WIFI_DIRECT:
                    db = Resources.getStringArray(R.array.device_bus)[4];
                    break;
                }

                EntryInfo entryInfo = new EntryInfo(logicalName, dc, bxlConfigLoader.getProductName(logicalName), db, bxlConfigLoader.getAddress(logicalName));
                EntryDialogFragment.showDialog(SupportFragmentManager, "Modify entry", entryInfo);
                return(true);

            case R.id.context_remove_entry:
                if (bxlConfigLoader.removeEntry(logicalName))
                {
                    arrayAdapter.remove(logicalName);
                }
                else
                {
                    Toast.makeText(this, "Remove failed", Toast.LENGTH_SHORT).show();
                }
                return(true);

            default:
                return(base.onContextItemSelected(item));
            }
        }