mirror of
https://github.com/apache/cordova-plugin-camera.git
synced 2025-01-31 12:42:50 +08:00
fix(android): return error if file url is null (#632)
This commit is contained in:
parent
eb7fc333ee
commit
e2ecd7fe91
@ -686,12 +686,17 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
|
|||||||
LOG.d(LOG_TAG, "File location is: " + fileLocation);
|
LOG.d(LOG_TAG, "File location is: " + fileLocation);
|
||||||
|
|
||||||
String uriString = uri.toString();
|
String uriString = uri.toString();
|
||||||
|
String finalLocation = fileLocation != null ? fileLocation : uriString;
|
||||||
String mimeType = FileHelper.getMimeType(uriString, this.cordova);
|
String mimeType = FileHelper.getMimeType(uriString, this.cordova);
|
||||||
|
|
||||||
|
if (finalLocation == null) {
|
||||||
|
this.failPicture("Error retrieving result.");
|
||||||
|
} else {
|
||||||
|
|
||||||
// If you ask for video or the selected file doesn't have JPEG or PNG mime type
|
// If you ask for video or the selected file doesn't have JPEG or PNG mime type
|
||||||
// there will be no attempt to resize any returned data
|
// there will be no attempt to resize any returned data
|
||||||
if (this.mediaType == VIDEO || !(JPEG_MIME_TYPE.equalsIgnoreCase(mimeType) || PNG_MIME_TYPE.equalsIgnoreCase(mimeType))) {
|
if (this.mediaType == VIDEO || !(JPEG_MIME_TYPE.equalsIgnoreCase(mimeType) || PNG_MIME_TYPE.equalsIgnoreCase(mimeType))) {
|
||||||
this.callbackContext.success(fileLocation);
|
this.callbackContext.success(finalLocation);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
@ -701,7 +706,7 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
|
|||||||
(destType == FILE_URI || destType == NATIVE_URI) && !this.correctOrientation &&
|
(destType == FILE_URI || destType == NATIVE_URI) && !this.correctOrientation &&
|
||||||
mimeType != null && mimeType.equalsIgnoreCase(getMimetypeForFormat(encodingType)))
|
mimeType != null && mimeType.equalsIgnoreCase(getMimetypeForFormat(encodingType)))
|
||||||
{
|
{
|
||||||
this.callbackContext.success(uriString);
|
this.callbackContext.success(finalLocation);
|
||||||
} else {
|
} else {
|
||||||
Bitmap bitmap = null;
|
Bitmap bitmap = null;
|
||||||
try {
|
try {
|
||||||
@ -738,7 +743,7 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
|
|||||||
this.failPicture("Error retrieving image.");
|
this.failPicture("Error retrieving image.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.callbackContext.success(fileLocation);
|
this.callbackContext.success(finalLocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (bitmap != null) {
|
if (bitmap != null) {
|
||||||
@ -750,6 +755,8 @@ public class CameraLauncher extends CordovaPlugin implements MediaScannerConnect
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the camera view exits.
|
* Called when the camera view exits.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user