From 7f823d10b4882c62ccee9540decd94bcb7c987df Mon Sep 17 00:00:00 2001 From: Federico Baron Date: Wed, 21 Dec 2022 11:39:46 -0800 Subject: [PATCH] Fix bug where dragging icons in folders causes error The error was caused by delta being larger than the range, which leads to an UnsupportedOperationException: "Final position of the spring cannot be greater than the max value". With this change, delta will never be greater than range. Fix: 261674632 Test: 1. Settings > Display > Display size and text >>> Set display size to the biggest 2. Make folder 3. Go to landscape mode 4. Open folder 5. Quickly drag icon in folder 6. Verify that Launcher doesn't stop and drag is successful Change-Id: I6c81755750acf0de8693b98caad8e7dab3e9f58a --- src/com/android/launcher3/dragndrop/DragView.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/dragndrop/DragView.java b/src/com/android/launcher3/dragndrop/DragView.java index 09fe740d23..f54d05dbdc 100644 --- a/src/com/android/launcher3/dragndrop/DragView.java +++ b/src/com/android/launcher3/dragndrop/DragView.java @@ -568,7 +568,8 @@ public abstract class DragView extends Fram .setSpring(new SpringForce(0) .setDampingRatio(DAMPENING_RATIO) .setStiffness(STIFFNESS)); - mDelta = view.getResources().getDisplayMetrics().density * PARALLAX_MAX_IN_DP; + mDelta = Math.min( + range, view.getResources().getDisplayMetrics().density * PARALLAX_MAX_IN_DP); } public void animateToPos(float value) {