Class PictureFileUtils
-
- All Implemented Interfaces:
public class PictureFileUtils
-
-
Field Summary
Fields Modifier and Type Field Description public final static StringPOSTFIXpublic final static StringPOST_VIDEOpublic final static StringPOST_AUDIO
-
Method Summary
Modifier and Type Method Description static FilecreateCameraFile(Context context, int type, String fileName, String format)static booleanisExternalStorageDocument(Uri uri)static booleanisDownloadsDocument(Uri uri)static booleanisMediaDocument(Uri uri)static booleanisGooglePhotosUri(Uri uri)static StringgetDataColumn(Context context, Uri uri, String selection, Array<String> selectionArgs)Get the value of the data column for this Uri. static StringgetPath(Context context, Uri uri)Get a file path from a Uri. static longgetMediaSize(Context context, String path)static intreadPictureDegree(Context context, String path)读取图片属性:旋转的角度 static BitmaprotatingImageView(int angle, Bitmap bitmap)旋转Bitmap static voidsaveBitmapFile(Bitmap bitmap, File file)static StringcreateDir(Context context, String filename)创建文件夹 static StringgetDCIMCameraPath(Context ctx, String mimeType)static voiddeleteCacheDirFile(Context mContext, int type)set empty PictureSelector Cache static voiddeleteAllCacheDirFile(Context context)set empty PictureSelector Cache static StringgetDiskCacheDir(Context ctx)static UriparUri(Context context, File cameraFile)生成uri static StringextSuffix(InputStream input)获取图片后缀 static voidrotateImage(int degree, String path)判断拍照 图片是否旋转 static StringrotateImageToAndroidQ(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)
判断拍照 图片是否旋转
-
-
-
-