diff options
author | Samuel Tardieu <sam@rfc1149.net> | 2012-04-27 12:10:34 +0200 |
---|---|---|
committer | Samuel Tardieu <sam@rfc1149.net> | 2012-04-27 12:10:34 +0200 |
commit | 75a8a8d1c70b23a2867345043e36e850a6c16502 (patch) | |
tree | 00c7b928ecc815440b08e70b2bf92e6e941bb2ee /main | |
parent | 5a10f40f72702009d2afc3bc6501b8843a70bb03 (diff) | |
download | cgeo-75a8a8d1c70b23a2867345043e36e850a6c16502.zip cgeo-75a8a8d1c70b23a2867345043e36e850a6c16502.tar.gz cgeo-75a8a8d1c70b23a2867345043e36e850a6c16502.tar.bz2 |
Add GPS enabled information to the IGeoData interface
Diffstat (limited to 'main')
-rw-r--r-- | main/src/cgeo/geocaching/GeoDataProvider.java | 24 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/IGeoData.java | 1 |
2 files changed, 21 insertions, 4 deletions
diff --git a/main/src/cgeo/geocaching/GeoDataProvider.java b/main/src/cgeo/geocaching/GeoDataProvider.java index b7a5341..fe942c4 100644 --- a/main/src/cgeo/geocaching/GeoDataProvider.java +++ b/main/src/cgeo/geocaching/GeoDataProvider.java @@ -46,6 +46,7 @@ class GeoDataProvider extends MemorySubject<IGeoData> { public float accuracyNow = -1f; public int satellitesVisible = 0; public int satellitesFixed = 0; + public boolean gpsEnabled = false; @Override public Location getLocation() { @@ -73,6 +74,11 @@ class GeoDataProvider extends MemorySubject<IGeoData> { } @Override + public boolean getGpsEnabled() { + return gpsEnabled; + } + + @Override public float getSpeedNow() { return speedNow; } @@ -253,6 +259,7 @@ class GeoDataProvider extends MemorySubject<IGeoData> { @Override public void onGpsStatusChanged(final int event) { + boolean changed = false; if (event == GpsStatus.GPS_EVENT_SATELLITE_STATUS) { final GpsStatus status = geoManager.getGpsStatus(null); final Iterator<GpsSatellite> statusIterator = status.getSatellites().iterator(); @@ -268,7 +275,6 @@ class GeoDataProvider extends MemorySubject<IGeoData> { satellites++; } - boolean changed = false; if (satellites != current.satellitesVisible) { current.satellitesVisible = satellites; changed = true; @@ -277,10 +283,20 @@ class GeoDataProvider extends MemorySubject<IGeoData> { current.satellitesFixed = fixed; changed = true; } + } else if (event == GpsStatus.GPS_EVENT_STARTED && !current.gpsEnabled) { + current.gpsEnabled = true; + current.satellitesFixed = 0; + current.satellitesVisible = 0; + changed = true; + } else if (event == GpsStatus.GPS_EVENT_STOPPED && current.gpsEnabled) { + current.gpsEnabled = false; + current.satellitesFixed = 0; + current.satellitesVisible = 0; + changed = true; + } - if (changed) { - selectBest(null); - } + if (changed) { + selectBest(null); } } } diff --git a/main/src/cgeo/geocaching/IGeoData.java b/main/src/cgeo/geocaching/IGeoData.java index d703d1a..7758a97 100644 --- a/main/src/cgeo/geocaching/IGeoData.java +++ b/main/src/cgeo/geocaching/IGeoData.java @@ -14,6 +14,7 @@ public interface IGeoData { public float getBearingNow(); public float getSpeedNow(); public float getAccuracyNow(); + public boolean getGpsEnabled(); public int getSatellitesVisible(); public int getSatellitesFixed(); |