Revert "Revert "Use color extraction for arrow popup.""

This reverts commit 17fda29bf35bc4f21ede07319ffe26c88fea1b81.

Reason for revert: Fixing the memory leak

Leak was detected in caused launcher tapl tests to fail.
For instructions on how to debug leaks, see go/launcher-testing.
Using AS memory profiler, the color extractor class is holding
onto a reference to launcher that has already been destroyed.
The fix is to set the listener to null when view is closed.

Bug: 175329686
Test: run profiler in AS, open and close popups, and verify no leaks

Change-Id: I2d4a87f0481cbc88f3587dce91278e85ca113545
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index 2f755e1..af625a5 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -18,6 +18,7 @@
 
 import static android.animation.ValueAnimator.areAnimatorsEnabled;
 
+import static com.android.launcher3.Utilities.getBoundsForViewInDragLayer;
 import static com.android.launcher3.anim.Interpolators.DEACCEL_1_5;
 
 import android.animation.Animator;
@@ -193,6 +194,7 @@
     private static final int INVALID_DIRECTION = -100;
 
     private final Rect mTempRect = new Rect();
+    private final RectF mTempRectF = new RectF();
 
     private static final Paint sPaint = new Paint();
 
@@ -1070,11 +1072,16 @@
         // Apply local extracted color if the DragView is an AppWidgetHostViewDrawable.
         View view = dragObject.dragView.getContentView();
         if (view instanceof LauncherAppWidgetHostView) {
-            Workspace workspace =
-                    Launcher.getLauncher(dragObject.dragView.getContext()).getWorkspace();
+            Launcher launcher = Launcher.getLauncher(dragObject.dragView.getContext());
+            Workspace workspace = launcher.getWorkspace();
             int screenId = workspace.getIdForScreen(this);
             int pageId = workspace.getPageIndexForScreenId(screenId);
             cellToRect(targetCell[0], targetCell[1], spanX, spanY, mTempRect);
+
+            // Now get the rect in drag layer coordinates.
+            getBoundsForViewInDragLayer(launcher.getDragLayer(), workspace, mTempRect, false,
+                    mTempRectF);
+            Utilities.setRect(mTempRectF, mTempRect);
             ((LauncherAppWidgetHostView) view).handleDrag(mTempRect, pageId);
         }
     }