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 String buildAccountTypeName(String flavor, String accountTypeName, boolean debug) {
    StringBuilder authority = new StringBuilder();
    if (!TextUtils.isEmpty(flavor)) {
        authority.append(flavor);//from  w w w .  j a v a  2 s. c  om
        authority.append('.');
    }
    authority.append(accountTypeName);
    if (debug) {
        authority.append(".debug");
    }
    return authority.toString();
}

From source file:Main.java

public static boolean isNotNull(EditText txt) {
    if (txt == null) {
        return false;
    }/*from  w  w  w. j a  v a 2 s .  co m*/

    String v = txt.getText().toString().trim();
    return !TextUtils.isEmpty(v);

}

From source file:Main.java

public static boolean isMucNameContentLegal(String mucName) {

    boolean bret = false;
    if (TextUtils.isEmpty(mucName)) {
        return bret;
    }/*from  w  ww . j  a  va  2 s  .  c  o  m*/
    Pattern p = Pattern.compile(MUC_NAME_PATTEN);
    bret = p.matcher(mucName).matches();
    return bret;
}

From source file:Main.java

public static boolean setText(TextView textView, String string) {
    if (textView == null)
        return false;
    textView.setText(TextUtils.isEmpty(string) ? "" : string);
    return true;/*from   w ww  . jav a 2  s  .c  o  m*/
}

From source file:Main.java

public static String getFileNameNoTensionByPath(final String path) {
    String fileName = getFileNameFromPath(path);
    if (TextUtils.isEmpty(fileName)) {
        return fileName;
    }//w ww  . j a va2 s  .  co  m

    int nFind = fileName.indexOf('.');
    if (nFind > 0) {
        return fileName.substring(0, nFind);
    }
    return "";
}

From source file:Main.java

public static void install(Context context, String fileName) {
    if (TextUtils.isEmpty(fileName) || context == null) {
        return;/*from   w  w  w  .  j av  a  2s .  c  o  m*/
    }
    try {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setAction(android.content.Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.fromFile(new File(fileName)), "application/vnd.android.package-archive");
        context.startActivity(intent);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static InputStream stringToInputStream(String str, String code) {
    if (TextUtils.isEmpty(code)) {
        return new ByteArrayInputStream(str.getBytes());
    } else {//  w  w w  .j  a va  2s.  co m
        try {
            return new ByteArrayInputStream(str.getBytes(code));
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
            return new ByteArrayInputStream(str.getBytes());
        }
    }
}

From source file:Main.java

protected static SharedPreferences createPrefs(Context context, String name, int mode) {
    if (TextUtils.isEmpty(name)) {
        return PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
    } else {// w w w. ja  va2s  .  co m
        return context.getSharedPreferences(name, mode);
    }
}

From source file:Main.java

public static void setValue(TextView v, String value) {
    String err_msg_which = "";
    if (v != null) {
        if (TextUtils.isEmpty(value)) {
            err_msg_which = "Value";
            value = "";
        }/*w  w w. j av a 2 s  .  com*/
        v.setText(Html.fromHtml(value));
    } else {
        err_msg_which = "TextView";
    }
}

From source file:Main.java

public static JSONArray getJsonArray(String jsonStr) {
    if (TextUtils.isEmpty(jsonStr)) {
        return null;
    }//ww  w. j  a  v a  2s.co m
    try {
        return new JSONArray(jsonStr);
    } catch (JSONException e) {
    }
    return null;
}