Fixing flashing icon on delete, and offset of delete animation.

Change-Id: I993f2d8e54cc7052e16f318a09ada80e9b766147
This commit is contained in:
Winson Chung
2012-02-28 18:11:33 -08:00
parent 483e01b0ae
commit 61967cb17f
4 changed files with 43 additions and 38 deletions

View File

@@ -19,6 +19,7 @@ package com.android.launcher2;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.TextView;
@@ -41,7 +42,7 @@ public class ButtonDropTarget extends TextView implements DropTarget, DragContro
protected boolean mActive;
/** The paint applied to the drag view on hover */
protected final Paint mHoverPaint = new Paint();
protected int mHoverColor = 0;
public ButtonDropTarget(Context context, AttributeSet attrs) {
this(context, attrs, 0);
@@ -71,7 +72,7 @@ public class ButtonDropTarget extends TextView implements DropTarget, DragContro
}
public void onDragEnter(DragObject d) {
d.dragView.setPaint(mHoverPaint);
d.dragView.setColor(mHoverColor);
}
public void onDragOver(DragObject d) {
@@ -79,7 +80,7 @@ public class ButtonDropTarget extends TextView implements DropTarget, DragContro
}
public void onDragExit(DragObject d) {
d.dragView.setPaint(null);
d.dragView.setColor(0);
}
public void onDragStart(DragSource source, Object info, int dragAction) {
@@ -100,6 +101,26 @@ public class ButtonDropTarget extends TextView implements DropTarget, DragContro
outRect.bottom += mBottomDragPadding;
}
Rect getIconRect(int itemWidth, int itemHeight, int drawableWidth, int drawableHeight) {
DragLayer dragLayer = mLauncher.getDragLayer();
// Find the rect to animate to (the view is center aligned)
Rect to = new Rect();
dragLayer.getViewRectRelativeToSelf(this, to);
int width = drawableWidth;
int height = drawableHeight;
int left = to.left + getPaddingLeft();
int top = to.top + (getMeasuredHeight() - height) / 2;
to.set(left, top, left + width, top + height);
// Center the destination rect about the trash icon
int xOffset = (int) -(itemWidth - width) / 2;
int yOffset = (int) -(itemHeight - height) / 2;
to.offset(xOffset, yOffset);
return to;
}
@Override
public DropTarget getDropTargetDelegate(DragObject d) {
return null;