Example usage for android.util Log w

List of usage examples for android.util Log w

Introduction

In this page you can find the example usage for android.util Log w.

Prototype

public static int w(String tag, Throwable tr) 

Source Link

Usage

From source file:Main.java

/**
 * Attempts to find a preview size that matches the provided width and height (which
 * specify the dimensions of the encoded video).  If it fails to find a match it just
 * uses the default preview size for video.
 * <p>/*from   w  w  w .j a  va2s . co  m*/
 * TODO: should do a best-fit match, e.g.
 * https://github.com/commonsguy/cwac-camera/blob/master/camera/src/com/commonsware/cwac/camera/CameraUtils.java
 */
public static void choosePreviewSize(Camera.Parameters parms, int width, int height) {
    // We should make sure that the requested MPEG size is less than the preferred
    // size, and has the same aspect ratio.
    Camera.Size ppsfv = parms.getPreferredPreviewSizeForVideo();
    if (ppsfv != null) {
        Log.d(TAG, "Camera preferred preview size for video is " + ppsfv.width + "x" + ppsfv.height);
    }

    //for (Camera.Size size : parms.getSupportedPreviewSizes()) {
    //    Log.d(TAG, "supported: " + size.width + "x" + size.height);
    //}

    for (Camera.Size size : parms.getSupportedPreviewSizes()) {
        if (size.width == width && size.height == height) {
            parms.setPreviewSize(width, height);
            return;
        }
    }

    Log.w(TAG, "Unable to set preview size to " + width + "x" + height);
    if (ppsfv != null) {
        parms.setPreviewSize(ppsfv.width, ppsfv.height);
    }
    // else use whatever the default size is
}

From source file:Main.java

/**
 * Attempts to find a preview size that matches the provided width and height (which
 * specify the dimensions of the encoded video).  If it fails to find a match it just
 * uses the default preview size for video.
 * <p>//from   w w  w .  jav  a  2  s  .  com
 * TODO: should do a best-fit match, e.g.
 * https://github.com/commonsguy/cwac-camera/blob/master/camera/src/com/commonsware/cwac/camera/CameraUtils.java
 */
public static void choosePreviewSize(Camera.Parameters parms, int width, int height) {
    // We should make sure that the requested MPEG size is less than the preferred
    // size, and has the same aspect ratio.
    Camera.Size ppsfv = parms.getPreferredPreviewSizeForVideo();
    if (ppsfv != null) {
        Log.d(TAG, "Camera preferred preview size for video is " + ppsfv.width + "x" + ppsfv.height);
    }

    //for (Camera.Size size : parms.getSupportedPreviewSizes()) {
    //    Log.d(TAG, "supported: " + size.width + "x" + size.height);
    //}

    for (Camera.Size size : parms.getSupportedPreviewSizes()) {
        Log.e("camrae...parame", size.width + "*" + size.height);

        if (size.width == width && size.height == height) {
            parms.setPreviewSize(width, height);
            return;
        }
    }

    Log.w(TAG, "Unable to set preview size to " + width + "x" + height);
    if (ppsfv != null) {
        parms.setPreviewSize(ppsfv.width, ppsfv.height);
    }
    // else use whatever the default size is
}

From source file:com.deltadna.android.sdk.notifications.Utils.java

static String convert(Bundle payload) {
    final JSONObject result = new JSONObject();

    for (final String key : payload.keySet()) {
        try {//from w  w  w . j a  va  2  s .c om
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
                result.put(key, payload.get(key));
            } else {
                result.put(key, JSONObject.wrap(payload.get(key)));
            }
        } catch (JSONException e) {
            Log.w(BuildConfig.LOG_TAG, e);
        }
    }

    return result.toString();
}

From source file:Main.java

/**
 * Attempts to find a preview size that matches the provided width and height (which
 * specify the dimensions of the encoded video).  If it fails to find a match it just
 * uses the default preview size for video.
 * <p>//  w w w  .j a v  a2 s  . c  o m
 * TODO: should do a best-fit match, e.g.
 * https://github.com/commonsguy/cwac-camera/blob/master/camera/src/com/commonsware/cwac/camera/CameraUtils.java
 */
