List of usage examples for android.text TextUtils isEmpty
public static boolean isEmpty(@Nullable CharSequence str)
From source file:Main.java
public static boolean isValid(String expiry) { if (TextUtils.isEmpty(expiry)) { return false; }// www .j a v a2s.c om if (expiry.length() != LENGTH_EXPIRY_DATE) { return false; } // check all numeric if (!TextUtils.isDigitsOnly(expiry)) { return false; } // check month valid int month = Integer.parseInt(expiry.substring(0, 2)); if (month < 1 || month > 12) { return false; } return true; }
From source file:Main.java
public static void sendSmsBySystem(Context context, String phone, String body) { if (TextUtils.isEmpty(phone)) return;/*ww w .j ava2 s . com*/ Uri uri = Uri.parse("smsto:" + phone); Intent intent = new Intent(Intent.ACTION_SENDTO, uri); intent.putExtra("sms_body", body); context.startActivity(intent); }
From source file:Main.java
public static void assertNotEmpty(String text, String parameterName) throws AssertionError { check(TextUtils.isEmpty(text) || TextUtils.isEmpty(text.trim()), parameterName + " can't be empty."); }
From source file:Main.java
public static String getImageSavePath(String fileName) { if (TextUtils.isEmpty(fileName)) { return null; }//from w w w. j a v a 2 s .c o m final File folder = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "MGJ-IM" + File.separator + "images"); if (!folder.exists()) { folder.mkdirs(); } return folder.getAbsolutePath() + File.separator + fileName; }
From source file:Main.java
public static String md5(String str) { if (TextUtils.isEmpty(str)) { return null; }//from w w w .j a v a 2 s. c o m try { MessageDigest messageDigest = MessageDigest.getInstance("MD5"); messageDigest.update(str.getBytes()); return encodeHex(messageDigest.digest()); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:Main.java
public static void updateTitle(TextView view, String title) { if (view != null && !TextUtils.isEmpty(title)) { view.setVisibility(View.VISIBLE); view.setSelected(true);/*from ww w .j a v a 2 s. c o m*/ view.setText(title); } }
From source file:Main.java
public static boolean deleteFolderFile(String filePath, boolean deleteThisPath) { if (!TextUtils.isEmpty(filePath)) { try {//from w w w. j ava 2 s . c om File file = new File(filePath); if (file.isDirectory()) { File files[] = file.listFiles(); for (int i = 0; i < files.length; i++) { deleteFolderFile(files[i].getAbsolutePath(), true); } } if (deleteThisPath) { if (!file.isDirectory()) { file.delete(); } else { if (file.listFiles().length == 0) { file.delete(); } } } return true; } catch (Exception e) { e.printStackTrace(); } } return false; }
From source file:Main.java
public static boolean isMediaInDateRange(String mediaTimeStamp) { if (!TextUtils.isEmpty(mediaTimeStamp)) { Date currentDate = new Date(); long mediaDateLong = Long.valueOf(mediaTimeStamp) * 1000L; long diff = currentDate.getTime() - mediaDateLong; if (diff < IG_MEDIA_PHOTOS_RANGE) { return true; }/*ww w . ja v a 2 s . com*/ } return false; }
From source file:Main.java
/** * * @param str//from w w w . j av a 2 s. c o m * @return */ public static String isEmptyOrNull(String str) { if (TextUtils.isEmpty(str)) { return DEFAULT_EMPTY; } return str; }
From source file:Main.java
public static boolean isPhoneNumber(String phoneNumber) { if (phoneNumber == null) return false; if (TextUtils.isEmpty(phoneNumber)) return false; Pattern pattern = Pattern.compile("^(86|\\+86)?[1][3,4,5,8][0-9]{9}$"); Matcher m = pattern.matcher(phoneNumber); return m.matches(); }