From 9430ff23c8a1127341e73b285e901a5cb9f1b5f7 Mon Sep 17 00:00:00 2001 From: Vadim Tryshev Date: Fri, 7 Aug 2015 15:09:39 -0700 Subject: [PATCH] Fixing 1-point jump upon switching from DragView to drag shadow. Upon the end if the growth animation for DragView, we hide DragView and show the framework DND drag shadow. Rounding problems caused shifting of the drag image by 1 pixel when the transition happened. Bug: 22028725 Change-Id: I2a2275a6d18c1a10ceecaecf8a279c6d11d8c7d8 --- src/com/android/launcher3/DragView.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/com/android/launcher3/DragView.java b/src/com/android/launcher3/DragView.java index a4e7ca7b3f..91dadf3c7e 100644 --- a/src/com/android/launcher3/DragView.java +++ b/src/com/android/launcher3/DragView.java @@ -199,9 +199,11 @@ public class DragView extends View { public void provideDragShadowMetrics(Point size, Point touch) { size.set((int)(mBitmap.getWidth() * getScaleX()), (int)(mBitmap.getHeight() * getScaleY())); - final int xGrowth = (int)(mBitmap.getWidth() * (getScaleX() - mInitialScale)); - final int yGrowth = (int)(mBitmap.getHeight() * (getScaleY() - mInitialScale)); - touch.set(mRegistrationX + xGrowth / 2, mRegistrationY + yGrowth / 2); + final float xGrowth = mBitmap.getWidth() * (getScaleX() - mInitialScale); + final float yGrowth = mBitmap.getHeight() * (getScaleY() - mInitialScale); + touch.set( + mRegistrationX + (int)Math.round(xGrowth / 2), + mRegistrationY + (int)Math.round(yGrowth / 2)); } @Override