public static void choosePreviewSize(Camera.Parameters parms, int width, int height) {
    // We should make sure that the requested MPEG size is less than the preferred
    // size, and has the same aspect ratio.
    Camera.Size ppsfv = parms.getPreferredPreviewSizeForVideo();
    if (ppsfv != null) {
        Log.d(TAG, "Camera preferred preview size for video is " + ppsfv.width + "x" + ppsfv.height);
    }

    //for (Camera.Size size : parms.getSupportedPreviewSizes()) {
    //    Log.d(TAG, "supported: " + size.width + "x" + size.height);
    //}

    for (Camera.Size size : parms.getSupportedPreviewSizes()) {

        Log.i(TAG, "preview size " + size.width + "x" + size.height);

        if (size.width == width && size.height == height) {
            parms.setPreviewSize(width, height);
            return;
        }
    }

    Log.w(TAG, "Unable to set preview size to " + width + "x" + height);
    if (ppsfv != null) {
        parms.setPreviewSize(ppsfv.width, ppsfv.height);
    }
    // else use whatever the default size is
}

From source file:Main.java

/**
 * Logs provided logText in provided tag at given logLevel (like, android.util.Log.DEBUG)
 * @param logLevel int VERBOSE, DEBUG, INFO, WARN, ERROR
 * @param tag String//  w  ww. ja v  a  2s  . c o  m
 * @param logText String
 */
public static void log(int logLevel, String tag, String logText) {
    switch (logLevel) {
    case Log.VERBOSE:
        Log.v(tag, logText);
        break;

    case Log.DEBUG:
        Log.d(tag, logText);
        break;

    case Log.INFO:
        Log.i(tag, logText);
        break;

    case Log.WARN:
        Log.w(tag, logText);
        break;

    case Log.ERROR:
        Log.e(tag, logText);
        break;
    }
}

From source file:net.nordist.lloydproof.CorrectionStorage.java

@Override
public void onCreate(SQLiteDatabase database) {
    Log.w(TAG, "Creating database v" + DATABASE_VERSION);
    database.execSQL("CREATE TABLE " + TABLE_NAME + " (id integer PRIMARY KEY AUTOINCREMENT,"
            + " current_text text NOT NULL DEFAULT '');");
}

From source file:Main.java

public static String getMD5Value(String str, String fix, String charsetName) {
    if (str != null && fix != null) {
        String formalString = str + fix;
        try {/* ww w  .  j  a v a  2 s.com*/
            MessageDigest algorithm = MessageDigest.getInstance("MD5");
            algorithm.reset();
            try {
                algorithm.update(formalString.getBytes(charsetName));
            } catch (UnsupportedEncodingException e) {
                // TODO Auto-generated catch block
                Log.e("WxException", e.getMessage(), e);
                return null;
            }
            byte messageDigest[] = algorithm.digest();

            return toHexString(messageDigest);
        } catch (NoSuchAlgorithmException e) {
            Log.w(TAG, e);
            Log.e("WxException", e.getMessage(), e);
        }
    }
    return null;

}

From source file:Main.java

/**
 * Load the image at {@code imagePath} as a {@link Bitmap}, scaling it to
 * the specified size and preserving the aspect ratio.
 * @param imagePath Path of the image to load.
 * @param width Required width of the resulting {@link Bitmap}.
 * @param height Required height of the resulting {@link Bitmap}.
 * @param fill {@code true} to fill the empty space with transparent color.
 * @param crop {@code true} to crop the image, {@code false} to resize without cutting the image.
 * @return {@link Bitmap} representing the image at {@code imagePath}.
 *///from www  . j  a v  a  2  s  .c  om
