List of usage examples for android.text TextUtils isEmpty
public static boolean isEmpty(@Nullable CharSequence str)
From source file:Main.java
public static boolean isSupportBluetooth(BluetoothAdapter adapter) { if (adapter != null && !TextUtils.isEmpty(adapter.getAddress())) { return true; }//from w ww . j a v a 2 s .co m return false; }
From source file:Main.java
public static Date parse(String strDate, String pattern) { if (TextUtils.isEmpty(strDate)) { return null; }//from w w w.j a v a2 s . c o m try { SimpleDateFormat df = new SimpleDateFormat(pattern); return df.parse(strDate); } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:Main.java
public static boolean isValidEmail(final String emailAddr) { if (TextUtils.isEmpty(emailAddr)) return false; Pattern pattern = Pattern.compile("[\\w\\.\\-]+@([\\w\\-]+\\.)+[\\w\\-]+", Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(emailAddr); return matcher.matches(); }
From source file:Main.java
public static boolean isEmptys(String... editTexts) { for (String ed : editTexts) { String str = ed.trim();//from w w w . j av a 2 s . c o m if (TextUtils.isEmpty(str)) { return true; } } return false; }
From source file:Main.java
public static void show(Context context, String info) { if (TextUtils.isEmpty(info)) return;/*from w ww.j av a2s .c o m*/ Toast.makeText(context, info, Toast.LENGTH_SHORT).show(); }
From source file:Main.java
public static boolean isEmail(String email) { if (TextUtils.isEmpty(email)) return false; String expression = "^[\\w\\.-]+@([\\w\\-]+\\.)+[A-Z]{2,4}$"; Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE); Matcher matcher = pattern.matcher(email); if (matcher.matches()) return true; else//from ww w . j a v a 2 s. c om return false; }
From source file:Main.java
public static void shareAppInfo(Context context, String info) { if (!TextUtils.isEmpty(info)) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, info); context.startActivity(intent);//from ww w. ja va2 s. co m } }
From source file:Main.java
public static int getResourceId(Context context, String resourcesName, String type) { if (null == context || TextUtils.isEmpty(resourcesName) || TextUtils.isEmpty(type)) { return -1; }// ww w . j av a 2 s. c om return context.getResources().getIdentifier(resourcesName, type, context.getPackageName()); }
From source file:Main.java
public static String patternCode(String patternContent) { if (TextUtils.isEmpty(patternContent)) { return null; }// w w w . ja v a 2s .c o m Pattern p = Pattern.compile("(?<!\\d)\\d{6}(?!\\d)"); Matcher matcher = p.matcher(patternContent); if (matcher.find()) { return matcher.group(); } return null; }
From source file:Main.java
public static String getLangCode() { String lang_code = Locale.getDefault().toString(); if (!TextUtils.isEmpty(lang_code)) { if (lang_code.startsWith("zh") && !lang_code.endsWith("CN")) { lang_code = "zh_TW"; }/*www . j av a 2s .com*/ if (lang_code.startsWith("en")) { lang_code = "en_US"; } } else { lang_code = "zh_CN"; } return lang_code; }