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