Java源码示例:me.dm7.barcodescanner.core.IViewFinder
示例1
@Override
public void onCreate(Bundle state) {
super.onCreate(state);
setContentView(R.layout.activity_qrscanner);
final ViewGroup contentFrame = findViewById(R.id.content_frame);
scannerView = new ZXingScannerView(this) {
@Override
protected IViewFinder createViewFinderView(Context context) {
return new SquareViewFinderView(context);
}
};
contentFrame.addView(scannerView);
scannerView.setFormats(Collections.singletonList(BarcodeFormat.QR_CODE));
}
示例2
@Override
public void onCreate(Bundle state) {
super.onCreate(state);
setContentView(R.layout.activity_scan);
setupToolbar();
ViewGroup contentFrame = findViewById(R.id.scan_content_frame);
mScannerView = new ZXingScannerView(this) {
@Override
protected IViewFinder createViewFinderView(Context context) {
return new KaliumViewFinderView(context);
}
};
mScannerView.setAutoFocus(true);
contentFrame.addView(mScannerView);
// get title
String title = getIntent().getStringExtra(EXTRA_TITLE);
if (title != null) {
mInstructionsText = findViewById(R.id.scan_instruction_label);
if (mInstructionsText != null) {
mInstructionsText.setText(title);
}
}
// get if seed mode
seedMode = getIntent().getBooleanExtra(EXTRA_SEED_MODE, false);
mHandler = new Handler();
mRunnable = () -> {
if (mInstructionsText != null) {
mInstructionsText.setText(title);
}
};
}
示例3
@Override
public void onCreate(Bundle state) {
super.onCreate(state);
setContentView(R.layout.activity_scan);
setupToolbar();
ViewGroup contentFrame = findViewById(R.id.scan_content_frame);
mScannerView = new ZXingScannerView(this) {
@Override
protected IViewFinder createViewFinderView(Context context) {
return new NanoViewFinderView(context);
}
};
contentFrame.addView(mScannerView);
// get title
String title = getIntent().getStringExtra(EXTRA_TITLE);
if (title != null) {
TextView instructions = findViewById(R.id.scan_instruction_label);
if (instructions != null) {
instructions.setText(title);
}
}
// get seed only scan setting
isSeedOnlyScan = getIntent().getBooleanExtra(EXTRA_IS_SEED, false);
}
示例4
@Override
protected void onCreate(Bundle state) {
super.onCreate(state);
_entries = new ArrayList<>();
_scannerView = new ZXingScannerView(this) {
@Override
protected IViewFinder createViewFinderView(Context context) {
return new SquareFinderView(context);
}
};
_scannerView.setResultHandler(this);
_scannerView.setFormats(Collections.singletonList(BarcodeFormat.QR_CODE));
int camera = getRearCameraId();
if (camera == -1) {
camera = getFrontCameraId();
if (camera == -1) {
Toast.makeText(this, getString(R.string.no_cameras_available), Toast.LENGTH_LONG).show();
finish();
}
_facing = CAMERA_FACING_FRONT;
}
_scannerView.startCamera(camera);
setContentView(_scannerView);
}
示例5
@Override
protected IViewFinder createViewFinderView(Context context) {
if (mDrawLaser) {
Log.w("camera", "drawLaser set to true");
mViewFinderView = new ViewFinderView(context);
}
else {
Log.w("camera", "drawLaser set to false");
mViewFinderView = new CustomViewFinderView(context);
}
return mViewFinderView;
}
示例6
@Override
protected IViewFinder createViewFinderView(Context context) {
return new LatteViewFinderView(context);
}
示例7
protected IViewFinder createViewFinderView(Context context) {
return new ViewFinderView(context);
}