List of usage examples for android.util Log INFO
int INFO
To view the source code for android.util Log INFO.
Click Source Link
From source file:Main.java
private static void log(String tag, int level, String msg, Throwable tr) { if (isLog) {// ww w . j ava 2 s. c om switch (level) { case Log.VERBOSE: if (tr == null) { Log.v(tag, msg); } else { Log.v(tag, msg, tr); } break; case Log.INFO: if (tr == null) { Log.i(tag, msg); } else { Log.i(tag, msg, tr); } break; case Log.DEBUG: if (tr == null) { Log.d(tag, msg); } else { Log.d(tag, msg, tr); } break; case Log.WARN: if (tr == null) { Log.w(tag, msg); } else { Log.w(tag, msg, tr); } break; case Log.ERROR: if (tr == null) { Log.e(tag, msg, tr); } else { Log.e(tag, msg, tr); } break; } } }
From source file:Main.java
public static void i(String tag, Object... messages) { log(tag, Log.INFO, null, messages); }
From source file:Main.java
public static int i(String tag, String msg) { return println(Log.INFO, tag, msg); }
From source file:Main.java
/** * @param message Message to display * @param type [Log.Error, Log.Warn, ...] * @param shouldPrint value that comes from Preferences which allows the user to decide if debug info should be printed to logcat. Error info will ALWAYS be displayed despite this value *//*from w w w . ja va 2s . co m*/ public static void debugFunc(String message, int type, boolean shouldPrint) { // errors must always be displayed if (type == Log.ERROR) { Log.e(LOG_TAG, message); } else if (shouldPrint) { switch (type) { case Log.DEBUG: Log.d(LOG_TAG, message); break; case Log.INFO: Log.i(LOG_TAG, message); break; case Log.VERBOSE: Log.v(LOG_TAG, message); break; case Log.WARN: Log.w(LOG_TAG, message); break; default: Log.v(LOG_TAG, message); break; } } }
From source file:Main.java
public static int i(String tag, String msg, Throwable tr) { return println(Log.INFO, tag, msg + '\n' + getStackTraceString(tr)); }
From source file:Main.java
private static void print(int mode, final String tag, String msg) { if (!isPrint) { return;/*from ww w. j a v a 2 s. c om*/ } if (msg == null) { Log.e(tag, MSG); return; } switch (mode) { case Log.VERBOSE: Log.v(tag, msg); break; case Log.DEBUG: Log.d(tag, msg); break; case Log.INFO: Log.i(tag, msg); break; case Log.WARN: Log.w(tag, msg); break; case Log.ERROR: Log.e(tag, msg); break; default: Log.d(tag, msg); break; } }
From source file:Main.java
public static void log(Class<? extends Object> clazz, String msg) { if (isLog) {//from w ww . j a va 2 s. com log(DEFAULT_TAG, Log.INFO, String.format("%s : %s", clazz.getSimpleName(), msg), null); } }
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!"); }/* w w w .java 2s . 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 void log(final String msg) { if (isLog) { log(DEFAULT_TAG, Log.INFO, msg, null); } }
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 ww . jav a2s . c o m 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; }