diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2014-04-01 09:43:19 +0200 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2014-04-01 09:43:27 +0200 |
| commit | 6422ccae65dbf47d53f18c3501e4a295dcdaf751 (patch) | |
| tree | d2a919513fc53b2e821f66e4e210fc8384ab58dd /main | |
| parent | 11d49a5a42dedf0821f16aa030bd0e7e27c9bc03 (diff) | |
| download | cgeo-6422ccae65dbf47d53f18c3501e4a295dcdaf751.zip cgeo-6422ccae65dbf47d53f18c3501e4a295dcdaf751.tar.gz cgeo-6422ccae65dbf47d53f18c3501e4a295dcdaf751.tar.bz2 | |
Use Math.floor/ceil instead of FloatMath
On SDK >= 8, Math.floor and Math.ceil are faster than FloatMath
equivalents.
Diffstat (limited to 'main')
| -rw-r--r-- | main/src/cgeo/geocaching/ui/CompassView.java | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/main/src/cgeo/geocaching/ui/CompassView.java b/main/src/cgeo/geocaching/ui/CompassView.java index eaaf711..f7111f7 100644 --- a/main/src/cgeo/geocaching/ui/CompassView.java +++ b/main/src/cgeo/geocaching/ui/CompassView.java @@ -16,7 +16,6 @@ import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.PaintFlagsDrawFilter; import android.util.AttributeSet; -import android.util.FloatMath; import android.view.View; import java.util.concurrent.TimeUnit; @@ -158,19 +157,19 @@ public class CompassView extends View { * @return the new value */ static protected float smoothUpdate(float goal, float actual) { - final float diff = AngleUtils.difference(actual, goal); + final double diff = AngleUtils.difference(actual, goal); - float offset = 0; + double offset = 0; // If the difference is smaller than 1 degree, do nothing as it // causes the arrow to vibrate. Round away from 0. if (diff > 1.0) { - offset = FloatMath.ceil(diff / 10.0f); // for larger angles, rotate faster + offset = Math.ceil(diff / 10.0); // for larger angles, rotate faster } else if (diff < 1.0) { - offset = FloatMath.floor(diff / 10.0f); + offset = Math.floor(diff / 10.0); } - return AngleUtils.normalize(actual + offset); + return AngleUtils.normalize((float) (actual + offset)); } @Override |
