-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Description
Move cursor declaration outside try block and close it when not null when exception is trown.
private int getExifOrientation(String sourceUri) {
int exifOrientation = ORIENTATION_0;
if (sourceUri.startsWith(ContentResolver.SCHEME_CONTENT)) {
final String[] columns = { MediaStore.Images.Media.ORIENTATION };
Cursor cursor = null;
try {
cursor = getContext().getContentResolver().query(Uri.parse(sourceUri), columns, null, null, null);
// if (cursor != null) {
if (cursor.moveToFirst()) {
int orientation = cursor.getInt(0);
if (VALID_ORIENTATIONS.contains(orientation) && orientation != ORIENTATION_USE_EXIF) {
exifOrientation = orientation;
} else {
Log.w(TAG, "Unsupported orientation: " + orientation);
}
}
cursor.close();
// }
} catch (Exception e) {
Log.w(TAG, "Could not get orientation of image from media store");
if (cursor != null) cursor.close();
}
} else if (sourceUri.startsWith(ImageSource.FILE_SCHEME) && !sourceUri.startsWith(ImageSource.ASSET_SCHEME)) {
// ...
}
return exifOrientation;
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels