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 void
addLocationToQueue(android.location.Location l)
Adds location to queue.boolean
compareToLoc(float lat, float longitude, float radius)
void
disableDebug()
void
enableDebug()
android.content.Context
getContext()
android.location.Location
getCurrentLocation()
Gets the current LocationLinkedList<android.location.Location>
getLastLocs()
boolean
getSingleLocation(SingleLocationObserver observer)
Starts listening for a single location.int
getUpdateRate()
Gets the update rate in secondsprotected boolean
isBetterLocation(android.location.Location location)
Determines whether one Location reading is better than the current Location fixboolean
isGpsProviderEnabled()
boolean
isNetworkProviderEnabled()
static com.google.android.gms.maps.model.LatLng
locationToLatLng(android.location.Location loc)
void
removeUpdates()
Stops requesting location updates from the location manager.void
requestLocationUpdates()
Requests the current location based on passive,network, and GPS provider.void
requestLocationUpdates(String provider)
Requests the current location based on a specific provider.void
setCurrentLocation(android.location.Location currentLocation)
void
setLastLocs(LinkedList<android.location.Location> lastLocs)
void
setUpdateRate(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()
-
-