From 043f2af567178b82b0b41f12d379e7dd12da2936 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Thu, 1 Mar 2012 16:09:54 -0800 Subject: Adding fling-to-delete. - Also fixing issue where the drop target icon changes color slower than the text. Change-Id: I0bfa59da5d202016342f1c3de419ebcafd81ff6f --- src/com/android/launcher2/DragView.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/com/android/launcher2/DragView.java') diff --git a/src/com/android/launcher2/DragView.java b/src/com/android/launcher2/DragView.java index 3090e8f66..5636f995d 100644 --- a/src/com/android/launcher2/DragView.java +++ b/src/com/android/launcher2/DragView.java @@ -51,6 +51,7 @@ public class DragView extends View { ValueAnimator mAnim; private float mOffsetX = 0.0f; private float mOffsetY = 0.0f; + private float mInitialScale = 1f; /** * Construct the drag view. @@ -67,6 +68,7 @@ public class DragView extends View { int left, int top, int width, int height, final float initialScale) { super(launcher); mDragLayer = launcher.getDragLayer(); + mInitialScale = initialScale; final Resources res = getResources(); final float offsetX = res.getDimensionPixelSize(R.dimen.dragViewOffsetX); @@ -151,6 +153,14 @@ public class DragView extends View { return mDragRegion; } + public float getInitialScale() { + return mInitialScale; + } + + public void updateInitialScaleToCurrentScale() { + mInitialScale = getScaleX(); + } + @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { setMeasuredDimension(mBitmap.getWidth(), mBitmap.getHeight()); @@ -233,6 +243,11 @@ public class DragView extends View { */ public void show(int touchX, int touchY) { mDragLayer.addView(this); + + // Enable hw-layers on this view + setLayerType(View.LAYER_TYPE_HARDWARE, null); + + // Start the pick-up animation DragLayer.LayoutParams lp = new DragLayer.LayoutParams(0, 0); lp.width = mBitmap.getWidth(); lp.height = mBitmap.getHeight(); @@ -267,6 +282,9 @@ public class DragView extends View { void remove() { if (getParent() != null) { + // Disable hw-layers on this view + setLayerType(View.LAYER_TYPE_NONE, null); + mDragLayer.removeView(DragView.this); } } -- cgit v1.2.3