Fix bug with dragging crosshairs sometimes being too bright

Change-Id: Ieb20ab96e73c5f297ffd69d29472024c11978a13
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 13603f0..369f0d2 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -91,13 +91,13 @@
     private Rect[] mDragRects = new Rect[8];
     private int[] mDragRectAlphas = new int[mDragRects.length];
     private InterruptibleInOutAnimator[] mDragRectAnims =
-        new InterruptibleInOutAnimator[mDragRects.length];
+            new InterruptibleInOutAnimator[mDragRects.length];
 
     // Used as an index into the above 3 arrays; indicates which is the most current value.
     private int mDragRectCurrent = 0;
 
     private Drawable mCrosshairsDrawable = null;
-    private ValueAnimator mCrosshairsAnimator = null;
+    private InterruptibleInOutAnimator mCrosshairsAnimator = null;
     private float mCrosshairsVisibility = 0.0f;
 
     // When a drag operation is in progress, holds the nearest cell to the touch point
@@ -165,7 +165,7 @@
 
         // Set up the animation for fading the crosshairs in and out
         int animDuration = res.getInteger(R.integer.config_crosshairsFadeInTime);
-        mCrosshairsAnimator = new ValueAnimator<Float>(animDuration);
+        mCrosshairsAnimator = new InterruptibleInOutAnimator(animDuration, 0.0f, 1.0f);
         mCrosshairsAnimator.addUpdateListener(new AnimatorUpdateListener() {
             public void onAnimationUpdate(ValueAnimator animation) {
                 mCrosshairsVisibility = ((Float) animation.getAnimatedValue()).floatValue();
@@ -207,15 +207,6 @@
         mHover = value;
     }
 
-    private void animateCrosshairsTo(float value) {
-        final ValueAnimator anim = mCrosshairsAnimator;
-        long fullDuration = getResources().getInteger(R.integer.config_crosshairsFadeInTime);
-        anim.setDuration(fullDuration - anim.getCurrentPlayTime());
-        anim.setValues(mCrosshairsVisibility, value);
-        anim.cancel();
-        anim.start();
-    }
-
     public void drawChildren(Canvas canvas) {
         super.dispatchDraw(canvas);
     }
@@ -809,6 +800,11 @@
                 mDragRectAnims[mDragRectCurrent].animateIn();
             }
         }
+
+        // If we are drawing crosshairs, the entire CellLayout needs to be invalidated
+        if (mCrosshairsDrawable != null) {
+            invalidate();
+        }
     }
 
     /**
@@ -1020,7 +1016,7 @@
 
         // Fade out the drag indicators
         if (mCrosshairsAnimator != null) {
-            animateCrosshairsTo(0.0f);
+            mCrosshairsAnimator.animateOut();
         }
 
         mDragRectAnims[mDragRectCurrent].animateOut();
@@ -1070,7 +1066,7 @@
     void onDragEnter(View dragView) {
         // Fade in the drag indicators
         if (mCrosshairsAnimator != null) {
-            animateCrosshairsTo(1.0f);
+            mCrosshairsAnimator.animateIn();
         }
     }