Added first fix tracking to AndroidGPS and SkyHook

This should prevent any mix ups about first fix.

closes #34

Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
2012-05-02 11:33:01 -04:00
parent 46ab711e41
commit d8159587a5
2 changed files with 14 additions and 2 deletions

View File

@@ -49,6 +49,7 @@ public class SkyHook implements GeoPointLocationListener{
private boolean isFallBackScheduled = false;
private boolean isEnabled = false;
private boolean isUnauthorized = false;
private boolean isFirstFix;
/*
* this runnable will be used to check if we have location from skyhook,
@@ -123,6 +124,7 @@ public class SkyHook implements GeoPointLocationListener{
// in the text view. we use a Handler because UI updates
// must occur in the UI thread
setUIHandler();
isFirstFix = true;
}
/**
@@ -195,6 +197,7 @@ public class SkyHook implements GeoPointLocationListener{
mSkyHookFallback = null;
isEnabled = false;
}
isFirstFix = true;
}
/**
@@ -226,7 +229,10 @@ public class SkyHook implements GeoPointLocationListener{
Log.d(TAG,"got location "+ location.getLatitude() +", "+ location.getLongitude()+" +- "+ location.getHPE() +"m");
mListener.onLocationChanged(new GeoPoint((int) (location.getLatitude() * 1e6), (int) (location.getLongitude() * 1e6)), location.getHPE());
mListener.onFirstFix(isFirstFix);
hasLocation = true;
isFirstFix = false;
}
}
return;
@@ -291,7 +297,7 @@ public class SkyHook implements GeoPointLocationListener{
}
@Override
public void onFirstFix(boolean isFistFix) {
// unused
public void onFirstFix(boolean firstFix) {
mListener.onFirstFix(firstFix);
}
}

View File

@@ -27,6 +27,7 @@ public class AndroidGPS implements LocationListener {
private final LocationManager mLocationManager;
private GeoPointLocationListener mListener;
private LocationListener mLocationListener;
private boolean isFirstFix;
/**
* Creates a new SkyHookFallback
@@ -34,6 +35,7 @@ public class AndroidGPS implements LocationListener {
*/
public AndroidGPS(Context context) {
mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
isFirstFix = true;
}
/**
@@ -45,6 +47,7 @@ public class AndroidGPS implements LocationListener {
Log.d(TAG, "disableLocationUpdates()");
mListener = null;
mLocationManager.removeUpdates(this);
isFirstFix = true;
}
/**
@@ -88,6 +91,9 @@ public class AndroidGPS implements LocationListener {
if(mLocationListener != null){
mLocationListener.onLocationChanged(location);
}
mListener.onFirstFix(isFirstFix);
isFirstFix = false;
}
/**