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 boolean checkTelephone(String telephone) {
    if (TextUtils.isEmpty(telephone)) {
        return false;
    } else if ((telephone.startsWith("86") && telephone.length() == 13)
            || (!telephone.startsWith("86") && telephone.length() == 11)) {
        return true;
    }/* w ww  . ja  va  2  s. co  m*/
    return false;
}

From source file:Main.java

public static String removeDoubleQuotes(String string) {
    if (TextUtils.isEmpty(string))
        return "";
    int length = string.length();
    if ((length > 1) && (string.charAt(0) == '"') && (string.charAt(length - 1) == '"')) {
        return string.substring(1, length - 1);
    }//www. j a  v  a2  s. c om
    return string;
}

From source file:Main.java

public static String RemoveLastZero(String datetime) {
    if (TextUtils.isEmpty(datetime))
        return "";

    if (datetime.length() > 19)
        return datetime.substring(0, 19);
    else/*from  ww w . j  a v  a2 s. c om*/
        return datetime;
}

From source file:Main.java

public static String ToDBC(String input) {
    if (TextUtils.isEmpty(input)) {
        return "";
    }/*w w  w .ja v  a 2s.com*/
    char[] c = input.toCharArray();
    for (int i = 0; i < c.length; i++) {
        if (c[i] == 12288) {
            c[i] = (char) 32;
            continue;
        }
        if (c[i] > 65280 && c[i] < 65375)
            c[i] = (char) (c[i] - 65248);
    }
    return new String(c);
}

From source file:Main.java

public static boolean isLetterBegin(String s) {
    if (TextUtils.isEmpty(s))
        return false;
    else {//from w  w w .  j  av  a 2  s.c  o  m
        char c = s.charAt(0);
        int i = (int) c;
        if ((i >= 65 && i <= 90) || (i >= 97 && i <= 122)) {
            return true;
        } else {
            return false;
        }
    }
}

From source file:Main.java

public static String concatenateWhere(String a, String b) {
    if (TextUtils.isEmpty(a)) {
        return b;
    }//from www  .  ja v a 2  s  . c o  m
    if (TextUtils.isEmpty(b)) {
        return a;
    }
    return "(" + a + ") AND (" + b + ")";
}

From source file:Main.java

public static String getFileExtension(String path) {
    if (TextUtils.isEmpty(path)) {
        return null;
    }// w  w  w. ja va  2  s . c om
    int index = path.lastIndexOf(".");
    if (index == -1 || index == path.length() - 1) {
        return null;
    }

    return path.substring(index + 1);
}

From source file:Main.java

public static String defaultText(String text, String defaultText) {
    return TextUtils.isEmpty(text) ? defaultText : text;
}

From source file:Main.java

public static boolean checkVerifyCode(String verifyCode) {
    if (TextUtils.isEmpty(verifyCode)) {
        return false;
    } else {//from   w w w .java 2s.  c  om
        String verRegex = "[0-9]{6}";
        return verifyCode.matches(verRegex);

    }
}

From source file:Main.java

public static boolean checkUrlNotNull(String url) {
    return url != null && !TextUtils.isEmpty(url) && url.trim().length() != 0;
}