de.unikassel.android.sdcframework.devices
Class LocationTracker

Package class diagram package LocationTracker
java.lang.Object
  extended by de.unikassel.android.sdcframework.util.LifeCycleObjectImpl
      extended by de.unikassel.android.sdcframework.devices.LocationTracker
All Implemented Interfaces:
EventObserver<Sample>, LifeCycleObject

public final class LocationTracker
extends LifeCycleObjectImpl
implements EventObserver<Sample>

Class to track location information using available sensors.


Field Summary
private  Context context
          the application context
private  Location currentLocation
          The current Location
private  boolean enabled
          Enabled flag
private static int SIGNIFICANT_TIME_DIFF
          The time difference for significance
 
Constructor Summary
LocationTracker()
          Constructor
 
Method Summary
 Location getCurrentLocation()
          Getter for the currentLocation
private  void getLastKnownLocation()
          Method to get the last known location
private static boolean isBetterLocation(Location location, Location currentBestLocation)
          Determines whether one Location reading is better than the current Location fix ( source: http://developer.android.com/guide/topics/location/obtaining-user -location.html )
 boolean isEnabled()
          Getter for the enabled
private static boolean isSameProvider(String provider1, String provider2)
          Method to check for the same provider
private  Location locationFromSample(Sample sample)
          Method to create a location object from a location sample
 void onCreate(Context applicationContext)
          Creation method
 void onEvent(ObservableEventSource<? extends Sample> eventSource, Sample observedEvent)
          This method is called whenever the observed object does create an observed event
private  void setCurrentLocation(Location currentLocation)
          Setter for the currentLocation
 void setEnabled(boolean enabled)
          Setter for the enabled
 
Methods inherited from class de.unikassel.android.sdcframework.util.LifeCycleObjectImpl
onDestroy, onPause, onResume
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SIGNIFICANT_TIME_DIFF

private static final int SIGNIFICANT_TIME_DIFF
The time difference for significance

See Also:
Constant Field Values

currentLocation

private Location currentLocation
The current Location


enabled

private boolean enabled
Enabled flag


context

private Context context
the application context

Constructor Detail

LocationTracker

public LocationTracker()
Constructor

Method Detail

onCreate

public final void onCreate(Context applicationContext)
Description copied from interface: LifeCycleObject
Creation method

Specified by:
onCreate in interface LifeCycleObject
Overrides:
onCreate in class LifeCycleObjectImpl
Parameters:
applicationContext - the application context

getLastKnownLocation

private void getLastKnownLocation()
Method to get the last known location


isBetterLocation

private static final boolean isBetterLocation(Location location,
                                              Location currentBestLocation)
Determines whether one Location reading is better than the current Location fix ( source: http://developer.android.com/guide/topics/location/obtaining-user -location.html )

Parameters:
location - the new location
currentBestLocation - the current location

isSameProvider

private static final boolean isSameProvider(String provider1,
                                            String provider2)
Method to check for the same provider

Parameters:
provider1 - first provider
provider2 - second provider
Returns:
true if it is the same provider

onEvent

public final void onEvent(ObservableEventSource<? extends Sample> eventSource,
                          Sample observedEvent)
Description copied from interface: EventObserver
This method is called whenever the observed object does create an observed event

Specified by:
onEvent in interface EventObserver<Sample>
Parameters:
eventSource - the event generator
observedEvent - the event created by the observed object

locationFromSample

private final Location locationFromSample(Sample sample)
Method to create a location object from a location sample

Parameters:
sample - the sample
Returns:
the converted location sample or null

setCurrentLocation

private final void setCurrentLocation(Location currentLocation)
Setter for the currentLocation

Parameters:
currentLocation - the currentLocation to set

getCurrentLocation

public final Location getCurrentLocation()
Getter for the currentLocation

Returns:
the currentLocation

setEnabled

public void setEnabled(boolean enabled)
Setter for the enabled

Parameters:
enabled - the enabled to set

isEnabled

public boolean isEnabled()
Getter for the enabled

Returns:
the enabled