List of usage examples for android.text TextUtils isEmpty
public static boolean isEmpty(@Nullable CharSequence str)
From source file:Main.java
public static String urlEncode(String msg) { if (TextUtils.isEmpty(msg)) { return null; }//from ww w . j a v a2s.co m try { return URLEncoder.encode(msg, "UTF-8"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
From source file:Main.java
public static String patternCode(String patternContent) { if (TextUtils.isEmpty(patternContent)) { return null; }//from w w w . j a va 2 s . c o m Pattern p = Pattern.compile("(?<!\\d)\\d{4}(?!\\d)"); Matcher matcher = p.matcher(patternContent); if (matcher.find()) { return matcher.group(); } return null; }
From source file:Main.java
public static boolean deleteFile(String path) { if (TextUtils.isEmpty(path)) { return true; }//w w w. j av a2 s. c o m File file = new File(path); if (!file.exists()) { return true; } if (file.isFile()) { return file.delete(); } if (!file.isDirectory()) { return false; } File[] files = file.listFiles(); if (files == null || files.length == 0) { return file.delete(); } for (File f : files) { if (isFileExists(f)) { f.delete(); } else if (f.isDirectory()) { deleteFile(f.getAbsolutePath()); } } return file.delete(); }
From source file:Main.java
public static boolean isValidWebAddress(CharSequence target) { return !TextUtils.isEmpty(target) && Patterns.DOMAIN_NAME.matcher(target).matches(); }
From source file:Main.java
public static boolean createDirectory(String dir) { if (TextUtils.isEmpty(dir)) { return false; }//from w ww . j a v a 2 s . c om boolean result = true; File file = new File(dir); if (!file.exists()) { result = file.mkdirs(); } return result; }
From source file:Main.java
public static boolean isEmailAddress(String emailAddress) { if (!TextUtils.isEmpty(emailAddress)) { Pattern pattern = Pattern.compile("^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$"); Matcher matcher = pattern.matcher(emailAddress); return matcher.find(); }/* w w w .jav a 2 s. com*/ return false; }
From source file:Main.java
@Nullable public static Uri createSDCardUri(String url) { if (TextUtils.isEmpty(url)) { return null; }/*w ww . ja v a 2s. c om*/ return Uri.parse("file:///" + url); }
From source file:Main.java
public static String getMIUIVersion() { if (TextUtils.isEmpty(miui_version)) { miui_version = getSystemProperties("ro.miui.ui.version.name"); }// w w w .ja v a 2 s .c o m return miui_version; }
From source file:Main.java
public static boolean isVehiclePlate(String plate) { String telRegex = "/^[\\u4e00-\\u9fa5]{1}[a-zA-Z]{1}[a-zA-Z_0-9]{5}$/"; if (TextUtils.isEmpty(plate)) return false; else/* w w w .j a v a2 s . c o m*/ return plate.matches(telRegex); }
From source file:Main.java
public static void showToast(Context context, String msg) { if (TextUtils.isEmpty(msg)) { return;//ww w. jav a 2 s . c om } Toast.makeText(context, msg, Toast.LENGTH_SHORT).show(); }