From d8159587a5405a66e6ed61640f6612d517003d36 Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Wed, 2 May 2012 11:33:01 -0400 Subject: [PATCH] Added first fix tracking to AndroidGPS and SkyHook This should prevent any mix ups about first fix. closes #34 Signed-off-by: Ricky Barrette --- .../src/com/TwentyCodes/android/SkyHook/SkyHook.java | 10 ++++++++-- .../com/TwentyCodes/android/location/AndroidGPS.java | 6 ++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/LocationLib/src/com/TwentyCodes/android/SkyHook/SkyHook.java b/LocationLib/src/com/TwentyCodes/android/SkyHook/SkyHook.java index e0e77e8..b344d22 100644 --- a/LocationLib/src/com/TwentyCodes/android/SkyHook/SkyHook.java +++ b/LocationLib/src/com/TwentyCodes/android/SkyHook/SkyHook.java @@ -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); } } \ No newline at end of file diff --git a/LocationLib/src/com/TwentyCodes/android/location/AndroidGPS.java b/LocationLib/src/com/TwentyCodes/android/location/AndroidGPS.java index 6568c3f..5e6a724 100644 --- a/LocationLib/src/com/TwentyCodes/android/location/AndroidGPS.java +++ b/LocationLib/src/com/TwentyCodes/android/location/AndroidGPS.java @@ -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; } /**