Refactoring FlingToDelete
> Moving all fling related logic to FlingToDeleteHelper from DragController > Removing fling related methods from DragSource and DropTarget > Moving fling animation logic from DeleteDropTarget to FlingAnimation > Simplifying DropTargetBar to directly look for all valid drop targets. This makes it easier to add new DropTarget in xml. Change-Id: I7214d2d30c907ab93c80d92d9f9be6dda2d63354
This commit is contained in:
1 parent
466c4131d8
commit
0f76b56865
19 files changed
+227
-327
No files matched your search
@@ -28,7 +28,6 @@ import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.ColorMatrix;
|
||||
import android.graphics.ColorMatrixColorFilter;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
@@ -118,9 +117,6 @@ public abstract class ButtonDropTarget extends TextView
|
||||
mDropTargetBar = dropTargetBar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFlingToDelete(DragObject d, PointF vec) { }
|
||||
|
||||
@Override
|
||||
public final void onDragEnter(DragObject d) {
|
||||
d.dragView.setColor(mHoverColor);
|
||||
@@ -243,10 +239,7 @@ public abstract class ButtonDropTarget extends TextView
|
||||
final Rect from = new Rect();
|
||||
dragLayer.getViewRectRelativeToSelf(d.dragView, from);
|
||||
|
||||
int width = mDrawable.getIntrinsicWidth();
|
||||
int height = mDrawable.getIntrinsicHeight();
|
||||
final Rect to = getIconRect(d.dragView.getMeasuredWidth(), d.dragView.getMeasuredHeight(),
|
||||
width, height);
|
||||
final Rect to = getIconRect(d);
|
||||
final float scale = (float) to.width() / from.width();
|
||||
mDropTargetBar.deferOnDragEnd();
|
||||
|
||||
@@ -268,7 +261,7 @@ public abstract class ButtonDropTarget extends TextView
|
||||
@Override
|
||||
public void prepareAccessibilityDrop() { }
|
||||
|
||||
@Thunk abstract void completeDrop(DragObject d);
|
||||
public abstract void completeDrop(DragObject d);
|
||||
|
||||
@Override
|
||||
public void getHitRectRelativeToDragLayer(android.graphics.Rect outRect) {
|
||||
@@ -280,7 +273,11 @@ public abstract class ButtonDropTarget extends TextView
|
||||
outRect.offsetTo(coords[0], coords[1]);
|
||||
}
|
||||
|
||||
protected Rect getIconRect(int viewWidth, int viewHeight, int drawableWidth, int drawableHeight) {
|
||||
public Rect getIconRect(DragObject dragObject) {
|
||||
int viewWidth = dragObject.dragView.getMeasuredWidth();
|
||||
int viewHeight = dragObject.dragView.getMeasuredHeight();
|
||||
int drawableWidth = mDrawable.getIntrinsicWidth();
|
||||
int drawableHeight = mDrawable.getIntrinsicHeight();
|
||||
DragLayer dragLayer = mLauncher.getDragLayer();
|
||||
|
||||
// Find the rect to animate to (the view is center aligned)
|
||||
|
||||
Reference in new issue
Block a user