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 checkUserToken() {
    checkSP();//from w ww . j ava  2s .c  o  m
    String token = sp.getString("matrix_user_token", "");
    if (TextUtils.isEmpty(token)) {
        return false;
    } else {
        return true;
    }
}

From source file:Main.java

public static int str2Int(String str, int defValue) {
    try {/*from  w  w  w  .ja va  2 s  .  c om*/
        if (TextUtils.isEmpty(str))
            return defValue;
        return Integer.parseInt(str);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return defValue;
}

From source file:Main.java

public static boolean isMobileNO(String cellphone) {
    Pattern p = Pattern.compile("^[1][34578]\\d{9}$");
    Matcher m = p.matcher(cellphone);
    if (!TextUtils.isEmpty(cellphone)) {
        return m.matches();
    }//from w w  w  . jav a  2s .c  om
    return false;
}

From source file:Main.java

public static SpannableString setTextStrikethrough(String content, int startIndex, int endIndex) {
    if (TextUtils.isEmpty(content) || startIndex < 0 || endIndex >= content.length()
            || startIndex >= endIndex) {
        return null;
    }//www .  ja  v  a  2  s.  com

    SpannableString spannableString = new SpannableString(content);
    spannableString.setSpan(new StrikethroughSpan(), startIndex, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    return spannableString;
}

From source file:Main.java

public static String onDecide(String originUrl, int width) {
    if (TextUtils.isEmpty(originUrl)) {
        return "";
    }// www. j a va 2s.c  o  m
    int index = binarySearch(URL_SIZE, width, true);
    return originUrl + "-w" + URL_SIZE[index];
}

From source file:Main.java

private static WeakReference<Bitmap> cprsBmpBySize(String path, int rqsW, int rqsH) {
    if (TextUtils.isEmpty(path))
        return null;
    final BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;//from   w ww  .ja va  2  s .  co  m
    BitmapFactory.decodeFile(path, options);
    options.inSampleSize = caculateInSampleSize(options, rqsW, rqsH);
    options.inJustDecodeBounds = false;
    return new WeakReference<Bitmap>(BitmapFactory.decodeFile(path, options));
}

From source file:Main.java

/**
 * 2016-01-23 10:00:12.0 => 2016-01-23
 * @param str//w  w w.  j a  v  a2 s  .  c  o m
 * @return
 */
public static String formatCreateDate(String createDate) {
    String result = "";
    if (!TextUtils.isEmpty(createDate) && createDate.length() >= 10) {
        result = createDate.substring(0, 10);
    }
    return result;
}

From source file:Main.java

/**
 * encode/*w  w  w. ja  v a 2s . co m*/
 * @param source source
 * @return String
 */
public static String encode(String source) {
    if (!TextUtils.isEmpty(source)) {
        return new String(mBase64.encode(source.getBytes()));
    }
    return "";
}

From source file:Main.java

/**
 * decode/*from  ww  w .  j a  v  a2s. c  o m*/
 * @param source source
 * @return String
 */
public static String decode(String source) {
    if (!TextUtils.isEmpty(source)) {
        return new String(mBase64.decode(source.getBytes()));
    }
    return "";
}

From source file:Main.java

@Nullable
static Uri safeUri(@NonNull String url) {
    if (TextUtils.isEmpty(url)) {
        return null;
    }/*from  ww  w . ja va  2s.c o  m*/

    Uri uri = Uri.parse(url);

    if (uri.getHost() == null || uri.getScheme() == null) {
        return null;
    }

    return uri;
}