mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 18:58:19 +00:00
Fixing flashing icon on delete, and offset of delete animation.
Change-Id: I993f2d8e54cc7052e16f318a09ada80e9b766147
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user