// Path: zxing-android-embedded/src/com/journeyapps/barcodescanner/Size.java
// public class Size implements Comparable<Size> {
//     public final int width;
//     public final int height;
// 
//     public Size(int width, int height) {
//         this.width = width;
//         this.height = height;
//     }
// 
//     /**
//      * Swap width and height.
//      *
//      * @return a new Size with swapped width and height
//      */
//     public Size rotate() {
//         //noinspection SuspiciousNameCombination
//         return new Size(height, width);
//     }
// 
//     /**
//      * Scale by n / d.
//      *
//      * @param n numerator
//      * @param d denominator
//      * @return the scaled size
//      */
//     public Size scale(int n, int d) {
//         return new Size(width * n / d, height * n / d);
//     }
// 
//     /**
//      * Scales the dimensions so that it fits entirely inside the parent.One of width or height will
//      * fit exactly. Aspect ratio is preserved.
//      *
//      * @param into the parent to fit into
//      * @return the scaled size
//      */
//     public Size scaleFit(Size into) {
//         if (width * into.height >= into.width * height) {
//             // match width
//             return new Size(into.width, height * into.width / width);
//         } else {
//             // match height
//             return new Size(width * into.height / height, into.height);
//         }
//     }
//     /**
//      * Scales the size so that both dimensions will be greater than or equal to the corresponding
//      * dimension of the parent. One of width or height will fit exactly. Aspect ratio is preserved.
//      *
//      * @param into the parent to fit into
//      * @return the scaled size
//      */
//     public Size scaleCrop(Size into) {
//         if (width * into.height <= into.width * height) {
//             // match width
//             return new Size(into.width, height * into.width / width);
//         } else {
//             // match height
//             return new Size(width * into.height / height, into.height);
//         }
//     }
// 
//     /**
//      * Checks if both dimensions of the other size are at least as large as this size.
//      *
//      * @param other the size to compare with
//      * @return true if this size fits into the other size
//      */
//     public boolean fitsIn(Size other) {
//         return width <= other.width && height <= other.height;
//     }
// 
//     /**
//      * Default sort order is ascending by size.
//      */
//     @Override
//     public int compareTo(@NonNull Size other) {
//         int aPixels = this.height * this.width;
//         int bPixels = other.height * other.width;
//         if (bPixels < aPixels) {
//             return 1;
//         }
//         if (bPixels > aPixels) {
//             return -1;
//         }
//         return 0;
//     }
// 
//     public String toString() {
//         return width + "x" + height;
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         Size size = (Size) o;
// 
//         return width == size.width && height == size.height;
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = width;
//         result = 31 * result + height;
//         return result;
//     }
// }


import android.content.Context;
import android.os.Handler;
import android.util.Log;
import android.view.SurfaceHolder;
import com.google.zxing.client.android.R;
import com.journeyapps.barcodescanner.Size;
import com.journeyapps.barcodescanner.Util;
            try {
                Log.d(TAG, "Opening camera");
                cameraManager.open();
            } catch (Exception e) {
                notifyError(e);
                Log.e(TAG, "Failed to open camera", e);
            }
        }
    };

    private Runnable configure = new Runnable() {
        @Override
        public void run() {
            try {
                Log.d(TAG, "Configuring camera");
                cameraManager.configure();
                if (readyHandler != null) {
                    readyHandler.obtainMessage(R.id.zxing_prewiew_size_ready, getPreviewSize()).sendToTarget();
                }
            } catch (Exception e) {
                notifyError(e);
                Log.e(TAG, "Failed to configure camera", e);
            }
        }
    };

    private Runnable previewStarter = new Runnable() {
        @Override
        public void run() {
            try {
// Path: zxing-android-embedded/src/com/journeyapps/barcodescanner/Size.java
// public class Size implements Comparable<Size> {
//     public final int width;
//     public final int height;
// 
//     public Size(int width, int height) {
//         this.width = width;
//         this.height = height;
//     }
// 
//     /**
//      * Swap width and height.
//      *
//      * @return a new Size with swapped width and height
//      */
//     public Size rotate() {
//         //noinspection SuspiciousNameCombination
//         return new Size(height, width);
//     }
// 
//     /**
//      * Scale by n / d.
//      *
//      * @param n numerator
//      * @param d denominator
//      * @return the scaled size
//      */
//     public Size scale(int n, int d) {
//         return new Size(width * n / d, height * n / d);
//     }
// 
//     /**
//      * Scales the dimensions so that it fits entirely inside the parent.One of width or height will
//      * fit exactly. Aspect ratio is preserved.
//      *
//      * @param into the parent to fit into
//      * @return the scaled size
//      */
//     public Size scaleFit(Size into) {
//         if (width * into.height >= into.width * height) {
//             // match width
//             return new Size(into.width, height * into.width / width);
//         } else {
//             // match height
//             return new Size(width * into.height / height, into.height);
//         }
//     }
//     /**
//      * Scales the size so that both dimensions will be greater than or equal to the corresponding
//      * dimension of the parent. One of width or height will fit exactly. Aspect ratio is preserved.
//      *
//      * @param into the parent to fit into
//      * @return the scaled size
//      */
//     public Size scaleCrop(Size into) {
//         if (width * into.height <= into.width * height) {
//             // match width
//             return new Size(into.width, height * into.width / width);
//         } else {
//             // match height
//             return new Size(width * into.height / height, into.height);
//         }
//     }
// 
//     /**
//      * Checks if both dimensions of the other size are at least as large as this size.
//      *
//      * @param other the size to compare with
//      * @return true if this size fits into the other size
//      */
//     public boolean fitsIn(Size other) {
//         return width <= other.width && height <= other.height;
//     }
// 
//     /**
//      * Default sort order is ascending by size.
//      */
//     @Override
//     public int compareTo(@NonNull Size other) {
//         int aPixels = this.height * this.width;
//         int bPixels = other.height * other.width;
//         if (bPixels < aPixels) {
//             return 1;
//         }
//         if (bPixels > aPixels) {
//             return -1;
//         }
//         return 0;
//     }
// 
//     public String toString() {
//         return width + "x" + height;
//     }
// 
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         Size size = (Size) o;
// 
//         return width == size.width && height == size.height;
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = width;
//         result = 31 * result + height;
//         return result;
//     }
// }


// Path: zxing-android-embedded/src/com/journeyapps/barcodescanner/camera/CameraInstance.java
import android.content.Context;
import android.os.Handler;
import android.util.Log;
import android.view.SurfaceHolder;
import com.google.zxing.client.android.R;
import com.journeyapps.barcodescanner.Size;
import com.journeyapps.barcodescanner.Util;

            try {
                Log.d(TAG, "Opening camera");
                cameraManager.open();
            } catch (Exception e) {
                notifyError(e);
                Log.e(TAG, "Failed to open camera", e);
            }
        }
    };

    private Runnable configure = new Runnable() {
        @Override
        public void run() {
            try {
                Log.d(TAG, "Configuring camera");
                cameraManager.configure();
                if (readyHandler != null) {
                    readyHandler.obtainMessage(R.id.zxing_prewiew_size_ready, getPreviewSize()).sendToTarget();
                }
            } catch (Exception e) {
                notifyError(e);
                Log.e(TAG, "Failed to configure camera", e);
            }
        }
    };

    private Runnable previewStarter = new Runnable() {
        @Override
        public void run() {
            try {
                Log.d(TAG, "Starting preview");