From 0c81801f9ec2956c1da28703654da64e1ec9fb14 Mon Sep 17 00:00:00 2001 From: Michel Comin Escude Date: Tue, 13 Apr 2021 18:50:22 -0700 Subject: [PATCH] Fixed and decreased isAtEquilibrium thresholds Distance and speed were multiplied by LINEAR_STRETCH_INTENSITY which is not directly related to speed and and distance. Moreover the velocity threshold was a little bit high (1/0.016, wich means 62 pixels/second) and the distance as well (1 is ok if there's no scale but since there's some stretching the difference was being magnified). Bug: 184892316 Test: EdgeEffectTests and visual Change-Id: Ibd7adb16d1d00df0ab6e96132bfe96a4fa4d45dc --- core/java/android/widget/EdgeEffect.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/java/android/widget/EdgeEffect.java b/core/java/android/widget/EdgeEffect.java index cd91d0266c753..b47a08e26e22e 100644 --- a/core/java/android/widget/EdgeEffect.java +++ b/core/java/android/widget/EdgeEffect.java @@ -104,15 +104,15 @@ public class EdgeEffect { /** * The velocity threshold before the spring animation is considered settled. - * The idea here is that velocity should be less than 1 pixel per frame (~16ms). + * The idea here is that velocity should be less than 0.1 pixel per second. */ - private static final double VELOCITY_THRESHOLD = 1.0 / 0.016; + private static final double VELOCITY_THRESHOLD = 0.1; /** * The value threshold before the spring animation is considered close enough to - * the destination to be settled. This should be around 1 pixel. + * the destination to be settled. This should be around 0.01 pixel. */ - private static final double VALUE_THRESHOLD = 1; + private static final double VALUE_THRESHOLD = 0.01; /** * The natural frequency of the stretch spring. @@ -782,8 +782,8 @@ public class EdgeEffect { * considered at rest or false if it is still animating. */ private boolean isAtEquilibrium() { - double displacement = mDistance * mHeight * LINEAR_STRETCH_INTENSITY; // in pixels - double velocity = mVelocity * LINEAR_STRETCH_INTENSITY; + double displacement = mDistance * mHeight; // in pixels + double velocity = mVelocity; return Math.abs(velocity) < VELOCITY_THRESHOLD && Math.abs(displacement) < VALUE_THRESHOLD; }