List of usage examples for android.text TextUtils isEmpty
public static boolean isEmpty(@Nullable CharSequence str)
From source file:Main.java
public static String getIMSI(Context context) { TelephonyManager mTelephonyMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String imsi = mTelephonyMgr.getSubscriberId(); if (TextUtils.isEmpty(imsi)) { imsi = "000000000000000"; }// ww w .j a v a 2 s .c o m return imsi; }
From source file:Main.java
public static boolean isSyncConfigured(Context context) { String syncSource = PreferenceManager.getDefaultSharedPreferences(context).getString("syncSource", ""); if (TextUtils.isEmpty(syncSource)) return false; else/*from www . j a v a2 s.c om*/ return true; }
From source file:Main.java
public static boolean saveObject(@NonNull Context context, Object obj, String fileName) { if (obj == null || TextUtils.isEmpty(fileName)) { return false; }// w w w . jav a 2 s .c om FileOutputStream fos = null; ObjectOutputStream oos = null; try { fos = context.openFileOutput(fileName, Context.MODE_PRIVATE); oos = new ObjectOutputStream(fos); oos.writeObject(obj); oos.flush(); return true; } catch (Exception e) { e.printStackTrace(); return false; } finally { try { if (fos != null) fos.close(); if (oos != null) oos.close(); } catch (Exception e) { e.printStackTrace(); } } }
From source file:Main.java
/** * get image size by path//from w ww. j a v a2 s . c om */ public static Point getImageSize(String path) throws IOException { if (TextUtils.isEmpty(path)) { return null; } BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; if (path.startsWith("http")) { BitmapFactory.decodeStream(new URL(path).openStream(), null, options); } else { BitmapFactory.decodeFile(path, options); } return new Point(options.outWidth, options.outHeight); }
From source file:Main.java
public static String getPhone(Context context) { TelephonyManager mTelephonyMgr = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); String num = mTelephonyMgr.getLine1Number(); if (TextUtils.isEmpty(num)) { return ""; } else {/*from ww w .ja v a2 s.c o m*/ return num; } }
From source file:Main.java
private static boolean isEmpty(String target) { return TextUtils.isEmpty(target); }
From source file:Main.java
public static boolean isNull(String val) { // Log.d("val", val); return TextUtils.isEmpty(val) || "null".equals(val) || null == val; }
From source file:Main.java
public static void toastMessage(Context context, String message) { if (context == null) { return;// w w w. j ava 2 s . c o m } if (TextUtils.isEmpty(message)) { sToast = null; return; } if (sToast != null) { sToast.cancel(); sToast = null; } sToast = getToast(context); sToast.setDuration(Toast.LENGTH_SHORT); sToast.setText(message); sToast.show(); }
From source file:Main.java
public static WeakReference<Bitmap> autoRotateBitmap(String path, WeakReference<Bitmap> bmp) { if (TextUtils.isEmpty(path) || bmp == null || bmp.get() == null) return bmp; int degree = getDegress(path); if (degree != 0) { bmp = rotateBitmap(bmp, degree); }/*from ww w.j ava2s . com*/ return bmp; }
From source file:Main.java
public static List<String> getSubtitlePath(String videoPath) { List<String> sbPathList = new ArrayList<String>(); if (TextUtils.isEmpty(videoPath)) return sbPathList; if (videoPath.contains("file")) { videoPath = videoPath.substring(7); }//from ww w.j ava2s. c o m int end = videoPath.lastIndexOf("/", videoPath.length()); String path = videoPath.substring(0, end + 1); end = videoPath.lastIndexOf(".", videoPath.length()); if (-1 == end || null == path) return sbPathList; String subffix = videoPath.substring(0, end); File files = new File(path); if ((files != null) && (files.exists()) && (files.isDirectory())) { File[] filesInDir = files.listFiles(); long count = filesInDir.length; for (int num = 0; num < count; num++) { String filePath = filesInDir[num].getPath(); File subTitleFile = new File(filePath); if ((subTitleFile != null) && (subTitleFile.isFile()) && (subTitleFile.canRead())) { int pos = filePath.lastIndexOf(".", filePath.length()); String sub = filePath.substring(pos + 1, filePath.length()); if ((filePath.startsWith(subffix)) && (sub != null) && ((sub.equalsIgnoreCase("srt")) || (sub.equalsIgnoreCase("ass")) || (sub.equalsIgnoreCase("smi")) || (sub.equalsIgnoreCase("ssa")) || (sub.equalsIgnoreCase("sub")))) { sbPathList.add(filePath); } } } if (sbPathList.size() != 0) { return sbPathList; } } return sbPathList; }