Class PictureFileUtils
-
- All Implemented Interfaces:
public class PictureFileUtils
-
-
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
-
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)
读取图片属性:旋转的角度 static Bitmap
rotatingImageView(int angle, Bitmap bitmap)
旋转Bitmap static void
saveBitmapFile(Bitmap bitmap, File file)
static String
createDir(Context context, String filename)
创建文件夹 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)
生成uri static String
extSuffix(InputStream input)
获取图片后缀 static void
rotateImage(int degree, String path)
判断拍照 图片是否旋转 static String
rotateImageToAndroidQ(Context context, int degree, String path, String newFileName)
判断拍照 图片是否旋转 -
-
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)
读取图片属性:旋转的角度
- Parameters:
path
- 图片绝对路径- Returns:
degree旋转的角度
-
rotatingImageView
static Bitmap rotatingImageView(int angle, Bitmap bitmap)
旋转Bitmap
-
saveBitmapFile
static void saveBitmapFile(Bitmap bitmap, File file)
-
createDir
static String createDir(Context context, String filename)
创建文件夹
-
getDCIMCameraPath
static String getDCIMCameraPath(Context ctx, String mimeType)
-
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
-
getDiskCacheDir
static String getDiskCacheDir(Context ctx)
-
parUri
static Uri parUri(Context context, File cameraFile)
生成uri
-
extSuffix
static String extSuffix(InputStream input)
获取图片后缀
-
rotateImage
static void rotateImage(int degree, String path)
判断拍照 图片是否旋转
-
rotateImageToAndroidQ
static String rotateImageToAndroidQ(Context context, int degree, String path, String newFileName)
判断拍照 图片是否旋转
-
-
-
-