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();
}
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);
}
Aggregations