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 getFileName(String filePathName) {
    if (!TextUtils.isEmpty(filePathName)) {
        int index = filePathName.lastIndexOf('/');
        if (index != -1 && (index + 1) < filePathName.length()) {
            String name = filePathName.substring(index + 1);
            if (!TextUtils.isEmpty(name)) {
                int subIndex = name.lastIndexOf(".");
                if (subIndex != -1) {
                    return name.substring(0, subIndex);
                }//from  w  w  w .  j ava 2 s  . c o  m
            }
            return name;
        }
    }
    return "";
}

From source file:Main.java

public static boolean validateSourceUri(Uri uri) {
    return uri != null && !TextUtils.isEmpty(uri.toString());
}

From source file:Main.java

public final static boolean isValidUrl(CharSequence target) {
    return !TextUtils.isEmpty(target) && Patterns.WEB_URL.matcher(target).matches();
}

From source file:Main.java

public static boolean textIsEmpty(String text) {
    if (TextUtils.isEmpty(text) || "null".equals(text) || "(null)".equals(text)) {
        return true;
    } else {/*from   w  ww. j a v  a2  s  . c  o  m*/
        return false;
    }
}

From source file:Main.java

public static boolean isMobileValid(String mobile) {
    if (TextUtils.isEmpty(mobile) || !TextUtils.isDigitsOnly(mobile)) {
        return false;
    }/*from www  .j ava2s.  c  o  m*/

    return Pattern.matches("^(\\+86)?(1[3-9][0-9])\\d{8}$", mobile);
}

From source file:Main.java

public static String formatHM(String timeStr) {
    if (TextUtils.isEmpty(timeStr)) {
        return "";
    }//from  www  .  j a  v  a  2 s.c o  m
    return timeStr.substring(11, 16);

}

From source file:Main.java

public static long getLongTime(String millisTime) {
    return !TextUtils.isEmpty(millisTime) ? (long) (Double.valueOf(millisTime) * 1000)
            : System.currentTimeMillis();
}

From source file:Main.java

public static boolean isEmpty(String... strings) {
    for (String s : strings) {
        if (TextUtils.isEmpty(s)) {
            return true;
        }//from w w  w. j ava  2  s . com
    }
    return false;
}

From source file:Main.java

public static boolean textIsNOTEmpty(String a, String a1, String a2, String a3, String a4) {
    if (!TextUtils.isEmpty(a) && !TextUtils.isEmpty(a1) && !TextUtils.isEmpty(a2) && !TextUtils.isEmpty(a3)
            && !TextUtils.isEmpty(a4)) {
        return true;
    }// w  w w. ja  v  a 2 s .  c  om
    return false;
}

From source file:Main.java

public static String highlightText(String html, String name, String text) {
    if (TextUtils.isEmpty(text)) {
        return name;
    }//from  w ww . j  a  v a  2s .co  m

    if (name.contains(text)) {
        String replaceHtml = html.replace("%s", text);
        name = name.replaceAll(text, replaceHtml);
    }

    return name;
}