If else block for gps prefs

This commit is contained in:
misaochan 2016-02-05 18:31:46 +13:00
parent 5492aa7551
commit 11e291cb41

View file

@ -65,6 +65,8 @@ public class GPSExtractor {
//Check what user's preference is for automatic location detection //Check what user's preference is for automatic location detection
boolean gpsPrefEnabled = gpsPreferenceEnabled(); boolean gpsPrefEnabled = gpsPreferenceEnabled();
if (gpsPrefEnabled) {
//If pref enabled, set up LocationListener to get current location
LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria(); Criteria criteria = new Criteria();
String provider = locationManager.getBestProvider(criteria, true); String provider = locationManager.getBestProvider(criteria, true);
@ -75,14 +77,17 @@ public class GPSExtractor {
if (location != null) { if (location != null) {
myLocationListener.onLocationChanged(location); myLocationListener.onLocationChanged(location);
} } else {
else {
//calling method is equipped to deal with null return value //calling method is equipped to deal with null return value
return null; return null;
} }
Log.d(TAG, "Current location values: Lat = " + currentLatitude + " Long = " + currentLongitude); Log.d(TAG, "Current location values: Lat = " + currentLatitude + " Long = " + currentLongitude);
String currentCoords = String.valueOf(currentLatitude) + "|" + String.valueOf(currentLongitude); String currentCoords = String.valueOf(currentLatitude) + "|" + String.valueOf(currentLongitude);
return currentCoords; return currentCoords;
} else {
//Otherwise treat as if no coords found
return null;
}
} else { } else {
imageCoordsExists = true; imageCoordsExists = true;