diff options
Diffstat (limited to 'main/src/cgeo/geocaching/CompassActivity.java')
| -rw-r--r-- | main/src/cgeo/geocaching/CompassActivity.java | 34 |
1 files changed, 7 insertions, 27 deletions
diff --git a/main/src/cgeo/geocaching/CompassActivity.java b/main/src/cgeo/geocaching/CompassActivity.java index 8955afd..b7dcd7e 100644 --- a/main/src/cgeo/geocaching/CompassActivity.java +++ b/main/src/cgeo/geocaching/CompassActivity.java @@ -8,12 +8,14 @@ import cgeo.geocaching.enumerations.LoadFlags; import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.geopoint.Units; import cgeo.geocaching.maps.CGeoMap; +import cgeo.geocaching.sensors.DirectionProvider; +import cgeo.geocaching.sensors.IGeoData; import cgeo.geocaching.settings.Settings; import cgeo.geocaching.speech.SpeechService; import cgeo.geocaching.ui.CompassView; import cgeo.geocaching.ui.Formatter; import cgeo.geocaching.ui.LoggingUI; -import cgeo.geocaching.utils.GeoDirHandler; +import cgeo.geocaching.sensors.GeoDirHandler; import cgeo.geocaching.utils.Log; import org.apache.commons.lang3.StringUtils; @@ -116,15 +118,11 @@ public class CompassActivity extends AbstractActivity { @Override public void onResume() { - super.onResume(); - - // sensor and geolocation manager - geoDirHandler.startGeoAndDir(); + super.onResume(geoDirHandler.start()); } @Override public void onPause() { - geoDirHandler.stopGeoAndDir(); super.onPause(); } @@ -150,11 +148,7 @@ public class CompassActivity extends AbstractActivity { final CgeoApplication app = CgeoApplication.getInstance(); final IGeoData geo = app.currentGeo(); if (geo != null) { - geoDirHandler.update(geo); - } - final Float dir = app.currentDirection(); - if (dir != null) { - geoDirHandler.update(dir); + geoDirHandler.updateGeoDir(geo, app.currentDirection()); } } @@ -197,11 +191,6 @@ public class CompassActivity extends AbstractActivity { boolean oldSetting = Settings.isUseCompass(); Settings.setUseCompass(!oldSetting); invalidateOptionsMenuCompatible(); - if (oldSetting) { - geoDirHandler.stopDir(); - } else { - geoDirHandler.startDir(); - } return true; case R.id.menu_edit_destination: Intent pointIntent = new Intent(this, NavigateAnyPointActivity.class); @@ -273,7 +262,7 @@ public class CompassActivity extends AbstractActivity { private GeoDirHandler geoDirHandler = new GeoDirHandler() { @Override - public void updateGeoData(final IGeoData geo) { + public void updateGeoDir(final IGeoData geo, final float dir) { try { if (geo.getCoords() != null) { if (geo.getSatellitesVisible() >= 0) { @@ -298,20 +287,11 @@ public class CompassActivity extends AbstractActivity { navLocation.setText(res.getString(R.string.loc_trying)); } - if (!Settings.isUseCompass() || geo.getSpeed() > 5) { // use GPS when speed is higher than 18 km/h - updateNorthHeading(geo.getBearing()); - } + updateNorthHeading(DirectionProvider.getDirectionNow(CompassActivity.this, dir)); } catch (RuntimeException e) { Log.w("Failed to LocationUpdater location."); } } - - @Override - public void updateDirection(final float direction) { - if (app.currentGeo().getSpeed() <= 5) { // use compass when speed is lower than 18 km/h - updateNorthHeading(DirectionProvider.getDirectionNow(CompassActivity.this, direction)); - } - } }; private void updateNorthHeading(final float northHeading) { |
