summaryrefslogtreecommitdiff
path: root/sample/src/main/java/example/zxing/CustomCaptureActivity.java
diff options
context:
space:
mode:
Diffstat (limited to 'sample/src/main/java/example/zxing/CustomCaptureActivity.java')
-rw-r--r--sample/src/main/java/example/zxing/CustomCaptureActivity.java150
1 files changed, 75 insertions, 75 deletions
diff --git a/sample/src/main/java/example/zxing/CustomCaptureActivity.java b/sample/src/main/java/example/zxing/CustomCaptureActivity.java
index 754bc3fc..37b69fed 100644
--- a/sample/src/main/java/example/zxing/CustomCaptureActivity.java
+++ b/sample/src/main/java/example/zxing/CustomCaptureActivity.java
@@ -22,98 +22,98 @@ import java.util.List;
*
*/
public class CustomCaptureActivity extends Activity {
- private static final String TAG = CustomCaptureActivity.class.getSimpleName();
- private BarcodeView barcodeView;
- private ViewfinderView viewFinder;
+ private static final String TAG = CustomCaptureActivity.class.getSimpleName();
+ private BarcodeView barcodeView;
+ private ViewfinderView viewFinder;
+
+ private BarcodeCallback callback = new BarcodeCallback() {
+ @Override
+ public void barcodeResult(BarcodeResult result) {
+ TextView text = (TextView) findViewById(R.id.zxing_barcode_status);
+ if (result.getText() != null) {
+ text.setText(result.getText());
+ }
+ //Added preview of scanned barcode
+ ImageView imageView = (ImageView) findViewById(R.id.barcodePreview);
+ imageView.setImageBitmap(result.getBitmapWithResultPoints(Color.YELLOW));
+ }
+
+ @Override
+ public void possibleResultPoints(List<ResultPoint> resultPoints) {
+ for (ResultPoint point : resultPoints) {
+ viewFinder.addPossibleResultPoint(point);
+ }
+ }
+ };
- private BarcodeCallback callback = new BarcodeCallback() {
@Override
- public void barcodeResult(BarcodeResult result) {
- TextView text = (TextView)findViewById(R.id.zxing_barcode_status);
- if(result.getText() != null) {
- text.setText(result.getText());
- }
- //Added preview of scanned barcode
- ImageView imageView = (ImageView) findViewById(R.id.barcodePreview);
- imageView.setImageBitmap(result.getBitmapWithResultPoints(Color.YELLOW));
- }
-
- @Override
- public void possibleResultPoints(List<ResultPoint> resultPoints) {
- for (ResultPoint point : resultPoints) {
- viewFinder.addPossibleResultPoint(point);
- }
- }
- };
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
- setContentView(R.layout.new_custom_layout);
+ setContentView(R.layout.new_custom_layout);
- barcodeView = (BarcodeView) findViewById(R.id.zxing_barcode_surface);
- barcodeView.decodeContinuous(callback);
+ barcodeView = (BarcodeView) findViewById(R.id.zxing_barcode_surface);
+ barcodeView.decodeContinuous(callback);
- viewFinder = (ViewfinderView)findViewById(R.id.zxing_viewfinder_view);
- viewFinder.setCameraPreview(barcodeView);
- }
+ viewFinder = (ViewfinderView) findViewById(R.id.zxing_viewfinder_view);
+ viewFinder.setCameraPreview(barcodeView);
+ }
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
- Log.d(TAG, "Configuration changed");
+ Log.d(TAG, "Configuration changed");
- }
+ }
- private void orientationChanged() {
- barcodeView.pause();
- barcodeView.resume();
- }
+ private void orientationChanged() {
+ barcodeView.pause();
+ barcodeView.resume();
+ }
- @Override
- protected void onResume() {
- super.onResume();
+ @Override
+ protected void onResume() {
+ super.onResume();
- barcodeView.resume();
- }
+ barcodeView.resume();
+ }
- @Override
- protected void onPause() {
- super.onPause();
+ @Override
+ protected void onPause() {
+ super.onPause();
- barcodeView.pause();
- }
+ barcodeView.pause();
+ }
- public void pause(View view) {
- barcodeView.pause();
- }
+ public void pause(View view) {
+ barcodeView.pause();
+ }
- public void resume(View view) {
- barcodeView.resume();
- }
+ public void resume(View view) {
+ barcodeView.resume();
+ }
- public void triggerScan(View view) {
- barcodeView.decodeSingle(callback);
- }
+ public void triggerScan(View view) {
+ barcodeView.decodeSingle(callback);
+ }
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- switch (keyCode) {
- case KeyEvent.KEYCODE_FOCUS:
- case KeyEvent.KEYCODE_CAMERA:
- // Handle these events so they don't launch the Camera app
- return true;
- // Use volume up/down to turn on light
- case KeyEvent.KEYCODE_VOLUME_DOWN:
- barcodeView.setTorch(false);
- return true;
- case KeyEvent.KEYCODE_VOLUME_UP:
- barcodeView.setTorch(true);
- return true;
+ @Override
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
+ switch (keyCode) {
+ case KeyEvent.KEYCODE_FOCUS:
+ case KeyEvent.KEYCODE_CAMERA:
+ // Handle these events so they don't launch the Camera app
+ return true;
+ // Use volume up/down to turn on light
+ case KeyEvent.KEYCODE_VOLUME_DOWN:
+ barcodeView.setTorch(false);
+ return true;
+ case KeyEvent.KEYCODE_VOLUME_UP:
+ barcodeView.setTorch(true);
+ return true;
+ }
+ return super.onKeyDown(keyCode, event);
}
- return super.onKeyDown(keyCode, event);
- }
}