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 isHasValue(String... editTexts) {
    for (String ed : editTexts) {
        String str = ed.trim();/*w  w w  . j  a  v  a 2 s.co m*/
        if (!TextUtils.isEmpty(str)) {
            return true;
        }
    }
    return false;
}

From source file:Main.java

public static int getLogoColorIndex(String room) {
    int index = 0;
    if (TextUtils.isEmpty(room)) {
        return index;
    }/*from  w w  w . j  a va2  s.  c o  m*/
    if (room.contains("201")) {
        index = 1;
    } else if (room.contains("202")) {
        index = 2;
    } else if (room.contains("203")) {
        index = 3;
    } else if (room.contains("204")) {
        index = 4;
    } else if (room.contains("205")) {
        index = 5;
    }
    return index;
}

From source file:Main.java

public static String getFieldValue(String json, String key) {
    if (TextUtils.isEmpty(json))
        return null;
    if (!json.contains(key))
        return "";
    JSONObject jsonObject = null;//from   w w w.  jav a2 s .  co m
    String value = null;
    try {
        jsonObject = new JSONObject(json);
        value = jsonObject.getString(key);
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return value;
}

From source file:Main.java

public static boolean isToday(final String milliseconds) {
    if (TextUtils.isEmpty(milliseconds))
        return false;
    return isToday(new Date(Long.parseLong(milliseconds)));
}

From source file:Main.java

public static boolean deleteFile(String path) {
    boolean result = false;
    if (!TextUtils.isEmpty(path)) {
        File file = new File(path);
        if (file.exists()) {
            if (file.isFile()) {
                result = file.delete();//from  w w w .j  av  a  2  s . c o  m
            } else {
                result = removeDir(file);
            }
        }
    }
    return result;
}

From source file:Main.java

public static boolean hasNotEmptyParam(String... params) {
    int size = params.length;
    for (int i = 0; i < size; i++) {
        if (TextUtils.isEmpty(params[i])) {
            return false;
        }//w ww  .  ja  v  a 2s  .  c o m
    }
    return true;
}

From source file:Main.java

public static String filterMobileNum(String phoneNum) {
    if (TextUtils.isEmpty(phoneNum))
        return "";

    return checkMobileNum(phoneNum.replaceAll("[^0-9]", ""));
}

From source file:Main.java

public static boolean compareDate(String startDate, String endDate) {
    if (TextUtils.isEmpty(startDate) || TextUtils.isEmpty(endDate)) {
        return false;
    }//w  w  w. ja v a 2s.  c  o m
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHH");
    try {
        Date dt1 = sdf.parse(startDate);
        Date dt2 = sdf.parse(endDate);
        return dt1.after(dt2);
    } catch (Exception e) {
        return false;
    }
}

From source file:Main.java

public static boolean deleteFile(String path) {
    if (TextUtils.isEmpty(path)) {
        return true;
    }//from  w  w  w  . j a v  a 2s.co  m

    File file = new File(path);
    if (file.exists()) {
        if (file.isFile()) {
            return file.delete();
        } else if (file.isDirectory()) {
            for (File f : file.listFiles()) {
                if (f.isFile()) {
                    f.delete();
                } else if (f.isDirectory()) {
                    deleteFile(f.getAbsolutePath());
                }
            }
            return file.delete();
        }
        return false;
    }
    return true;
}

From source file:Main.java

public static final String filterUCS4(String str) {
    if (TextUtils.isEmpty(str)) {
        return str;
    }//  ww  w. j  a  va  2s.  c  om

    if (str.codePointCount(0, str.length()) == str.length()) {
        return str;
    }

    StringBuilder sb = new StringBuilder();

    int index = 0;
    while (index < str.length()) {
        int codePoint = str.codePointAt(index);
        index += Character.charCount(codePoint);
        if (Character.isSupplementaryCodePoint(codePoint)) {
            continue;
        }

        sb.appendCodePoint(codePoint);
    }

    return sb.toString();
}