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 isValidId(String id) {
    try {/*  w w  w.  j av a2  s . c o m*/
        return !TextUtils.isEmpty(id) && TextUtils.isDigitsOnly(id) && Integer.parseInt(id) > 0;
    } catch (Exception e) {
        return false;
    }
}

From source file:Main.java

public static String changeTel(String pNumber) {
    if (!TextUtils.isEmpty(pNumber) && pNumber.length() > 6) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < pNumber.length(); i++) {
            char c = pNumber.charAt(i);
            if (i >= 3 && i <= 6) {
                sb.append('*');
            } else {
                sb.append(c);//from  w  w w .j  a va2  s .com
            }
        }
        return sb.toString();
    }
    return pNumber;
}

From source file:Main.java

public static Uri getUriFromFile(String path) {
    if (TextUtils.isEmpty(path)) {
        return Uri.parse("");
    } else {/*from  w w  w  . ja va2  s. co  m*/
        return Uri.parse("file://" + path);
    }
}

From source file:Main.java

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

From source file:Main.java

public static boolean deleteFile(String fileName) {
    boolean res = false;
    if (!TextUtils.isEmpty(fileName)) {
        File file = new File(fileName);
        if (file.exists()) {
            res = file.delete();/* w w  w.  j a va 2  s  .c om*/
        }
    }
    return res;
}

From source file:Main.java

public static Uri getUriFromAsset(String path) {
    if (TextUtils.isEmpty(path)) {
        return Uri.parse("");
    } else {//from   w ww.ja va  2 s .  c  o m
        return Uri.parse("asset:///" + path);
    }
}

From source file:Main.java

public static String getFormatDayTime(String time) {
    if (TextUtils.isEmpty(time))
        return null;

    return getFormatDayTime(Long.valueOf(time));
}

From source file:Main.java

public static String interceptStringOfIndex(String str, int index) {
    String intercept = str;//www .  ja v  a 2 s  .c  om

    if (TextUtils.isEmpty(str)) {
        return str;
    }

    if (str.length() > index) {
        intercept = str.substring(str.length() - index, str.length());

    }

    return intercept;
}

From source file:Main.java

public static boolean validateInputNumber(String text) {
    boolean digitsOnly = TextUtils.isDigitsOnly(text);
    if (TextUtils.isEmpty(text) || !digitsOnly) {
        return false;
    }//from   www  .  ja  v a 2 s  .  c  o  m
    return true;
}

From source file:Main.java

@Nullable
public static String nullableString(@Nullable String str) {
    return TextUtils.isEmpty(str) ? null : str;
}