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

/**
 *
 * @param userData// w  ww. j  av a2  s .c  om
 * @return
 */
public static String getFileNameFormUserdata(String userData) {
    if (TextUtils.isEmpty(userData) || "null".equals(userData)) {
        return "";
    }
    return userData.substring(userData.indexOf("fileName=") + "fileName=".length(), userData.length());
}

From source file:Main.java

public static boolean checkEmailFormat(String email) {
    if (TextUtils.isEmpty(email)) {
        return false;
    }//from   ww  w.j a va  2  s . c o  m
    String reg = "^[0-9a-z_-][_.0-9a-z-]{0,31}@([0-9a-z][0-9a-z-]{0,30}\\.){1,4}[a-z]{2,4}$";
    Pattern pattern = Pattern.compile(reg, Pattern.CASE_INSENSITIVE);
    Matcher matcher = pattern.matcher(email);
    return matcher.matches();
}

From source file:Main.java

public static boolean isEmailLegal(String email) {
    if (TextUtils.isEmpty(email))
        return false;

    final String REGEXP = "^([a-z0-9\\-_.+]+)@([a-z0-9\\-]+[.][a-z0-9\\-.]+)$";
    Pattern p = Pattern.compile(REGEXP);
    Matcher m = p.matcher(email.toLowerCase());
    return m.matches();
}

From source file:Main.java

public static void writeData(OutputStream stream, String str) {
    if (null == stream || TextUtils.isEmpty(str)) {
        return;/* w w w.j  a  v  a  2  s.c om*/
    }

    str = str + "\r\n";

    try {
        BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(stream);
        bufferedOutputStream.write(str.getBytes());
        bufferedOutputStream.flush();
    } catch (Exception ex) {
        ex.printStackTrace();
    } finally {

    }
}

From source file:Main.java

public static Bitmap getBitmapFromBase64(String base64Str) {

    if (TextUtils.isEmpty(base64Str)) {
        return null;
    }/*from   w ww . j av a2s  . com*/

    byte[] bytes = Base64.decode(base64Str, Base64.NO_WRAP);
    return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
}

From source file:Main.java

public static boolean isPhoneNumber(String phoneNumber) {
    if (TextUtils.isEmpty(phoneNumber)) {
        return false;
    }//from   www . ja va  2  s .c  om
    String reg = "^[0-9]{11}$";
    Pattern pattern = Pattern.compile(reg);
    Matcher matcher = pattern.matcher(phoneNumber);
    return matcher.matches();
}

From source file:Main.java

public static Object getField(String paramString, Object paramObject) throws Exception {
    if (TextUtils.isEmpty(paramString))
        throw new RuntimeException("field name can not be empty");
    if (paramObject == null)
        throw new RuntimeException("target object can not be null");
    Field localField = paramObject.getClass().getDeclaredField(paramString);
    if (localField == null)
        throw new RuntimeException("target object: " + paramObject.getClass().getName()
                + " do not have this field: " + paramString);
    localField.setAccessible(true);/*from ww w.  j av  a  2s. com*/
    return localField.get(paramObject);
}

From source file:Main.java

public static boolean notEmpty(String s) {
    return s != null && !TextUtils.isEmpty(s.trim());
}

From source file:Main.java

public static boolean uninstallApk(Context context, String packageName) {
    if (TextUtils.isEmpty(packageName)) {
        return false;
    }/*from w w w. j  a  va  2  s . c  o m*/
    Intent i = new Intent(Intent.ACTION_DELETE, Uri.parse("package:" + packageName));
    i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(i);
    return true;
}

From source file:Main.java

public static Pair<String, String> parseQuoteUsernamePostid(final String usernamePostId) {
    if (TextUtils.isEmpty(usernamePostId)) {
        return null;
    }/*w  w  w .  j a v  a 2  s.  c o m*/
    final String[] split = usernamePostId.split(";");
    if (split.length == 0) {
        return null;
    } else if (split.length == 1) {
        return new Pair<>(split[0], null);
    }
    return new Pair<>(split[0], split[1]);
}