Search in sources :

Example 1 with BarcodeFormat

use of me.dm7.barcodescanner.zbar.BarcodeFormat in project barcodescanner by dm77.

the class FormatSelectorDialogFragment method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (mSelectedIndices == null || mListener == null) {
        dismiss();
        return null;
    }
    String[] formats = new String[BarcodeFormat.ALL_FORMATS.size()];
    boolean[] checkedIndices = new boolean[BarcodeFormat.ALL_FORMATS.size()];
    int i = 0;
    for (BarcodeFormat format : BarcodeFormat.ALL_FORMATS) {
        formats[i] = format.getName();
        if (mSelectedIndices.contains(i)) {
            checkedIndices[i] = true;
        } else {
            checkedIndices[i] = false;
        }
        i++;
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    // Set the dialog title
    builder.setTitle(R.string.choose_formats).setMultiChoiceItems(formats, checkedIndices, new DialogInterface.OnMultiChoiceClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which, boolean isChecked) {
            if (isChecked) {
                // If the user checked the item, add it to the selected items
                mSelectedIndices.add(which);
            } else if (mSelectedIndices.contains(which)) {
                // Else, if the item is already in the array, remove it
                mSelectedIndices.remove(mSelectedIndices.indexOf(which));
            }
        }
    }).setPositiveButton(R.string.ok_button, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int id) {
            // or return them to the component that opened the dialog
            if (mListener != null) {
                mListener.onFormatsSaved(mSelectedIndices);
            }
        }
    }).setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int id) {
        }
    });
    return builder.create();
}
Also used : AlertDialog(android.app.AlertDialog) DialogInterface(android.content.DialogInterface) BarcodeFormat(me.dm7.barcodescanner.zbar.BarcodeFormat)

Example 2 with BarcodeFormat

use of me.dm7.barcodescanner.zbar.BarcodeFormat in project TumCampusApp by TCA-Team.

the class JoinRoomScanActivity method onCreate.

@Override
public void onCreate(Bundle state) {
    super.onCreate(state);
    // Programmatically initialize the scanner view
    mScannerView = new ZXingScannerView(this);
    List<BarcodeFormat> formats = ImmutableList.of(BarcodeFormat.QR_CODE);
    mScannerView.setFormats(formats);
    // Set the scanner inside the framelayout view as the content view
    setContentView(mScannerView);
}
Also used : BarcodeFormat(com.google.zxing.BarcodeFormat) ZXingScannerView(me.dm7.barcodescanner.zxing.ZXingScannerView)

Aggregations

AlertDialog (android.app.AlertDialog)1 DialogInterface (android.content.DialogInterface)1 BarcodeFormat (com.google.zxing.BarcodeFormat)1 BarcodeFormat (me.dm7.barcodescanner.zbar.BarcodeFormat)1 ZXingScannerView (me.dm7.barcodescanner.zxing.ZXingScannerView)1