Minor changes from code inspection results
[zxing.git] / android / src / com / google / zxing / client / android / camera / CameraManager.java
index 1acf00e..53c11ba 100755 (executable)
@@ -50,6 +50,18 @@ public final class CameraManager {
 
   private static CameraManager cameraManager;
 
+  static final int SDK_INT; // Later we can use Build.VERSION.SDK_INT
+  static {
+    int sdkInt;
+    try {
+      sdkInt = Integer.parseInt(Build.VERSION.SDK);
+    } catch (NumberFormatException nfe) {
+      // Just to be safe
+      sdkInt = 10000;
+    }
+    SDK_INT = sdkInt;
+  }
+
   private final Context context;
   private final CameraConfigurationManager configManager;
   private Camera camera;
@@ -95,10 +107,10 @@ public final class CameraManager {
     // Camera.setPreviewCallback() on 1.5 and earlier. For Donut and later, we need to use
     // the more efficient one shot callback, as the older one can swamp the system and cause it
     // to run out of memory. We can't use SDK_INT because it was introduced in the Donut SDK.
-    useOneShotPreviewCallback = Integer.parseInt(Build.VERSION.SDK) > Build.VERSION_CODES.CUPCAKE;
+    useOneShotPreviewCallback = SDK_INT > Build.VERSION_CODES.CUPCAKE;
 
     previewCallback = new PreviewCallback(configManager, useOneShotPreviewCallback);
-    autoFocusCallback = new AutoFocusCallback(configManager);
+    autoFocusCallback = new AutoFocusCallback();
   }
 
   /**
@@ -192,7 +204,7 @@ public final class CameraManager {
   public void requestAutoFocus(Handler handler, int message) {
     if (camera != null && previewing) {
       autoFocusCallback.setHandler(handler, message);
-      Log.v(TAG, "Requesting auto-focus callback");
+      //Log.d(TAG, "Requesting auto-focus callback");
       camera.autoFocus(autoFocusCallback);
     }
   }
@@ -225,7 +237,7 @@ public final class CameraManager {
       int leftOffset = (screenResolution.x - width) / 2;
       int topOffset = (screenResolution.y - height) / 2;
       framingRect = new Rect(leftOffset, topOffset, leftOffset + width, topOffset + height);
-      Log.v(TAG, "Calculated framing rect: " + framingRect);
+      Log.d(TAG, "Calculated framing rect: " + framingRect);
     }
     return framingRect;
   }