Class PictureFileUtils

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
      public final static String POSTFIX
      public final static String POST_VIDEO
      public final static String POST_AUDIO
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      static File createCameraFile(Context context, int type, String fileName, String format)
      static boolean isExternalStorageDocument(Uri uri)
      static boolean isDownloadsDocument(Uri uri)
      static boolean isMediaDocument(Uri uri)
      static boolean isGooglePhotosUri(Uri uri)
      static String getDataColumn(Context context, Uri uri, String selection, Array<String> selectionArgs) Get the value of the data column for this Uri.
      static String getPath(Context context, Uri uri) Get a file path from a Uri.
      static long getMediaSize(Context context, String path)
      static int readPictureDegree(Context context, String path) Read image EXIF rotation angle
      static Bitmap rotatingImageView(int angle, Bitmap bitmap) Rotate Bitmap
      static void saveBitmapFile(Bitmap bitmap, File file)
      static String createDir(Context context, String filename) Create directory
      static String getDCIMCameraPath(Context ctx, String mimeType)
      static void deleteCacheDirFile(Context mContext, int type) set empty PictureSelector Cache
      static void deleteAllCacheDirFile(Context context) set empty PictureSelector Cache
      static String getDiskCacheDir(Context ctx)
      static Uri parUri(Context context, File cameraFile) Generate URI
      static String extSuffix(InputStream input) Get image suffix
      static void rotateImage(int degree, String path) Check and rotate captured image if needed
      static String rotateImageToAndroidQ(Context context, int degree, String path, String newFileName) Check and rotate captured image for Android Q
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • createCameraFile

         static File createCameraFile(Context context, int type, String fileName, String format)
      • isExternalStorageDocument

         static boolean isExternalStorageDocument(Uri uri)
        Parameters:
        uri - The Uri to check.
        Returns:

        Whether the Uri authority is ExternalStorageProvider.

      • isDownloadsDocument

         static boolean isDownloadsDocument(Uri uri)
        Parameters:
        uri - The Uri to check.
        Returns:

        Whether the Uri authority is DownloadsProvider.

      • isMediaDocument

         static boolean isMediaDocument(Uri uri)
        Parameters:
        uri - The Uri to check.
        Returns:

        Whether the Uri authority is MediaProvider.

      • isGooglePhotosUri

         static boolean isGooglePhotosUri(Uri uri)
        Parameters:
        uri - The Uri to check.
        Returns:

        Whether the Uri authority is Google Photos.

      • getDataColumn

         static String getDataColumn(Context context, Uri uri, String selection, Array<String> selectionArgs)

        Get the value of the data column for this Uri. This is useful for MediaStore Uris, and other file-based ContentProviders.

        Parameters:
        context - The context.
        uri - The Uri to query.
        selection - (Optional) Filter used in the query.
        selectionArgs - (Optional) Selection arguments used in the query.
        Returns:

        The value of the _data column, which is typically a file path.

      • getPath

         static String getPath(Context context, Uri uri)

        Get a file path from a Uri. This will get the the path for Storage Access Framework Documents, as well as the _data field for the MediaStore and other file-based ContentProviders. Callers should check whether the path is local before assuming it represents a local file.

        Parameters:
        context - The context.
        uri - The Uri to query.
      • getMediaSize

         static long getMediaSize(Context context, String path)
      • readPictureDegree

         static int readPictureDegree(Context context, String path)

        Read image EXIF rotation angle

        Parameters:
        path - absolute image path
        Returns:

        degree the rotation angle

      • rotatingImageView

         static Bitmap rotatingImageView(int angle, Bitmap bitmap)

        Rotate Bitmap

      • saveBitmapFile

         static void saveBitmapFile(Bitmap bitmap, File file)
      • createDir

         static String createDir(Context context, String filename)

        Create directory

      • deleteCacheDirFile

         static void deleteCacheDirFile(Context mContext, int type)

        set empty PictureSelector Cache

        Parameters:
        type - image or video ...
      • deleteAllCacheDirFile

         static void deleteAllCacheDirFile(Context context)

        set empty PictureSelector Cache

      • parUri

         static Uri parUri(Context context, File cameraFile)

        Generate URI

      • extSuffix

         static String extSuffix(InputStream input)

        Get image suffix

      • rotateImage

         static void rotateImage(int degree, String path)

        Check and rotate captured image if needed

      • rotateImageToAndroidQ

         static String rotateImageToAndroidQ(Context context, int degree, String path, String newFileName)

        Check and rotate captured image for Android Q