Skip to content

Commit

Permalink
Merge pull request #4 from Groww/videocapturecrash
Browse files Browse the repository at this point in the history
Image picker file provider not working issue
  • Loading branch information
john1jan authored May 5, 2020
2 parents 8befbf8 + f03043e commit 6a2a7fb
Show file tree
Hide file tree
Showing 2 changed files with 194 additions and 188 deletions.
11 changes: 6 additions & 5 deletions android/src/main/java/com/imagepicker/ImagePickerModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.provider.MediaStore;
import android.provider.Settings;

Expand Down Expand Up @@ -370,7 +371,7 @@ public void onActivityResult(Activity activity, int requestCode, int resultCode,

case REQUEST_LAUNCH_IMAGE_LIBRARY:
uri = data.getData();
String realPath = getRealPathFromURI(uri);
String realPath = getRealPathFromURI(uri, Environment.DIRECTORY_PICTURES);
final boolean isUrl = !TextUtils.isEmpty(realPath) &&
Patterns.WEB_URL.matcher(realPath).matches();
if (realPath == null || isUrl) {
Expand All @@ -393,15 +394,15 @@ public void onActivityResult(Activity activity, int requestCode, int resultCode,
case REQUEST_LAUNCH_VIDEO_LIBRARY:
if (data != null && data.getData() != null) {
responseHelper.putString("uri", data.getData().toString());
responseHelper.putString("path", getRealPathFromURI(data.getData()));
responseHelper.putString("path", getRealPathFromURI(data.getData(),Environment.DIRECTORY_MOVIES));
responseHelper.invokeResponse(callback);
callback = null;
}
return;

case REQUEST_LAUNCH_VIDEO_CAPTURE:
if (data != null && data.getData() != null) {
final String path = getRealPathFromURI(data.getData());
final String path = getRealPathFromURI(data.getData(),Environment.DIRECTORY_MOVIES);
responseHelper.putString("uri", data.getData().toString());
responseHelper.putString("path", path);
fileScan(reactContext, path);
Expand Down Expand Up @@ -608,8 +609,8 @@ private boolean isCameraAvailable() {
}

private @NonNull
String getRealPathFromURI(@NonNull final Uri uri) {
return RealPathUtil.getRealPathFromURI(reactContext, uri);
String getRealPathFromURI(@NonNull final Uri uri,String directoryType) {
return RealPathUtil.getRealPathFromURI(reactContext, uri,directoryType);
}

/**
Expand Down
Loading

0 comments on commit 6a2a7fb

Please sign in to comment.