diff options
author | Android Dialer <noreply@google.com> | 2017-08-14 15:05:34 -0700 |
---|---|---|
committer | Eric Erfanian <erfanian@google.com> | 2017-08-15 08:26:21 -0700 |
commit | d3760c52b7c9e30c273f9c943410695b31e2061e (patch) | |
tree | 62fff98ee4f288d71beb925a351a257a03595329 /java/com | |
parent | 393c0df6a01bf6890a944284e6d62a482b5d62ae (diff) |
Replace MathUtils.clamp with private clamp implementation since MathUtils.clamp
is supported in Android SDK 26, which is not supported by the Android Auto application.
Bug: 64091458
Test: None. Functionally equivalent
PiperOrigin-RevId: 165234983
Change-Id: I02f4c5be1431a9b2f3122d466abf74a80c2063c1
Diffstat (limited to 'java/com')
-rw-r--r-- | java/com/android/dialershared/bubble/MoveHandler.java | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/java/com/android/dialershared/bubble/MoveHandler.java b/java/com/android/dialershared/bubble/MoveHandler.java index bd8fa1081..33507efd6 100644 --- a/java/com/android/dialershared/bubble/MoveHandler.java +++ b/java/com/android/dialershared/bubble/MoveHandler.java @@ -22,7 +22,6 @@ import android.support.animation.FloatPropertyCompat; import android.support.animation.SpringAnimation; import android.support.animation.SpringForce; import android.support.annotation.NonNull; -import android.support.v4.math.MathUtils; import android.view.Gravity; import android.view.MotionEvent; import android.view.VelocityTracker; @@ -61,6 +60,10 @@ class MoveHandler implements OnTouchListener { private VelocityTracker velocityTracker; private Scroller scroller; + private static float clamp(float value, float min, float max) { + return Math.min(max, Math.max(min, value)); + } + // Handles the left/right gravity conversion and centering private final FloatPropertyCompat<WindowManager.LayoutParams> xProperty = new FloatPropertyCompat<LayoutParams>("xProperty") { @@ -73,7 +76,7 @@ class MoveHandler implements OnTouchListener { int displayWidth = context.getResources().getDisplayMetrics().widthPixels; realX = displayWidth - realX; } - return MathUtils.clamp(realX, minX, maxX); + return clamp(realX, minX, maxX); } @Override @@ -104,7 +107,7 @@ class MoveHandler implements OnTouchListener { new FloatPropertyCompat<LayoutParams>("yProperty") { @Override public float getValue(LayoutParams object) { - return MathUtils.clamp(object.y + bubbleSize + shadowPaddingSize, minY, maxY); + return clamp(object.y + bubbleSize + shadowPaddingSize, minY, maxY); } @Override @@ -175,8 +178,8 @@ class MoveHandler implements OnTouchListener { ensureSprings(); - moveXAnimation.animateToFinalPosition(MathUtils.clamp(eventX, minX, maxX)); - moveYAnimation.animateToFinalPosition(MathUtils.clamp(eventY, minY, maxY)); + moveXAnimation.animateToFinalPosition(clamp(eventX, minX, maxX)); + moveYAnimation.animateToFinalPosition(clamp(eventY, minY, maxY)); } velocityTracker.addMovement(event); @@ -210,6 +213,7 @@ class MoveHandler implements OnTouchListener { bubble.primaryButtonClick(); } break; + default: // fall out } return true; } |