|
|
@ -1,15 +1,14 @@ |
|
|
|
package org.r3pek.pharmacies.utils; |
|
|
|
|
|
|
|
import java.util.LinkedList; |
|
|
|
import com.google.android.maps.GeoPoint; |
|
|
|
|
|
|
|
import android.content.Context; |
|
|
|
import android.location.Location; |
|
|
|
import android.location.LocationListener; |
|
|
|
import android.location.LocationManager; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.util.Log; |
|
|
|
|
|
|
|
import com.google.android.maps.GeoPoint; |
|
|
|
import java.util.LinkedList; |
|
|
|
|
|
|
|
public class Positioner implements LocationListener { |
|
|
|
private Location currentLocation; |
|
|
@ -57,7 +56,6 @@ public class Positioner implements LocationListener { |
|
|
|
|
|
|
|
public void requestUpdates() { |
|
|
|
if (isUpdating) return; |
|
|
|
Log.d("Positioner", "Enabling location Updates"); |
|
|
|
|
|
|
|
if (getBestLocationProvider().equals(LocationManager.GPS_PROVIDER) && !hadGPSFix) |
|
|
|
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this); |
|
|
@ -68,7 +66,6 @@ public class Positioner implements LocationListener { |
|
|
|
|
|
|
|
public void cancelUpdates() { |
|
|
|
if (!isUpdating) return; |
|
|
|
Log.d("Positioner", "Disabling location Updates"); |
|
|
|
|
|
|
|
locationManager.removeUpdates(this); |
|
|
|
|
|
|
@ -81,12 +78,10 @@ public class Positioner implements LocationListener { |
|
|
|
} |
|
|
|
|
|
|
|
public void registerNotification(OnPositionChangeListener object) { |
|
|
|
Log.d("Positioner", "Adding notification " + object.getClass().getCanonicalName()); |
|
|
|
toNotify.add(object); |
|
|
|
} |
|
|
|
|
|
|
|
public void unregisterNotification(OnPositionChangeListener object) { |
|
|
|
Log.d("Positioner", "Removing notification " + object.getClass().getCanonicalName()); |
|
|
|
toNotify.remove(object); |
|
|
|
} |
|
|
|
|
|
|
@ -104,8 +99,6 @@ public class Positioner implements LocationListener { |
|
|
|
|
|
|
|
@Override |
|
|
|
public synchronized void onLocationChanged(Location location) { |
|
|
|
Log.d("Positioner", "New location arrived"); |
|
|
|
|
|
|
|
/* If we already have a GPS fix, discard Network locations */ |
|
|
|
if (hadGPSFix && location.getProvider().equals(LocationManager.NETWORK_PROVIDER)) |
|
|
|
return; |
|
|
@ -136,7 +129,6 @@ public class Positioner implements LocationListener { |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onProviderEnabled(String provider) { |
|
|
|
Log.d("Positioner", "Provider enabled: " + provider); |
|
|
|
initLocation(); |
|
|
|
} |
|
|
|
|
|
|
@ -145,7 +137,6 @@ public class Positioner implements LocationListener { |
|
|
|
} |
|
|
|
|
|
|
|
private synchronized void notifyAllClients() { |
|
|
|
Log.d("Positioner", "Notifying clients"); |
|
|
|
for (OnPositionChangeListener l : toNotify) |
|
|
|
l.onLocationChange(currentGeoPoint, currentAccuracy); |
|
|
|
} |
|
|
|