mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Added try catch for getRealPath
This commit is contained in:
parent
6eea283dc4
commit
f8e5e9c50e
1 changed files with 16 additions and 15 deletions
|
|
@ -167,14 +167,21 @@ public class ShareActivity
|
|||
}
|
||||
|
||||
private String getRealPathFromURI(Uri contentUri) {
|
||||
String[] proj = { MediaStore.Images.Media.DATA };
|
||||
Cursor cursor = getContentResolver().query(contentUri, proj, null, null, null);
|
||||
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
||||
cursor.moveToFirst();
|
||||
|
||||
String cursorString = cursor.getString(column_index);
|
||||
cursor.close();
|
||||
return cursorString;
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
String[] proj = {MediaStore.Images.Media.DATA};
|
||||
cursor = getContentResolver().query(contentUri, proj, null, null, null);
|
||||
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
||||
cursor.moveToFirst();
|
||||
return cursor.getString(column_index);
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, e);
|
||||
return "";
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -208,14 +215,12 @@ public class ShareActivity
|
|||
String filePath = getRealPathFromURI(mediaUri);
|
||||
Log.d(TAG, "Filepath: " + filePath);
|
||||
|
||||
|
||||
if (filePath != null) {
|
||||
if (filePath != null && !filePath.equals("")) {
|
||||
//extract the coordinates of image in decimal degrees
|
||||
Log.d(TAG, "Calling GPSExtractor");
|
||||
GPSExtractor imageObj = new GPSExtractor(filePath);
|
||||
String decimalCoords = imageObj.getCoords();
|
||||
|
||||
|
||||
if (decimalCoords != null) {
|
||||
double decLongitude = imageObj.getDecLongitude();
|
||||
double decLatitude = imageObj.getDecLatitude();
|
||||
|
|
@ -239,16 +244,12 @@ public class ShareActivity
|
|||
Log.d(TAG, "Cache found, setting categoryList in MwVolleyApi to " + displayCatList.toString());
|
||||
MwVolleyApi.setGpsCat(displayCatList);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(savedInstanceState != null) {
|
||||
contribution = savedInstanceState.getParcelable("contribution");
|
||||
}
|
||||
|
||||
requestAuthToken();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue