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

View File

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