List of usage examples for android.text TextUtils isEmpty
public static boolean isEmpty(@Nullable CharSequence str)
From source file:Main.java
public static void makeingCalls(Context context, String phoneNum) { if (TextUtils.isEmpty(phoneNum)) { return;/*from w w w . jav a 2s .c o m*/ } Intent phoneIntent = new Intent("android.intent.action.CALL", Uri.parse("tel:" + phoneNum)); phoneIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(phoneIntent); }
From source file:Main.java
public static boolean isEmailAdd(String email) { String emailRegex = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$"; if (TextUtils.isEmpty(email)) return false; else/* w ww . j a va 2 s .c o m*/ return email.matches(emailRegex); }
From source file:Main.java
public static Bitmap bitmapFromBase64(String base64Str) { if (TextUtils.isEmpty(base64Str)) { return null; } else {//ww w. jav a 2s. c om byte[] bytes = Base64.decode(base64Str, Base64.NO_WRAP); return BitmapFactory.decodeByteArray(bytes, 0, bytes.length); } }
From source file:Main.java
public static boolean isNotNull(String jsonStr, String key) { if (TextUtils.isEmpty(key)) { return false; }/*from w w w. ja va2s .c om*/ try { JSONObject jsonObject = new JSONObject(jsonStr); return !jsonObject.isNull(key); } catch (Exception e) { } return false; }
From source file:Main.java
public static String matchUrl(String text) { if (TextUtils.isEmpty(text)) { return null; }/*w w w . ja va 2 s .c om*/ Pattern p = Pattern.compile("[http]+[://]+[0-9A-Za-z:/[-]_#[?][=][.][&]]*", Pattern.CASE_INSENSITIVE); Matcher matcher = p.matcher(text); if (matcher.find()) { return matcher.group(); } else { return null; } }
From source file:Main.java
public static Bitmap getMediaFrame(String filePath) { if (TextUtils.isEmpty(filePath)) { return null; }//from w w w . j ava 2s .c o m Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(filePath, MediaStore.Images.Thumbnails.MINI_KIND); bitmap = ThumbnailUtils.extractThumbnail(bitmap, 720, 387); return bitmap; }
From source file:Main.java
public static String getImageType(String url, String type) { if (TextUtils.isEmpty(url)) { return null; }/* www . java2s.c o m*/ return url.concat(type); }
From source file:Main.java
public static long parseDateTime(String dateTime) { if (TextUtils.isEmpty(dateTime)) { return 0; }/*from w w w . j av a 2s. com*/ long time = 0; try { Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(dateTime); if (null != date) { time = date.getTime(); } } catch (ParseException e) { e.printStackTrace(); } return time; }
From source file:Main.java
public static Calendar str2calendar(String str) { if (TextUtils.isEmpty(str)) return null; String[] strList = str.split("-"); if (strList.length != 3 || !isNumber(strList[0]) || !isNumber(strList[1]) || !isNumber(strList[2])) return null; int year = Integer.parseInt(strList[0]); int month = Integer.parseInt(strList[1]); int day = Integer.parseInt(strList[2]); Calendar result = Calendar.getInstance(); result.set(year, month - 1, day);// w w w.j ava 2 s.c o m return result; }
From source file:Main.java
public static String getFileName(String url) { if (TextUtils.isEmpty(url)) { return ""; }//from ww w . ja va 2 s .c o m return url.substring(url.lastIndexOf("/") + 1); }