Java 类com.google.zxing.activity.CaptureActivity 实例源码

项目:MyFire    文件:ScanMainActivity.java   
@Override
public void onClick(View v) {
    final int id = v.getId();
    if(id==R.id.btn1){
        String content = et.getText().toString().trim();
        try {
            if (!TextUtils.isEmpty(content)) {
                Bitmap bitmap = Create2DCode(content);
                iv.setImageBitmap(bitmap);
            } else {
                Toast.makeText(ScanMainActivity.this, "请输入要生成的字符串", Toast.LENGTH_SHORT).show();
            }
        } catch (WriterException e) {
            e.printStackTrace();
        }
    }else if(id==R.id.btn2){
        startActivity(new Intent(ScanMainActivity.this, CaptureActivity.class));
    }

}
项目:Ydkd    文件:ScanMainActivity.java   
@Override
public void onClick(View v) {
    final int id = v.getId();
    if(id==R.id.btn1){
        String content = et.getText().toString().trim();
        try {
            if (!TextUtils.isEmpty(content)) {
                Bitmap bitmap = Create2DCode(content);
                iv.setImageBitmap(bitmap);
            } else {
                Toast.makeText(ScanMainActivity.this, "请输入要生成的字符串", Toast.LENGTH_SHORT).show();
            }
        } catch (WriterException e) {
            e.printStackTrace();
        }
    }else if(id==R.id.btn2){
        startActivity(new Intent(ScanMainActivity.this, CaptureActivity.class));
    }

}
项目:CodeScaner    文件:MainActivity.java   
private void getPermission() {
    //第二个参数是需要申请的权限
    if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
        //权限还没有授予,需要在这里写申请权限的代码
        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA}, 2);
    } else {
        //权限已经被授予,在这里直接写要执行的相应方法即可
        startActivityForResult(new Intent(MainActivity.this, CaptureActivity.class), REQ_QRCODE);
    }
}
项目:CodeScaner    文件:MainActivity.java   
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    if (requestCode == 2) {
        if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
            startActivityForResult(new Intent(MainActivity.this, CaptureActivity.class), REQ_QRCODE);
        } else {
            // Permission Denied
            Toast.makeText(MainActivity.this,"Permission Denied",Toast.LENGTH_SHORT).show();
        }
    }
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
项目:CodeScaner    文件:MainActivity.java   
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK && requestCode == REQ_QRCODE && data != null) {
        byte[] result = data.getByteArrayExtra(CaptureActivity.KEY_RESULT);
        if (result == null || result.length == 0) return;
        String payCode = new String(result);
        tvReuslt.setText(payCode);
    }
}
项目:MyFire    文件:CaptureActivityHandler.java   
public CaptureActivityHandler(CaptureActivity activity, CameraManager cameraManager, int decodeMode) {
    this.activity = activity;
    decodeThread = new DecodeThread(activity, decodeMode);
    decodeThread.start();
    state = State.SUCCESS;

    // Start ourselves capturing previews and decoding.
    this.cameraManager = cameraManager;
    cameraManager.startPreview();
    restartPreviewAndDecode();
}
项目:MyFire    文件:DecodeThread.java   
public DecodeThread(CaptureActivity 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);
    }
项目:Ydkd    文件:CaptureActivityHandler.java   
public CaptureActivityHandler(CaptureActivity activity, CameraManager cameraManager, int decodeMode) {
    this.activity = activity;
    decodeThread = new DecodeThread(activity, decodeMode);
    decodeThread.start();
    state = State.SUCCESS;

    // Start ourselves capturing previews and decoding.
    this.cameraManager = cameraManager;
    cameraManager.startPreview();
    restartPreviewAndDecode();
}
项目:Ydkd    文件:DecodeThread.java   
public DecodeThread(CaptureActivity 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);
    }
项目:MyFire    文件:DecodeHandler.java   
public DecodeHandler(CaptureActivity activity, Map<DecodeHintType, Object> hints) {
    multiFormatReader = new MultiFormatReader();
    multiFormatReader.setHints(hints);
    this.activity = activity;
}
项目:Ydkd    文件:DecodeHandler.java   
public DecodeHandler(CaptureActivity activity, Map<DecodeHintType, Object> hints) {
    multiFormatReader = new MultiFormatReader();
    multiFormatReader.setHints(hints);
    this.activity = activity;
}