From 3aad03b9ec3a00d4515b723e19f037765ae3b156 Mon Sep 17 00:00:00 2001 From: misaochan Date: Fri, 12 Feb 2016 16:23:18 +1300 Subject: [PATCH] Moved getLastKnownLocation and onLocationChanged --- .../java/fr/free/nrw/commons/upload/GPSExtractor.java | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/commons/src/main/java/fr/free/nrw/commons/upload/GPSExtractor.java b/commons/src/main/java/fr/free/nrw/commons/upload/GPSExtractor.java index 44813e82a..1b88f3ea1 100644 --- a/commons/src/main/java/fr/free/nrw/commons/upload/GPSExtractor.java +++ b/commons/src/main/java/fr/free/nrw/commons/upload/GPSExtractor.java @@ -45,6 +45,8 @@ public class GPSExtractor { myLocationListener = new MyLocationListener(); locationManager.requestLocationUpdates(provider, 400, 1, myLocationListener); + Location location = locationManager.getLastKnownLocation(provider); + myLocationListener.onLocationChanged(location); } protected void unregisterLocationManager() { @@ -76,15 +78,6 @@ public class GPSExtractor { boolean gpsPrefEnabled = gpsPreferenceEnabled(); if (gpsPrefEnabled) { - //If pref enabled, get current location - Location location = locationManager.getLastKnownLocation(provider); - - if (location != null) { - myLocationListener.onLocationChanged(location); - } else { - //calling method is equipped to deal with null return value - return null; - } Log.d(TAG, "Current location values: Lat = " + currentLatitude + " Long = " + currentLongitude); String currentCoords = String.valueOf(currentLatitude) + "|" + String.valueOf(currentLongitude); return currentCoords;