From 6422ccae65dbf47d53f18c3501e4a295dcdaf751 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Tue, 1 Apr 2014 09:43:19 +0200 Subject: Use Math.floor/ceil instead of FloatMath On SDK >= 8, Math.floor and Math.ceil are faster than FloatMath equivalents. --- main/src/cgeo/geocaching/ui/CompassView.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (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 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 -- cgit v1.1