List of usage examples for android.util Log isLoggable
public static native boolean isLoggable(String tag, int level);
From source file:Main.java
public static void LOGV(final String tag, String message, Throwable cause) { if (LOGGING_ENABLED) { if (Log.isLoggable(tag, Log.VERBOSE)) { Log.v(tag, message, cause);//w ww. ja v a 2 s .c om } } }
From source file:Main.java
public static void LOGD(final String tag, String message, Throwable cause) { //noinspection PointlessBooleanExpression,ConstantConditions if (debug || Log.isLoggable(tag, Log.DEBUG)) { Log.d(tag, message, cause);/*from w w w.j av a2 s. c o m*/ } }
From source file:Main.java
public static void LOGV(final String tag, String message, Throwable cause) { //noinspection PointlessBooleanExpression,ConstantConditions if (debug && Log.isLoggable(tag, Log.VERBOSE)) { Log.v(tag, message, cause);/*from www .ja v a 2s . c om*/ } }
From source file:Main.java
/** * This is an expensive operation that copies the image in place with the pixels rotated. * If possible rather use getOrientationMatrix, and set that as the imageMatrix on an ImageView. * * @param imageToOrient Image Bitmap to orient. * @param degreesToRotate number of degrees to rotate the image by. If zero the original image is returned unmodified. * @return The oriented bitmap. May be the imageToOrient without modification, or a new Bitmap. *//* ww w .ja va 2 s.co m*/ public static Bitmap rotateImage(Bitmap imageToOrient, int degreesToRotate) { try { if (degreesToRotate != 0) { Matrix matrix = new Matrix(); matrix.setRotate(degreesToRotate); imageToOrient = Bitmap.createBitmap(imageToOrient, 0, 0, imageToOrient.getWidth(), imageToOrient.getHeight(), matrix, true); } } catch (Exception e) { if (Log.isLoggable(TAG, Log.ERROR)) { Log.e(TAG, "Exception when trying to orient image", e); } e.printStackTrace(); } return imageToOrient; }
From source file:Main.java
/** * Returns a matrix with rotation set based on Exif orientation tag. * If the orientation is undefined or 0 null is returned. * * @param pathToOriginal Path to original image file that may have exif data. * @return A rotation in degrees based on exif orientation *//* w w w. j a v a2 s.c om*/ public static int getOrientation(String pathToOriginal) { int degreesToRotate = 0; try { ExifInterface exif = new ExifInterface(pathToOriginal); int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED); if (orientation == ExifInterface.ORIENTATION_ROTATE_90) { degreesToRotate = 90; } else if (orientation == ExifInterface.ORIENTATION_ROTATE_180) { degreesToRotate = 180; } else if (orientation == ExifInterface.ORIENTATION_ROTATE_270) { degreesToRotate = 270; } } catch (Exception e) { if (Log.isLoggable(TAG, Log.ERROR)) { Log.e(TAG, "Unable to get orientation for image with path=" + pathToOriginal, e); } } return degreesToRotate; }
From source file:Main.java
/** * This is an expensive operation that copies the image in place with the pixels rotated. If * possible rather use getOrientationMatrix, and put that as the imageMatrix on an ImageView. * * @param imageToOrient Image Bitmap to orient. * @param degreesToRotate number of degrees to rotate the image by. If zero the original image is * returned unmodified. * @return The oriented bitmap. May be the imageToOrient without modification, or a new Bitmap. *///from w w w . j a va2 s . c om public static Bitmap rotateImage(@NonNull Bitmap imageToOrient, int degreesToRotate) { Bitmap result = imageToOrient; try { if (degreesToRotate != 0) { Matrix matrix = new Matrix(); matrix.setRotate(degreesToRotate); result = Bitmap.createBitmap(imageToOrient, 0, 0, imageToOrient.getWidth(), imageToOrient.getHeight(), matrix, true /*filter*/); } } catch (Exception e) { if (Log.isLoggable(TAG, Log.ERROR)) { Log.e(TAG, "Exception when trying to orient image", e); } } return result; }
From source file:com.android.volley.VolleyLog.java
/** * Customize the log tag for your application, so that other apps * using Volley don't mix their logs with yours. * <br />/* w w w . j a va 2 s .c o m*/ * Enable the log property for your tag before starting your app: * <br /> * {@code adb shell setprop log.tag.<tag>} */ public static void setTag(String tag) { d("Changing log tag to %s", tag); TAG = tag; // Reinitialize the DEBUG "constant" DEBUG = Log.isLoggable(TAG, Log.VERBOSE); }
From source file:Main.java
public static Point findBestPreviewSizeValue(Camera.Parameters parameters, Point screenResolution) { List<Camera.Size> rawSupportedSizes = parameters.getSupportedPreviewSizes(); if (rawSupportedSizes == null) { Log.w(TAG, "Device returned no supported preview sizes; using default"); Camera.Size defaultSize = parameters.getPreviewSize(); if (defaultSize == null) { throw new IllegalStateException("Parameters contained no preview size!"); }//from w w w .j ava2 s .c o m return new Point(defaultSize.width, defaultSize.height); } if (Log.isLoggable(TAG, Log.INFO)) { StringBuilder previewSizesString = new StringBuilder(); for (Camera.Size size : rawSupportedSizes) { previewSizesString.append(size.width).append('x').append(size.height).append(' '); } Log.i(TAG, "Supported preview sizes: " + previewSizesString); } double screenAspectRatio = screenResolution.x / (double) screenResolution.y; // Find a suitable size, with max resolution int maxResolution = 0; Camera.Size maxResPreviewSize = null; for (Camera.Size size : rawSupportedSizes) { int realWidth = size.width; int realHeight = size.height; int resolution = realWidth * realHeight; if (resolution < MIN_PREVIEW_PIXELS) { continue; } boolean isCandidatePortrait = realWidth < realHeight; int maybeFlippedWidth = isCandidatePortrait ? realHeight : realWidth; int maybeFlippedHeight = isCandidatePortrait ? realWidth : realHeight; double aspectRatio = maybeFlippedWidth / (double) maybeFlippedHeight; double distortion = Math.abs(aspectRatio - screenAspectRatio); if (distortion > MAX_ASPECT_DISTORTION) { continue; } if (maybeFlippedWidth == screenResolution.x && maybeFlippedHeight == screenResolution.y) { Point exactPoint = new Point(realWidth, realHeight); Log.i(TAG, "Found preview size exactly matching screen size: " + exactPoint); return exactPoint; } // Resolution is suitable; record the one with max resolution if (resolution > maxResolution) { maxResolution = resolution; maxResPreviewSize = size; } } // If no exact match, use largest preview size. This was not a great idea on older devices because // of the additional computation needed. We're likely to get here on newer Android 4+ devices, where // the CPU is much more powerful. if (maxResPreviewSize != null) { Point largestSize = new Point(maxResPreviewSize.width, maxResPreviewSize.height); Log.i(TAG, "Using largest suitable preview size: " + largestSize); return largestSize; } // If there is nothing at all suitable, return current preview size Camera.Size defaultPreview = parameters.getPreviewSize(); if (defaultPreview == null) { throw new IllegalStateException("Parameters contained no preview size!"); } Point defaultSize = new Point(defaultPreview.width, defaultPreview.height); Log.i(TAG, "No suitable preview sizes, using default: " + defaultSize); return defaultSize; }
From source file:Main.java
public static Point findBestPreviewSizeValue(Camera.Parameters parameters, Point screenResolution) { List<Camera.Size> rawSupportedSizes = parameters.getSupportedPreviewSizes(); if (rawSupportedSizes == null) { Log.w(TAG, "Device returned no supported preview sizes; using default"); Camera.Size defaultSize = parameters.getPreviewSize(); if (defaultSize == null) { throw new IllegalStateException("Parameters contained no preview size!"); }//from ww w. j av a2 s. c om return new Point(defaultSize.width, defaultSize.height); } // Sort by size, descending List<Camera.Size> supportedPreviewSizes = new ArrayList<Camera.Size>(rawSupportedSizes); Collections.sort(supportedPreviewSizes, new Comparator<Camera.Size>() { @Override public int compare(Camera.Size a, Camera.Size b) { int aPixels = a.height * a.width; int bPixels = b.height * b.width; if (bPixels < aPixels) { return -1; } if (bPixels > aPixels) { return 1; } return 0; } }); if (Log.isLoggable(TAG, Log.INFO)) { StringBuilder previewSizesString = new StringBuilder(); for (Camera.Size supportedPreviewSize : supportedPreviewSizes) { previewSizesString.append(supportedPreviewSize.width).append('x') .append(supportedPreviewSize.height).append(' '); } Log.i(TAG, "Supported preview sizes: " + previewSizesString); } double screenAspectRatio = (double) screenResolution.x / (double) screenResolution.y; // Remove sizes that are unsuitable Iterator<Camera.Size> it = supportedPreviewSizes.iterator(); while (it.hasNext()) { Camera.Size supportedPreviewSize = it.next(); int realWidth = supportedPreviewSize.width; int realHeight = supportedPreviewSize.height; if (realWidth * realHeight < MIN_PREVIEW_PIXELS) { it.remove(); continue; } boolean isCandidatePortrait = realWidth < realHeight; int maybeFlippedWidth = isCandidatePortrait ? realHeight : realWidth; int maybeFlippedHeight = isCandidatePortrait ? realWidth : realHeight; double aspectRatio = (double) maybeFlippedWidth / (double) maybeFlippedHeight; double distortion = Math.abs(aspectRatio - screenAspectRatio); if (distortion > MAX_ASPECT_DISTORTION) { it.remove(); continue; } if (maybeFlippedWidth == screenResolution.x && maybeFlippedHeight == screenResolution.y) { Point exactPoint = new Point(realWidth, realHeight); Log.i(TAG, "Found preview size exactly matching screen size: " + exactPoint); return exactPoint; } } // If no exact match, use largest preview size. This was not a great // idea on older devices because // of the additional computation needed. We're likely to get here on // newer Android 4+ devices, where // the CPU is much more powerful. if (!supportedPreviewSizes.isEmpty()) { Camera.Size largestPreview = supportedPreviewSizes.get(0); Point largestSize = new Point(largestPreview.width, largestPreview.height); Log.i(TAG, "Using largest suitable preview size: " + largestSize); return largestSize; } // If there is nothing at all suitable, return current preview size Camera.Size defaultPreview = parameters.getPreviewSize(); if (defaultPreview == null) { throw new IllegalStateException("Parameters contained no preview size!"); } Point defaultSize = new Point(defaultPreview.width, defaultPreview.height); Log.i(TAG, "No suitable preview sizes, using default: " + defaultSize); return defaultSize; }
From source file:com.joptimizer.solvers.DiagonalKKTSolver.java
/** * Returns two vectors v and w.//from ww w. j a va2s.c o m */ @Override public double[][] solve() throws Exception { RealVector v = null; RealVector w = null; if (Log.isLoggable(MainActivity.JOPTIMIZER_LOGTAG, Log.DEBUG)) { Log.d(MainActivity.JOPTIMIZER_LOGTAG, "H: " + ArrayUtils.toString(H.getData())); Log.d(MainActivity.JOPTIMIZER_LOGTAG, "g: " + ArrayUtils.toString(g.toArray())); } v = new ArrayRealVector(g.getDimension()); for (int i = 0; i < v.getDimension(); i++) { v.setEntry(i, -g.getEntry(i) / H.getEntry(i, i)); } // solution checking if (this.checkKKTSolutionAccuracy && !this.checkKKTSolutionAccuracy(v, w)) { Log.e(MainActivity.JOPTIMIZER_LOGTAG, "KKT solution failed"); throw new Exception("KKT solution failed"); } double[][] ret = new double[2][]; ret[0] = v.toArray(); ret[1] = (w != null) ? w.toArray() : null; return ret; }