List of usage examples for android.text TextUtils isEmpty
public static boolean isEmpty(@Nullable CharSequence str)
From source file:Main.java
/** * Returns <tt>true</tt> if input String is not empty and Numeric. * * @param str/*from ww w . jav a 2 s .c o m*/ * @return */ public static boolean isNumeric(String str) { return !TextUtils.isEmpty(str) && TextUtils.isDigitsOnly(str); }
From source file:Main.java
public static SpannableString setTextUnderline(String content, int startIndex, int endIndex) { if (TextUtils.isEmpty(content) || startIndex < 0 || endIndex >= content.length() || startIndex >= endIndex) { return null; }//from w ww. j a va 2 s .c o m SpannableString spannableString = new SpannableString(content); spannableString.setSpan(new UnderlineSpan(), startIndex, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); return spannableString; }
From source file:Main.java
public static boolean isValidCardNumber(String pan) { if (TextUtils.isEmpty(pan)) { return false; }/*from w w w . j av a2s .c o m*/ if (pan.length() < PAN_LENGTH_MIN || pan.length() > PAN_LENGTH_MAX) { return false; } // check all numeric if (!TextUtils.isDigitsOnly(pan)) { return false; } return true; }
From source file:Main.java
public static String getFormatDateFromAmazon(String amazonDate) { String month = null;/* w w w. j av a2s .c om*/ String date = null; String year = null; if (TextUtils.isEmpty(amazonDate)) return ""; String[] format_1 = amazonDate.split(","); String[] month_date = format_1[0].split(" "); month = month_date[0]; date = month_date[1]; if (format_1[1].startsWith(" ")) { format_1[1] = format_1[1].substring(1, format_1[1].length()); } String[] year_plus = format_1[1].split(" "); year = year_plus[0]; if (TextUtils.equals(month, "Jan")) month = "1"; else if (TextUtils.equals(month, "Feb")) month = "2"; else if (TextUtils.equals(month, "Mar")) month = "3"; else if (TextUtils.equals(month, "Apr")) month = "4"; else if (TextUtils.equals(month, "May")) month = "5"; else if (TextUtils.equals(month, "Jun")) month = "6"; else if (TextUtils.equals(month, "Jul")) month = "7"; else if (TextUtils.equals(month, "Aug")) month = "8"; else if (TextUtils.equals(month, "Sep")) month = "9"; else if (TextUtils.equals(month, "Oct")) month = "10"; else if (TextUtils.equals(month, "Nov")) month = "11"; else if (TextUtils.equals(month, "Dev")) month = "12"; return month + "/" + date + "/" + year; }
From source file:Main.java
public static boolean checkAppInstalled(Context context, String packetName) { boolean isInstalled = false; if (TextUtils.isEmpty(packetName)) return isInstalled; PackageInfo packageInfo;/*from w ww.j ava 2 s .co m*/ try { packageInfo = context.getPackageManager().getPackageInfo(packetName, 0); } catch (Exception e) { packageInfo = null; // e.printStackTrace(); } if (packageInfo == null) { isInstalled = false; } else { isInstalled = true; } return isInstalled; }
From source file:Main.java
public static boolean testingShowWebView(final Activity activity, final String aid, final String url) { if (TextUtils.isEmpty(url)) { Intent intent = new Intent(adWebAction); intent.putExtra("aid", aid); if (intent.resolveActivity(activity.getPackageManager()) != null) { activity.startActivity(intent); }/* w w w . j av a 2 s .co m*/ return true; } return false; }
From source file:Main.java
public static ProgressDialog showProgressDialog(Context context, String msg) { ProgressDialog progressDialog = new ProgressDialog(context); if (!TextUtils.isEmpty(msg)) progressDialog.setMessage(msg);/*from w w w . j av a 2 s . c om*/ progressDialog.setIndeterminate(true); progressDialog.setCancelable(false); progressDialog.show(); return progressDialog; }
From source file:Main.java
public static String formatSize(Context context, String size) { return Formatter.formatFileSize(context, Long.valueOf(TextUtils.isEmpty(size) ? "0" : size)); }
From source file:Main.java
public static void showLog(String tag, String msg) { if (isDebug && !TextUtils.isEmpty(msg)) { if (TextUtils.isEmpty(tag)) tag = mTag;//w ww. j ava2 s . com StackTraceElement[] stackTraceElement = Thread.currentThread().getStackTrace(); int currentIndex = -1; for (int i = 0; i < stackTraceElement.length; i++) { if (stackTraceElement[i].getMethodName().compareTo("showLog") == 0) { currentIndex = i + 1; break; } } if (currentIndex >= 0) { String fullClassName = stackTraceElement[currentIndex].getClassName(); String className = fullClassName.substring(fullClassName.lastIndexOf(".") + 1); String methodName = stackTraceElement[currentIndex].getMethodName(); String lineNumber = String.valueOf(stackTraceElement[currentIndex].getLineNumber()); Log.i(tag, msg + "\n ---->at " + className + "." + methodName + "(" + className + ".java:" + lineNumber + ")"); } else { Log.i(tag, msg); } } }
From source file:Main.java
public static DateTime formatDateFromStr(final String dateStr) { DateTime dateTime = new DateTime(); if (!TextUtils.isEmpty(dateStr)) { try {//from w w w .jav a 2 s. c o m dateTime = DateTime.parse(dateStr, ISODateTimeFormat.dateTimeParser()); } catch (Exception e) { Log.i("Exception:", e.getMessage()); } } return dateTime; }