Package com.aerisweather.aeris.location
Class LocationHelper
- java.lang.Object
-
- com.aerisweather.aeris.location.LocationHelper
-
public class LocationHelper extends Object
- Since:
- 05-Dec-2011 8:59:01 AM
-
-
Constructor Summary
Constructors Constructor Description LocationHelper(android.content.Context context)Constructor.LocationHelper(android.content.Context context, int updateRate, LocationDelegate windowDelegate)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddLocationToQueue(android.location.Location l)Adds location to queue.booleancompareToLoc(float lat, float longitude, float radius)voiddisableDebug()voidenableDebug()android.content.ContextgetContext()android.location.LocationgetCurrentLocation()Gets the current LocationLinkedList<android.location.Location>getLastLocs()booleangetSingleLocation(SingleLocationObserver observer)Starts listening for a single location.intgetUpdateRate()Gets the update rate in secondsprotected booleanisBetterLocation(android.location.Location location)Determines whether one Location reading is better than the current Location fixbooleanisGpsProviderEnabled()booleanisNetworkProviderEnabled()static com.google.android.gms.maps.model.LatLnglocationToLatLng(android.location.Location loc)voidremoveUpdates()Stops requesting location updates from the location manager.voidrequestLocationUpdates()Requests the current location based on passive,network, and GPS provider.voidrequestLocationUpdates(String provider)Requests the current location based on a specific provider.voidsetCurrentLocation(android.location.Location currentLocation)voidsetLastLocs(LinkedList<android.location.Location> lastLocs)voidsetUpdateRate(int updateRate)
-
-
-
Constructor Detail
-
LocationHelper
public LocationHelper(android.content.Context context)
Constructor. Takes into account what GPS settings are in place.- Parameters:
context- Context of the activity its called from.
-
LocationHelper
public LocationHelper(android.content.Context context, int updateRate, LocationDelegate windowDelegate)Constructor. Takes into account what GPS settings are in place.- Parameters:
context- Context of the activity its called from.updateRate- Update rate in seconds when the listener will next try to get a new location. Note: this is the min time possible for a next update to occur.windowDelegate- Window listeners delegate to pass a notification that the location has been updated.
-
-
Method Detail
-
getLastLocs
public LinkedList<android.location.Location> getLastLocs()
-
setLastLocs
public void setLastLocs(LinkedList<android.location.Location> lastLocs)
-
setCurrentLocation
public void setCurrentLocation(android.location.Location currentLocation)
-
enableDebug
public void enableDebug()
-
disableDebug
public void disableDebug()
-
addLocationToQueue
public void addLocationToQueue(android.location.Location l)
Adds location to queue.- Parameters:
l- Location
-
requestLocationUpdates
public void requestLocationUpdates()
Requests the current location based on passive,network, and GPS provider.
-
requestLocationUpdates
public void requestLocationUpdates(String provider)
Requests the current location based on a specific provider.- Parameters:
provider- provider to use.
-
getSingleLocation
public boolean getSingleLocation(SingleLocationObserver observer)
Starts listening for a single location. Returns true if a provider is enabled.- Parameters:
observer- SingleLocationObserver obj- Returns:
- boolean
-
compareToLoc
public boolean compareToLoc(float lat, float longitude, float radius)- Parameters:
lat- doublelongitude- doubleradius- float- Returns:
- boolean
-
getCurrentLocation
public android.location.Location getCurrentLocation()
Gets the current Location- Returns:
- Location object
-
isBetterLocation
protected boolean isBetterLocation(android.location.Location location)
Determines whether one Location reading is better than the current Location fix- Parameters:
location- Location obj- Returns:
- boolean
-
removeUpdates
public void removeUpdates()
Stops requesting location updates from the location manager. Keep in mind fragment and activity life cycles and remember to remove updates.
-
getUpdateRate
public int getUpdateRate()
Gets the update rate in seconds- Returns:
- int
-
setUpdateRate
public void setUpdateRate(int updateRate)
-
locationToLatLng
public static com.google.android.gms.maps.model.LatLng locationToLatLng(android.location.Location loc)
-
getContext
public android.content.Context getContext()
-
isGpsProviderEnabled
public boolean isGpsProviderEnabled()
-
isNetworkProviderEnabled
public boolean isNetworkProviderEnabled()
-
-