diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2019-05-20 12:40:42 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2019-05-20 15:20:47 -0700 |
commit | 878aa335673aefaaf84f474733fb18fa063be62f (patch) | |
tree | 5a186e208107882b9794009c3efd1b13fbd8b4a7 /src/com/android/launcher3/Utilities.java | |
parent | 136805abdca153c92569a8ead8aa5044944a84f5 (diff) | |
download | android_packages_apps_Trebuchet-878aa335673aefaaf84f474733fb18fa063be62f.tar.gz android_packages_apps_Trebuchet-878aa335673aefaaf84f474733fb18fa063be62f.tar.bz2 android_packages_apps_Trebuchet-878aa335673aefaaf84f474733fb18fa063be62f.zip |
Using squared hypot to optimize some comparisions
Change-Id: Ia5b99c2e60eedf02dea26857819f0e13127db4e2
Diffstat (limited to 'src/com/android/launcher3/Utilities.java')
-rw-r--r-- | src/com/android/launcher3/Utilities.java | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index 796fd2505..cc9bda710 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -61,6 +61,7 @@ import android.util.Pair; 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 @@ public final class Utilities { 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; |