Skip to content

Commit

Permalink
Fixed bug and add new features
Browse files Browse the repository at this point in the history
  • Loading branch information
Yanqilong committed Dec 1, 2016
1 parent 98830ac commit 62a6725
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 62a6725

Please sign in to comment.