@@ -80,7 +80,6 @@ public class BarcodeScannerView extends FrameLayout implements TextureView.Surfa
8080 private boolean startRequested ;
8181
8282 private List <BarcodeFormat > supportedBarcodeFormats = new ArrayList <>();
83- private boolean manualAutoFocus ;
8483 private int surfaceWidth ;
8584 private int surfaceHeight ;
8685 private TextureView textureView ;
@@ -367,10 +366,6 @@ private void startIfRequested() {
367366 camera .setPreviewCallbackWithBuffer (this );
368367 camera .addCallbackBuffer (backBuffer );
369368
370- if (manualAutoFocus ) {
371- scheduleAutoFocus ();
372- }
373-
374369 detectionRect .left = 0 ;
375370 detectionRect .top = 0 ;
376371 detectionRect .right = previewSize .width ;
@@ -389,6 +384,7 @@ public void run() {
389384 }
390385 });
391386
387+ scheduleAutoFocus ();
392388 showError (false );
393389
394390 if (isPaused ) {
@@ -430,10 +426,7 @@ private void chooseFrameRate(Camera.Parameters parameters) {
430426 private void chooseFocusMode (Camera .Parameters parameters ) {
431427 List <String > supportedFocusModes = parameters .getSupportedFocusModes ();
432428 if (supportedFocusModes != null ) {
433- if (supportedFocusModes .contains (Camera .Parameters .FOCUS_MODE_CONTINUOUS_VIDEO )) {
434- parameters .setFocusMode (Camera .Parameters .FOCUS_MODE_CONTINUOUS_VIDEO );
435- } else if (supportedFocusModes .contains (Camera .Parameters .FOCUS_MODE_AUTO )) {
436- manualAutoFocus = true ;
429+ if (supportedFocusModes .contains (Camera .Parameters .FOCUS_MODE_AUTO )) {
437430 parameters .setFocusMode (Camera .Parameters .FOCUS_MODE_AUTO );
438431 }
439432 }
@@ -507,18 +500,15 @@ private void scheduleAutoFocus() {
507500 public void run () {
508501 if (running ) {
509502 try {
510- camera .autoFocus (new Camera .AutoFocusCallback () {
511- @ Override
512- public void onAutoFocus (boolean success , Camera camera ) {
513- scheduleAutoFocus ();
514- }
515- });
503+ camera .autoFocus (null );
516504 } catch (RuntimeException e ) {
517- // ignore, happens mostly when calling autoFocus while its still focussing
505+ //ignore, happens mostly when calling autoFocus while its still focussing
518506 }
507+
508+ scheduleAutoFocus ();
519509 }
520510 }
521- }, 2000 );
511+ }, 1000 );
522512 }
523513
524514 private void setupZXing () {
@@ -654,7 +644,6 @@ public void onPreviewFrame(byte[] data, final Camera camera) {
654644 nextDetectionTimeMs = SystemClock .elapsedRealtime () + detectionDelayMs ;
655645
656646 barcodeProcessingHandler .post (new Runnable () {
657- @ SuppressWarnings ("SuspiciousNameCombination" )
658647 @ Override
659648 public void run () {
660649 if (!isAttachedToWindow || !decodeEnabled ) {
@@ -976,10 +965,10 @@ private Camera.Size getOptimalPreviewSize() {
976965 Camera .Size optimalSizeForWidth = null ;
977966 Camera .Size optimalSizeForHeight = null ;
978967
979- // we are using 1280x720 as our base resolution, as its available on most devices and provides
968+ // we are using 1920x1080 as our base resolution, as its available on most devices and provides
980969 // a good balance between quality and performance
981- int targetWidth = 1280 ;
982- int targetHeight = 720 ;
970+ int targetWidth = 1920 ;
971+ int targetHeight = 1080 ;
983972
984973 float minDiffX = Float .MAX_VALUE ;
985974 float minDiffY = Float .MIN_VALUE ;
0 commit comments