From 3e2d0a118596ab44857bec60d761fc2bfdeeb0be Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Thu, 31 May 2012 14:45:12 +0200 Subject: Add a function to compute a normalized angle difference --- main/src/cgeo/geocaching/ui/CompassView.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'main/src/cgeo/geocaching/ui/CompassView.java') diff --git a/main/src/cgeo/geocaching/ui/CompassView.java b/main/src/cgeo/geocaching/ui/CompassView.java index 6f5b8b9..56cba9d 100644 --- a/main/src/cgeo/geocaching/ui/CompassView.java +++ b/main/src/cgeo/geocaching/ui/CompassView.java @@ -1,5 +1,6 @@ package cgeo.geocaching.ui; +import cgeo.geocaching.DirectionProvider; import cgeo.geocaching.R; import cgeo.geocaching.utils.PeriodicHandler; @@ -153,7 +154,8 @@ public class CompassView extends View { public void act() { final double newAzimuthShown = smoothUpdate(northMeasured, azimuthShown); final double newCacheHeadingShown = smoothUpdate(cacheHeadingMeasured, cacheHeadingShown); - if (Math.abs(newAzimuthShown - azimuthShown) >= 2 || Math.abs(newCacheHeadingShown - cacheHeadingShown) >= 2) { + if (Math.abs(DirectionProvider.difference(azimuthShown, newAzimuthShown)) >= 2 || + Math.abs(DirectionProvider.difference(cacheHeadingShown, newCacheHeadingShown)) >= 2) { synchronized(CompassView.this) { azimuthShown = newAzimuthShown; cacheHeadingShown = newCacheHeadingShown; -- cgit v1.1