Skip to content
Permalink
Browse files

Fixed bug and add new features

  • Loading branch information
Yanqilong committed Dec 1, 2016
1 parent 98830ac commit 62a6725a99118ec0ce0f4cf1cd76b2ba70e21745
@@ -254,7 +254,6 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {

@Override
public void onPickMultiple(int limit) {
this.fromType = TImage.FromType.OTHER;
if (PermissionManager.TPermissionType.WAIT.equals(permissionType)) return;
TUtils.startActivityForResult(contextWrap, new TIntentWap(IntentUtils.getPickMultipleIntent(contextWrap, limit), TConstant.RC_PICK_MULTIPLE));
}
@@ -322,6 +321,7 @@ public void onPickFromGallery() {
}

private void selectPicture(int defaultIndex, boolean isCrop) {
this.fromType = TImage.FromType.OTHER;
if (takePhotoOptions != null && takePhotoOptions.isWithOwnGallery()) {
onPickMultiple(1);
return;
@@ -43,27 +43,50 @@ public static Uri convertFileUriToFileProviderUri(Context context,Uri uri){
return uri;

}

/**
* 创建一个用于拍照图片输出路径的Uri,
* 获取一个临时的Uri, 文件名随机生成
* @param context
* @return
*/
public static Uri getUriForFile(Context context, File file) {
return FileProvider.getUriForFile(context,TConstant.getFileProviderName(context), file);
public static Uri getTempUri(Context context){
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(new Date());
File file=new File(Environment.getExternalStorageDirectory(), "/images/"+timeStamp + ".jpg");
if (!file.getParentFile().exists())file.getParentFile().mkdirs();
return getUriForFile(context,file);
}

/**
* 获取一个临时的Uri ,(FileProvider)
* 获取一个临时的Uri, 通过传入字符串路径
*
* @param context
* @param path
* @return
*/
public static Uri getTempUri(Context context){
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(new Date());
File file=new File(Environment.getExternalStorageDirectory(), "/images/"+timeStamp + ".jpg");
public static Uri getTempUri(Context context, String path) {
File file = new File(path);
return getTempUri(context, file);
}

/**
* 获取一个临时的Uri, 通过传入File对象
* @param context
* @return
*/
public static Uri getTempUri(Context context, File file){
if (!file.getParentFile().exists())file.getParentFile().mkdirs();
return getUriForFile(context,file);
}

/**
* 创建一个用于拍照图片输出路径的Uri (FileProvider)
* @param context
* @return
*/
public static Uri getUriForFile(Context context, File file) {
return FileProvider.getUriForFile(context,TConstant.getFileProviderName(context), file);
}

/**
* 将TakePhoto 提供的Uri 解析出文件绝对路径
* @param uri

0 comments on commit 62a6725

Please sign in to comment.
You can’t perform that action at this time.