Using squared hypot to optimize some comparisions
Change-Id: Ia5b99c2e60eedf02dea26857819f0e13127db4e2
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index 796fd25..cc9bda7 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -61,6 +61,7 @@
import android.util.TypedValue;
import android.view.MotionEvent;
import android.view.View;
+import android.view.ViewConfiguration;
import android.view.animation.Interpolator;
import com.android.launcher3.compat.LauncherAppsCompat;
@@ -726,6 +727,15 @@
return str.toString();
}
+ public static float squaredHypot(float x, float y) {
+ return x * x + y * y;
+ }
+
+ public static float squaredTouchSlop(Context context) {
+ float slop = ViewConfiguration.get(context).getScaledTouchSlop();
+ return slop * slop;
+ }
+
private static class FixedSizeEmptyDrawable extends ColorDrawable {
private final int mSize;