コード例 #1
0
  public DecodeThread(ZXingCaptureActivity activity, int decodeMode) {

    this.activity = activity;
    handlerInitLatch = new CountDownLatch(1);

    hints = new EnumMap<DecodeHintType, Object>(DecodeHintType.class);

    Collection<BarcodeFormat> decodeFormats = new ArrayList<BarcodeFormat>();
    decodeFormats.addAll(EnumSet.of(BarcodeFormat.AZTEC));
    decodeFormats.addAll(EnumSet.of(BarcodeFormat.PDF_417));

    switch (decodeMode) {
      case BARCODE_MODE:
        decodeFormats.addAll(DecodeFormatManager.getBarCodeFormats());
        break;

      case QRCODE_MODE:
        decodeFormats.addAll(DecodeFormatManager.getQrCodeFormats());
        break;

      case ALL_MODE:
        decodeFormats.addAll(DecodeFormatManager.getBarCodeFormats());
        decodeFormats.addAll(DecodeFormatManager.getQrCodeFormats());
        break;

      default:
        break;
    }

    hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats);
  }
コード例 #2
0
 public DecoderBitmap(Context context) {
   multiFormatReader = new MultiFormatReader();
   Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>(2);
   Vector<BarcodeFormat> decodeFormats = new Vector<BarcodeFormat>();
   if (decodeFormats == null || decodeFormats.isEmpty()) {
     decodeFormats = new Vector<BarcodeFormat>();
     decodeFormats.addAll(DecodeFormatManager.getBarCodeFormats());
     decodeFormats.addAll(DecodeFormatManager.getQrCodeFormats());
     decodeFormats.addAll(EnumSet.of(BarcodeFormat.AZTEC));
     decodeFormats.addAll(EnumSet.of(BarcodeFormat.PDF_417));
   }
   hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats);
   hints.put(DecodeHintType.CHARACTER_SET, "UTF8");
   multiFormatReader.setHints(hints);
 }