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 void install(Context context, String path) {
    if (TextUtils.isEmpty(path)) {
        return;//from  w w w . j a va  2 s .c o  m
    }
    Intent installIntent = new Intent(Intent.ACTION_VIEW);
    installIntent.setDataAndType(Uri.parse(path), "application/vnd.android.package-archive");
    context.startActivity(installIntent);
}

From source file:Main.java

public static boolean checkPhone(String num) {
    String mobile = num;/*  w ww.  ja  va2  s .  c om*/
    if (TextUtils.isEmpty(mobile)) {
        return false;
    }
    String exp = "(1)[0-9]{10}$";
    Pattern p = Pattern.compile(exp);
    Matcher m = p.matcher(mobile);
    boolean isPhoneNum = m.matches();
    return isPhoneNum;
}

From source file:Main.java

/**
 * Checks whether or not a phone number is a private caller or not.
 *///from www  . ja  v  a  2s  .c om
public static boolean isPrivateCaller(CharSequence charsequence) {
    return TextUtils.isEmpty(charsequence) || '-' == charsequence.charAt(0);
}

From source file:Main.java

public static String getFirstNotEmpty(final String... texts) {
    for (final String text : texts) {
        if (!TextUtils.isEmpty(text)) {
            return text;
        }/*from  www  .  j a v a  2 s. com*/
    }

    return null;
}

From source file:Main.java

public static String getFileScheme(@NonNull final String filePath) {
    if (TextUtils.isEmpty(filePath))
        return "";
    return filePath.substring(filePath.lastIndexOf(".") + 1);
}

From source file:Main.java

public static String addParamToUrl(String url, String key, Object value) {
    if (TextUtils.isEmpty(url)) {
        return null;
    }/*from www.jav a2 s.  c o  m*/
    String tmpKey = key + "=";
    if (url.indexOf(tmpKey) != -1) {
        String[] tmp = url.split(tmpKey);
        if (tmp.length > 1) {
            if (tmp[1].indexOf("&") != -1) {
                String subStr = tmp[1].substring(tmp[1].indexOf("&"), tmp[1].length());
                url = tmp[0] + tmpKey + value + subStr;
            } else {
                url = tmp[0] + tmpKey + value;
            }
        }
    } else {
        if (url.indexOf("?") == -1) {
            url += "?" + key + "=" + value;
        } else {
            url += "&" + key + "=" + value;
        }
    }
    return url;
}

From source file:Main.java

public static void callByPhone(Context context, String phone) {
    if (TextUtils.isEmpty(phone)) {
        return;//  w ww.  ja  v  a 2  s  . c o m
    }

    Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phone));
    context.startActivity(intent);
}

From source file:Main.java

public static boolean patternCode(String patternCoder, String patternContent) {
    if (TextUtils.isEmpty(patternContent)) {
        return false;
    }//from  w w  w .j  a v a 2s.c om
    Pattern p = Pattern.compile(patternCoder);
    Matcher matcher = p.matcher(patternContent);
    if (matcher.find()) {
        return true;
    }
    return false;
}

From source file:Main.java

public static void checkNotNull(Object object, String message) {
    if (TextUtils.isEmpty(message))
        message = "param check failed";
    if (object == null)
        throw new NullPointerException(message);
}

From source file:Main.java

public static void setText(TextView textView, String text) {
    if (textView != null && !TextUtils.isEmpty(text)) {
        textView.setVisibility(View.VISIBLE);
        textView.setText(text);//from www  .  ja  va  2  s .  c  o m
    }
}