public static Bitmap loadResizedBitmap(String imagePath, int width, int height, boolean fill, boolean crop) {
    Bitmap retVal;

    BitmapFactory.Options opts = new BitmapFactory.Options();
    opts.inSampleSize = getScale(imagePath, width, height);
    opts.inJustDecodeBounds = false;

    Bitmap image = BitmapFactory.decodeFile(imagePath, opts);

    if (image == null) {
        if (imagePath != null) {
            Log.w("Helper", "Cannot decode " + imagePath);
        } else {
            Log.w("Helper", "Path is null: Cannot decode");
        }
        return null;
    }

    if (image.getWidth() != width || image.getHeight() != height) {
        //Image need to be resized.
        int scaledWidth = (image.getWidth() * height) / image.getHeight();
        int scaledHeight;
        if ((crop && scaledWidth > width) || (!crop && scaledWidth < width)) {
            scaledHeight = height;
        } else {
            scaledWidth = width;
            scaledHeight = (image.getHeight() * width) / image.getWidth();
        }

        Rect src = new Rect(0, 0, image.getWidth(), image.getHeight());
        Rect dst = new Rect(0, 0, scaledWidth, scaledHeight);

        if (fill) {
            retVal = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
            dst.offset((width - scaledWidth) / 2, (height - scaledHeight) / 2);
        } else {
            retVal = Bitmap.createBitmap(scaledWidth, scaledHeight, Bitmap.Config.ARGB_8888);
        }
        retVal.eraseColor(Color.TRANSPARENT);

        synchronized (canvas) {
            if (antiAliasPaint == null) {
                antiAliasPaint = new Paint();
                antiAliasPaint.setAntiAlias(true);
                antiAliasPaint.setFilterBitmap(true);
                antiAliasPaint.setDither(true);
            }
            canvas.setBitmap(retVal);
            canvas.drawBitmap(image, src, dst, antiAliasPaint);
        }

        image.recycle();
    } else {
        //No need to scale.
        retVal = image;
    }

    return retVal;
}

From source file:Main.java

public static <T extends BroadcastReceiver> void scheduleUpdate(Context context, Class<T> clazz) {
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
    AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    Intent intent = new Intent(context, clazz);
    PendingIntent sender = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    Random random = new Random(System.currentTimeMillis());
    long offset = random.nextLong() % (12 * 60 * 60 * 1000);
    long interval = (24 * 60 * 60 * 1000) + offset;
    String prefKey = "pref_scheduled_monitor_config_update_" + clazz.getCanonicalName();
    long scheduledTime = preferences.getLong(prefKey, -1);

    if (scheduledTime == -1) {
        context.sendBroadcast(intent);/*from   www. j  av  a  2  s. c  o m*/
    }

    if (scheduledTime <= System.currentTimeMillis()) {
        context.sendBroadcast(intent);
        scheduledTime = System.currentTimeMillis() + interval;
        preferences.edit().putLong(prefKey, scheduledTime).commit();
        Log.w("PeriodicActionUtils",
                "Scheduling for all new time: " + scheduledTime + " (" + clazz.getSimpleName() + ")");
    } else {
        Log.w("PeriodicActionUtils", "Scheduling for time found in preferences: " + scheduledTime + " ("
                + clazz.getSimpleName() + ")");
    }

    am.cancel(sender);
    am.set(AlarmManager.RTC_WAKEUP, scheduledTime, sender);

    Log.w("PeriodicActionUtils", "Scheduled for: " + scheduledTime + " (" + clazz.getSimpleName() + ")");
}

From source file:com.norman0406.slimgress.API.Plext.Markup.java

public static Markup createByJSON(JSONArray json) throws JSONException {
    if (json.length() != 2) {
        Log.e("Markup", "invalid array size");
        return null;
    }// w  ww.j  a  v  a  2s  . co  m

    JSONObject markupObj = json.getJSONObject(1);

    Markup newMarkup = null;

    String markupString = json.getString(0);
    if (markupString.equals("SECURE"))
        newMarkup = new MarkupSecure(markupObj);
    else if (markupString.equals("SENDER"))
        newMarkup = new MarkupSender(markupObj);
    else if (markupString.equals("PLAYER"))
        newMarkup = new MarkupPlayer(markupObj);
    else if (markupString.equals("AT_PLAYER"))
        newMarkup = new MarkupATPlayer(markupObj);
    else if (markupString.equals("PORTAL"))
        newMarkup = new MarkupPortal(markupObj);
    else if (markupString.equals("TEXT"))
        newMarkup = new MarkupText(markupObj);
    else
        Log.w("Markup", "unknown markup type: " + markupString);

    return newMarkup;
}