Example #1
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            // Handle presses on the action bar items
            DialogFragment fragment;

            switch (item.ItemId)
            {
            case Resource.Id.menu_flash:
                Flash = !Flash;
                if (Flash)
                {
                    item.SetTitle(Resource.String.flash_on);
                }
                else
                {
                    item.SetTitle(Resource.String.flash_off);
                }
                ScannerView.Flash = Flash;
                return(true);

            case Resource.Id.menu_auto_focus:
                AutoFocus = !AutoFocus;
                if (AutoFocus)
                {
                    item.SetTitle(Resource.String.auto_focus_on);
                }
                else
                {
                    item.SetTitle(Resource.String.auto_focus_off);
                }
                ScannerView.SetAutoFocus(AutoFocus);
                return(true);

            case Resource.Id.menu_formats:
                fragment = ZXingFormatSelectorDialogFragment.NewInstance(this, SelectedIndices);
                fragment.Show(SupportFragmentManager, "format_selector");
                return(true);

            case Resource.Id.menu_camera_selector:
                ScannerView.StopCamera();
                fragment = CameraSelectorDialogFragment.NewInstance(this, CameraId);
                fragment.Show(SupportFragmentManager, "camera_selector");
                return(true);

            case Android.Resource.Id.Home:
                OnBackPressed();
                return(true);

            default:
                return(base.OnOptionsItemSelected(item));
            }
        }
        public static ZXingFormatSelectorDialogFragment NewInstance(IFormatSelectorDialogListener listener,
                                                                    IList <Integer> selectedIndices)
        {
            ZXingFormatSelectorDialogFragment fragment = new ZXingFormatSelectorDialogFragment();

            if (selectedIndices == null)
            {
                selectedIndices = new List <Integer>();
            }
            fragment.SelectedIndices = new List <Integer>(selectedIndices);
            fragment.Listener        = listener;
            return(fragment);
        }