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 isEmpty(CharSequence target) {
    target = target.toString().trim();
    return TextUtils.isEmpty(target);
}

From source file:Main.java

public static String getConvertHtml(String content) {
    String rs = content;/*from   www.  j  ava  2 s.c  o m*/
    if (!TextUtils.isEmpty(content)) {
        rs = "";
        String[] arr_contents = content.split("\r\n");
        for (int i = 0, len = arr_contents.length; i < len; i++) {
            rs += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + arr_contents[i] + "<br/>";
        }
    }
    return rs;
}

From source file:Main.java

public static String formatPhoneNum(String phoneNum) {
    if (TextUtils.isEmpty(phoneNum)) {
        return null;
    }/* w ww.j  av a2  s  .  c o m*/
    return phoneNum.replace(" ", "");
}

From source file:Main.java

public static String getFolderPath(String path) {
    String folderPath = "";

    if (!TextUtils.isEmpty(path)) {
        int i = path.lastIndexOf('/');
        if (i > 0) {
            folderPath = path.substring(0, i);
        }/*from w w w.jav  a2 s. c o m*/
    }

    return folderPath;
}

From source file:Main.java

public static boolean isConfirmPasswordValid(String oldPsw, String psw) {
    try {/*from w ww.jav  a 2  s . c  o  m*/
        if (!TextUtils.isEmpty(psw) && oldPsw.equals(psw)) {
            return true;
        }
    } catch (NumberFormatException ignored) {
    }
    return false;
}

From source file:Main.java

public static boolean isValidTelNumber(String telNumber) {
    if (!TextUtils.isEmpty(telNumber)) {
        String regex = "(\\+\\d+)?1[34578]\\d{9}$";
        return Pattern.matches(regex, telNumber);
    }/*from w  w w  . j  a va 2s .c o m*/

    return false;
}

From source file:Main.java

public static boolean isValidEmail(CharSequence target) {
    return !TextUtils.isEmpty(target) && android.util.Patterns.EMAIL_ADDRESS.matcher(target).matches();
}

From source file:Main.java

public static boolean isFixPhoneValid(String fixPhone) {
    if (TextUtils.isEmpty(fixPhone))
        return false;

    String regex = "^(0[0-9]{2,3}\\-)?([2-9][0-9]{6,7})+(\\-[0-9]{1,5})?$";

    return Pattern.matches(regex, fixPhone);
}

From source file:Main.java

public static String getShortTitle(String title) {
    if (TextUtils.isEmpty(title)) {
        return "";
    }/*  www. j  a va 2 s .c o m*/
    if (title.length() <= 10) {
        return title;
    }
    return title.substring(0, 10);
}

From source file:Main.java

public static String getFileNameFromUrl(String url) {
    if (!TextUtils.isEmpty(url)) {
        return url.substring(url.lastIndexOf("/") + 1);
    }//from   w  w  w  .  j ava2  s .  c o  m

    return System.currentTimeMillis() + "";
}