mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Merge pull request #226 from misaochan/fix-gps-extractor
Fix recent GPSExtractor crash
This commit is contained in:
commit
22b6ce5dbf
1 changed files with 12 additions and 5 deletions
|
|
@ -9,6 +9,7 @@ import android.location.LocationManager;
|
|||
import android.media.ExifInterface;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.util.Log;
|
||||
import java.io.IOException;
|
||||
|
|
@ -82,6 +83,7 @@ public class GPSExtractor {
|
|||
* Extracts geolocation of image from EXIF data.
|
||||
* @return coordinates of image as string (needs to be passed as a String in API query)
|
||||
*/
|
||||
@Nullable
|
||||
public String getCoords(boolean useGPS) {
|
||||
|
||||
ExifInterface exif;
|
||||
|
|
@ -117,7 +119,7 @@ public class GPSExtractor {
|
|||
// No coords found
|
||||
return null;
|
||||
}
|
||||
} else if(exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE) == null) {
|
||||
} else if (exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE) == null) {
|
||||
return null;
|
||||
} else {
|
||||
imageCoordsExists = true;
|
||||
|
|
@ -127,11 +129,16 @@ public class GPSExtractor {
|
|||
latitude_ref = exif.getAttribute(ExifInterface.TAG_GPS_LATITUDE_REF);
|
||||
longitude = exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE);
|
||||
longitude_ref = exif.getAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF);
|
||||
Log.d("Image", "Latitude: " + latitude + " " + latitude_ref);
|
||||
Log.d("Image", "Longitude: " + longitude + " " + longitude_ref);
|
||||
|
||||
decimalCoords = getDecimalCoords(latitude, latitude_ref, longitude, longitude_ref);
|
||||
return decimalCoords;
|
||||
if (latitude!=null && latitude_ref!=null && longitude!=null && longitude_ref!=null) {
|
||||
Log.d("Image", "Latitude: " + latitude + " " + latitude_ref);
|
||||
Log.d("Image", "Longitude: " + longitude + " " + longitude_ref);
|
||||
|
||||
decimalCoords = getDecimalCoords(latitude, latitude_ref, longitude, longitude_ref);
|
||||
return decimalCoords;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue