List of usage examples for android.text TextUtils isEmpty
public static boolean isEmpty(@Nullable CharSequence str)
From source file:Main.java
public static String getIMEI(Context context) { String imeiStr = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId(); if (TextUtils.isEmpty(imeiStr)) { imeiStr = "000000000000000"; }/*w ww . jav a 2 s.co m*/ return imeiStr; }
From source file:Main.java
public static boolean checkFieldFull(EditText... editTexts) { for (EditText editText : editTexts) { if (!TextUtils.isEmpty(editText.getText())) { return true; }/* w ww . j av a 2s . co m*/ } return false; }
From source file:Main.java
public static String removeZero(String s) { if (!TextUtils.isEmpty(s)) { try {/*w w w . jav a 2 s. c o m*/ double d = Double.parseDouble(s); DecimalFormat format = new DecimalFormat("0.#"); return format.format(d); } catch (Exception e) { return "0"; } } else { return "0"; } }
From source file:Main.java
public static String getAppMainActivity(Context context, String packageName) { if (TextUtils.isEmpty(packageName)) { return ""; }/*from w w w . j av a 2 s .co m*/ final Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setPackage(packageName); final ResolveInfo res = context.getPackageManager().resolveActivity(intent, 0); if (res == null || res.activityInfo == null) { return ""; } return res.activityInfo.name; }
From source file:Main.java
public static boolean checkFieldsEmpty(EditText... editTexts) { for (EditText editText : editTexts) { if (TextUtils.isEmpty(editText.getText())) { return true; }/*w ww.ja v a 2 s.c o m*/ } return false; }
From source file:Main.java
public static String getDeviceID(Context context) { String id = ((TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId(); if (TextUtils.isEmpty(id)) { id = "000000000000000"; }/* w ww .j a v a2 s . com*/ return id; }
From source file:Main.java
public static boolean isMobile(String mobile) { Matcher localMatcher = Pattern.compile("^1[3-8]+\\d{9}$").matcher(mobile); if ((!TextUtils.isEmpty(mobile)) && (localMatcher.matches())) { return true; }//from w w w . ja v a 2 s . c om return false; }
From source file:Main.java
public static Bitmap getVideoScreenshotBitmap(Context context, String videoPath) { if (TextUtils.isEmpty(videoPath) || !new File(videoPath).exists()) { return null; }//ww w .j ava 2 s . c om Bitmap bitmap = null; MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever(); mediaMetadataRetriever.setDataSource(videoPath); bitmap = mediaMetadataRetriever.getFrameAtTime(0); return bitmap; }
From source file:Main.java
/** * Translates avatar id to string that can be used by disc cache as file name. * @param avatarId Avatar ID.//from w w w. j ava 2 s. co m * @return Key/file name for disk cache. */ public static String getDiskCacheKey(final String avatarId) { if (!TextUtils.isEmpty(avatarId)) { return avatarId.replace("|", "").toLowerCase(); } return null; }
From source file:Main.java
public static String formateDateToString(Object longDate) { String time = null;/*from w ww. j a va 2s . c om*/ if (longDate instanceof String) { time = (String) longDate; if (!TextUtils.isEmpty(time) && time.length() >= 16) { time = ((String) longDate).substring(0, 16); } } else if (longDate instanceof Long) { SimpleDateFormat formatDate = new SimpleDateFormat("yyyy-MM-dd HH:mm"); Date date = new Date((Long) longDate); time = formatDate.format(date); } return time.trim(); }