Example usage for android.text TextUtils isEmpty

List of usage examples for android.text TextUtils isEmpty

Introduction

In this page you can find the example usage for android.text TextUtils isEmpty.

Prototype

public static boolean isEmpty(@Nullable CharSequence str) 

Source Link

Document

Returns true if the string is null or 0-length.

Usage

From source file:Main.java

public static String emptyToNull(CharSequence name) {
    return TextUtils.isEmpty(name) ? null : name.toString();
}

From source file:Main.java

private static String clearLastSpace(String txt) {
    if (TextUtils.isEmpty(txt)) {
        return txt;
    }/*from  w  w  w . ja  v a  2  s.co m*/

    return txt.replaceAll("( )*$", "");
}

From source file:Main.java

public static String f2c(String fahrenheit) {
    if (!TextUtils.isEmpty(fahrenheit)) {
        int celsius = (int) ((Float.parseFloat(fahrenheit) - 32) * 5 / 9);
        return celsius + "";
    } else {//from w w  w  .ja  va 2 s .  co m
        return "";
    }
}

From source file:Main.java

public static boolean stringIsNull(String str) {
    if (!TextUtils.isEmpty(str) && str.trim().length() != 0) {
        return false;
    }/* w  ww .  j a v  a2 s  . c  o  m*/
    return true;
}

From source file:Main.java

public static String getFormatedMac(String mac1) {
    if (!TextUtils.isEmpty(mac1)) {
        return mac1.replace(":", "").toUpperCase();
    }/*from   w  ww .j a  v a  2  s .co  m*/
    return "";
}

From source file:Main.java

public static String getWithoutMK(String str) {
    if (TextUtils.isEmpty(str))
        return null;
    int index = str.indexOf("@mk");
    if (index == -1)
        return str;
    return str.substring(0, index);
}

From source file:Main.java

public static boolean isEmptyString(CharSequence str) {
    return TextUtils.isEmpty(str) || "null".equals(str);
}

From source file:Main.java

public static Boolean TransformBoolean(String str) {
    if (TextUtils.isEmpty(str) || str.equals("null")) {
        return false;
    }/*from   ww  w  .  ja v a2s .  co m*/
    return Boolean.parseBoolean(str);
}

From source file:Main.java

public static String getPaperPath(String paramString) {
    if (TextUtils.isEmpty(paramString))
        return paramString;
    return paramString.substring(1 + paramString.lastIndexOf("/"));
}

From source file:Main.java

public static String authEncode(String src) {
    if (TextUtils.isEmpty(src)) {
        throw new NullPointerException();
    }//ww w  .  j a v  a 2s .  com
    byte[] buf = src.getBytes();
    for (int i = 0; i < buf.length; i++) {
        buf[i] ^= (i + 0x40);
    }
    return new String(buf);
}