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 checkUrl(String url) {
    if (TextUtils.isEmpty(url)) {
        return false;
    }/*www  . ja  v  a2s . c om*/
    return Pattern.compile("^(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]")
            .matcher(url).matches();
}

From source file:Main.java

public static boolean isValidEmail(String email) {
    return !TextUtils.isEmpty(email) && Patterns.EMAIL_ADDRESS.matcher(email).matches();
}

From source file:Main.java

public static byte[] decodeToByte(String content) {
    if (TextUtils.isEmpty(content)) {
        return null;
    }/*from  www  .  j  a  v  a2 s  .c om*/
    return Base64.decode(content.getBytes(), Base64.DEFAULT);
}

From source file:Main.java

public static boolean startWithMytext(String mytext, String begin) {
    if (TextUtils.isEmpty(mytext) && TextUtils.isEmpty(begin))
        return false;
    else {//from ww  w .j ava 2s  .c  om
        if (mytext.startsWith(begin))
            return true;
        else
            return false;
    }
}

From source file:Main.java

public static String getArtistAndAlbum(String artist, String album) {
    if (TextUtils.isEmpty(artist) && TextUtils.isEmpty(album)) {
        return "";
    } else if (!TextUtils.isEmpty(artist) && TextUtils.isEmpty(album)) {
        return artist;
    } else if (TextUtils.isEmpty(artist) && !TextUtils.isEmpty(album)) {
        return album;
    } else {/*  w w  w.  j av  a 2  s  .  c  om*/
        return artist + " - " + album;
    }
}

From source file:Main.java

public static boolean isNotEmpty(String str) {
    return !TextUtils.isEmpty(str);
}

From source file:Main.java

public static boolean isGif(String url) {
    if (!TextUtils.isEmpty(url)) {
        int index = url.lastIndexOf("suffix=");
        if (index >= 0 && index + 10 <= url.length()) {
            String type = url.substring(index + 7, index + 10);
            if ("gif".equals(type)) {
                return true;
            }//from   w ww. j ava2s. co  m
        }
        if (url.contains(".gif")) {
            return true;
        }
        if (url.contains("format=gif")) {
            return true;
        }
    }
    return false;
}

From source file:Main.java

public static boolean isFileExist(String fileName) {
    if (TextUtils.isEmpty(fileName)) {
        return false;
    }//from  w ww .  j  a  v a2s .c  o  m
    File file = new File(fileName);
    return file.exists();

}

From source file:Main.java

public static void delFile(String path) {
    if (TextUtils.isEmpty(path)) {
        return;//from  w ww .  j a va2 s  .co m
    }

    try {
        File file = new File(path);
        if (file.exists()) {
            file.delete();
        }
    } catch (Exception ignore) {

    }
}

From source file:Main.java

public static String removePlusFromMobile(String mobile) {
    if (mobile != null || !TextUtils.isEmpty(mobile)) {
        String[] arrMobile = mobile.split("\\+");
        if (arrMobile.length > 0)
            return arrMobile[1];
    }//w w w  . j ava 2  s.  co  m
    return mobile;
}