diff options
| author | Ralf Kistner <ralf@embarkmobile.com> | 2015-05-03 19:20:28 +0300 |
|---|---|---|
| committer | Ralf Kistner <ralf@embarkmobile.com> | 2015-05-03 19:20:28 +0300 |
| commit | 27dbe6a711f1e0f8897ccf2c2e9b3de55e7678bf (patch) | |
| tree | 12ec8dd08685697b63eb1563810a54868416c545 /sample/src/main/java/example/zxing/CustomCaptureActivity.java | |
| parent | c74750c3e6a3937408fb54cbfcd7d069f5e056e3 (diff) | |
| download | zxing-android-embedded-27dbe6a711f1e0f8897ccf2c2e9b3de55e7678bf.tar.xz | |
Refactor ContinuousCaptureActivity to use the compound barcode view.
Diffstat (limited to 'sample/src/main/java/example/zxing/CustomCaptureActivity.java')
| -rw-r--r-- | sample/src/main/java/example/zxing/CustomCaptureActivity.java | 119 |
1 files changed, 0 insertions, 119 deletions
diff --git a/sample/src/main/java/example/zxing/CustomCaptureActivity.java b/sample/src/main/java/example/zxing/CustomCaptureActivity.java deleted file mode 100644 index 37b69fed..00000000 --- a/sample/src/main/java/example/zxing/CustomCaptureActivity.java +++ /dev/null @@ -1,119 +0,0 @@ -package example.zxing; - -import android.app.Activity; -import android.content.res.Configuration; -import android.graphics.Color; -import android.os.Bundle; -import android.util.Log; -import android.view.KeyEvent; -import android.view.View; -import android.widget.ImageView; -import android.widget.TextView; - -import com.google.zxing.ResultPoint; -import com.journeyapps.barcodescanner.BarcodeCallback; -import com.journeyapps.barcodescanner.BarcodeResult; -import com.journeyapps.barcodescanner.BarcodeView; -import com.journeyapps.barcodescanner.ViewfinderView; - -import java.util.List; - -/** - * - */ -public class CustomCaptureActivity extends Activity { - 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); - } - } - }; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - setContentView(R.layout.new_custom_layout); - - barcodeView = (BarcodeView) findViewById(R.id.zxing_barcode_surface); - barcodeView.decodeContinuous(callback); - - viewFinder = (ViewfinderView) findViewById(R.id.zxing_viewfinder_view); - viewFinder.setCameraPreview(barcodeView); - } - - @Override - public void onConfigurationChanged(Configuration newConfig) { - super.onConfigurationChanged(newConfig); - - Log.d(TAG, "Configuration changed"); - - } - - private void orientationChanged() { - barcodeView.pause(); - barcodeView.resume(); - } - - @Override - protected void onResume() { - super.onResume(); - - barcodeView.resume(); - } - - @Override - protected void onPause() { - super.onPause(); - - barcodeView.pause(); - } - - public void pause(View view) { - barcodeView.pause(); - } - - public void resume(View view) { - barcodeView.resume(); - } - - 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; - } - return super.onKeyDown(keyCode, event); - } -} |
