Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Daniel Sandler | 325dc23 | 2013-06-05 22:57:57 -0400 | [diff] [blame] | 17 | package com.android.launcher3; |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 18 | |
Patrick Dubroy | a669d79 | 2010-11-23 14:40:33 -0800 | [diff] [blame] | 19 | import android.animation.ValueAnimator; |
| 20 | import android.animation.ValueAnimator.AnimatorUpdateListener; |
Patrick Dubroy | de7658b | 2010-09-27 11:15:43 -0700 | [diff] [blame] | 21 | import android.content.res.Resources; |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 22 | import android.graphics.Bitmap; |
| 23 | import android.graphics.Canvas; |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 24 | import android.graphics.Paint; |
Winson Chung | b8c69f3 | 2011-10-19 21:36:08 -0700 | [diff] [blame] | 25 | import android.graphics.Point; |
Winson Chung | 61967cb | 2012-02-28 18:11:33 -0800 | [diff] [blame] | 26 | import android.graphics.PorterDuff; |
| 27 | import android.graphics.PorterDuffColorFilter; |
Adam Cohen | e3e27a8 | 2011-04-15 12:07:39 -0700 | [diff] [blame] | 28 | import android.graphics.Rect; |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 29 | import android.view.View; |
Patrick Dubroy | a669d79 | 2010-11-23 14:40:33 -0800 | [diff] [blame] | 30 | import android.view.animation.DecelerateInterpolator; |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 31 | |
Patrick Dubroy | a669d79 | 2010-11-23 14:40:33 -0800 | [diff] [blame] | 32 | public class DragView extends View { |
Winson Chung | 867ca62 | 2012-02-21 15:48:35 -0800 | [diff] [blame] | 33 | private static float sDragAlpha = 1f; |
Winson Chung | 7bd1bbb | 2012-02-13 18:29:29 -0800 | [diff] [blame] | 34 | |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 35 | private Bitmap mBitmap; |
Adam Cohen | ed66b2b | 2012-01-23 17:28:51 -0800 | [diff] [blame] | 36 | private Bitmap mCrossFadeBitmap; |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 37 | private Paint mPaint; |
| 38 | private int mRegistrationX; |
| 39 | private int mRegistrationY; |
| 40 | |
Winson Chung | b8c69f3 | 2011-10-19 21:36:08 -0700 | [diff] [blame] | 41 | private Point mDragVisualizeOffset = null; |
Adam Cohen | e3e27a8 | 2011-04-15 12:07:39 -0700 | [diff] [blame] | 42 | private Rect mDragRegion = null; |
Adam Cohen | 8dfcba4 | 2011-07-07 16:38:18 -0700 | [diff] [blame] | 43 | private DragLayer mDragLayer = null; |
Adam Cohen | fc53cd2 | 2011-07-20 15:45:11 -0700 | [diff] [blame] | 44 | private boolean mHasDrawn = false; |
Adam Cohen | ed66b2b | 2012-01-23 17:28:51 -0800 | [diff] [blame] | 45 | private float mCrossFadeProgress = 0f; |
Michael Jurka | a63c452 | 2010-08-19 13:52:27 -0700 | [diff] [blame] | 46 | |
Patrick Dubroy | a669d79 | 2010-11-23 14:40:33 -0800 | [diff] [blame] | 47 | ValueAnimator mAnim; |
Patrick Dubroy | a669d79 | 2010-11-23 14:40:33 -0800 | [diff] [blame] | 48 | private float mOffsetX = 0.0f; |
| 49 | private float mOffsetY = 0.0f; |
Winson Chung | 043f2af | 2012-03-01 16:09:54 -0800 | [diff] [blame] | 50 | private float mInitialScale = 1f; |
Winson Chung | eeb5bbc | 2013-11-13 15:47:05 -0800 | [diff] [blame] | 51 | // The intrinsic icon scale factor is the scale factor for a drag icon over the workspace |
| 52 | // size. This is ignored for non-icons. |
| 53 | private float mIntrinsicIconScale = 1f; |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 54 | |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 55 | /** |
| 56 | * Construct the drag view. |
| 57 | * <p> |
| 58 | * The registration point is the point inside our view that the touch events should |
| 59 | * be centered upon. |
| 60 | * |
Adam Cohen | 8dfcba4 | 2011-07-07 16:38:18 -0700 | [diff] [blame] | 61 | * @param launcher The Launcher instance |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 62 | * @param bitmap The view that we're dragging around. We scale it up when we draw it. |
| 63 | * @param registrationX The x coordinate of the registration point. |
| 64 | * @param registrationY The y coordinate of the registration point. |
| 65 | */ |
Adam Cohen | 8dfcba4 | 2011-07-07 16:38:18 -0700 | [diff] [blame] | 66 | public DragView(Launcher launcher, Bitmap bitmap, int registrationX, int registrationY, |
Winson Chung | 72d5984 | 2012-02-22 13:51:36 -0800 | [diff] [blame] | 67 | int left, int top, int width, int height, final float initialScale) { |
Adam Cohen | 8dfcba4 | 2011-07-07 16:38:18 -0700 | [diff] [blame] | 68 | super(launcher); |
| 69 | mDragLayer = launcher.getDragLayer(); |
Winson Chung | 043f2af | 2012-03-01 16:09:54 -0800 | [diff] [blame] | 70 | mInitialScale = initialScale; |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 71 | |
Patrick Dubroy | de7658b | 2010-09-27 11:15:43 -0700 | [diff] [blame] | 72 | final Resources res = getResources(); |
Winson Chung | 7bd1bbb | 2012-02-13 18:29:29 -0800 | [diff] [blame] | 73 | final float offsetX = res.getDimensionPixelSize(R.dimen.dragViewOffsetX); |
| 74 | final float offsetY = res.getDimensionPixelSize(R.dimen.dragViewOffsetY); |
| 75 | final float scaleDps = res.getDimensionPixelSize(R.dimen.dragViewScale); |
| 76 | final float scale = (width + scaleDps) / width; |
Patrick Dubroy | a669d79 | 2010-11-23 14:40:33 -0800 | [diff] [blame] | 77 | |
Adam Cohen | 307fe23 | 2012-08-16 17:55:58 -0700 | [diff] [blame] | 78 | // Set the initial scale to avoid any jumps |
| 79 | setScaleX(initialScale); |
| 80 | setScaleY(initialScale); |
| 81 | |
Patrick Dubroy | a669d79 | 2010-11-23 14:40:33 -0800 | [diff] [blame] | 82 | // Animate the view into the correct position |
Michael Jurka | f1ad608 | 2013-03-13 12:55:46 +0100 | [diff] [blame] | 83 | mAnim = LauncherAnimUtils.ofFloat(this, 0f, 1f); |
Winson Chung | 7bd1bbb | 2012-02-13 18:29:29 -0800 | [diff] [blame] | 84 | mAnim.setDuration(150); |
Patrick Dubroy | a669d79 | 2010-11-23 14:40:33 -0800 | [diff] [blame] | 85 | mAnim.addUpdateListener(new AnimatorUpdateListener() { |
| 86 | @Override |
| 87 | public void onAnimationUpdate(ValueAnimator animation) { |
| 88 | final float value = (Float) animation.getAnimatedValue(); |
| 89 | |
| 90 | final int deltaX = (int) ((value * offsetX) - mOffsetX); |
| 91 | final int deltaY = (int) ((value * offsetY) - mOffsetY); |
| 92 | |
| 93 | mOffsetX += deltaX; |
| 94 | mOffsetY += deltaY; |
Winson Chung | 72d5984 | 2012-02-22 13:51:36 -0800 | [diff] [blame] | 95 | setScaleX(initialScale + (value * (scale - initialScale))); |
| 96 | setScaleY(initialScale + (value * (scale - initialScale))); |
Winson Chung | 867ca62 | 2012-02-21 15:48:35 -0800 | [diff] [blame] | 97 | if (sDragAlpha != 1f) { |
| 98 | setAlpha(sDragAlpha * value + (1f - value)); |
| 99 | } |
Patrick Dubroy | a669d79 | 2010-11-23 14:40:33 -0800 | [diff] [blame] | 100 | |
| 101 | if (getParent() == null) { |
| 102 | animation.cancel(); |
| 103 | } else { |
Winson Chung | 7bd1bbb | 2012-02-13 18:29:29 -0800 | [diff] [blame] | 104 | setTranslationX(getTranslationX() + deltaX); |
| 105 | setTranslationY(getTranslationY() + deltaY); |
Patrick Dubroy | a669d79 | 2010-11-23 14:40:33 -0800 | [diff] [blame] | 106 | } |
| 107 | } |
| 108 | }); |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 109 | |
Winson Chung | 7bd1bbb | 2012-02-13 18:29:29 -0800 | [diff] [blame] | 110 | mBitmap = Bitmap.createBitmap(bitmap, left, top, width, height); |
Adam Cohen | e3e27a8 | 2011-04-15 12:07:39 -0700 | [diff] [blame] | 111 | setDragRegion(new Rect(0, 0, width, height)); |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 112 | |
| 113 | // The point in our scaled bitmap that the touch events are located |
Patrick Dubroy | a669d79 | 2010-11-23 14:40:33 -0800 | [diff] [blame] | 114 | mRegistrationX = registrationX; |
| 115 | mRegistrationY = registrationY; |
Patrick Dubroy | 62bbb3c | 2011-01-17 15:29:27 -0800 | [diff] [blame] | 116 | |
| 117 | // Force a measure, because Workspace uses getMeasuredHeight() before the layout pass |
| 118 | int ms = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); |
| 119 | measure(ms, ms); |
Michael Jurka | 6cfafb9 | 2012-02-23 18:25:43 -0800 | [diff] [blame] | 120 | mPaint = new Paint(Paint.FILTER_BITMAP_FLAG); |
Patrick Dubroy | 62bbb3c | 2011-01-17 15:29:27 -0800 | [diff] [blame] | 121 | } |
| 122 | |
Winson Chung | eeb5bbc | 2013-11-13 15:47:05 -0800 | [diff] [blame] | 123 | /** Sets the scale of the view over the normal workspace icon size. */ |
| 124 | public void setIntrinsicIconScaleFactor(float scale) { |
| 125 | mIntrinsicIconScale = scale; |
| 126 | } |
| 127 | |
| 128 | public float getIntrinsicIconScaleFactor() { |
| 129 | return mIntrinsicIconScale; |
| 130 | } |
| 131 | |
Patrick Dubroy | 62bbb3c | 2011-01-17 15:29:27 -0800 | [diff] [blame] | 132 | public float getOffsetY() { |
| 133 | return mOffsetY; |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 134 | } |
| 135 | |
Michael Jurka | a63c452 | 2010-08-19 13:52:27 -0700 | [diff] [blame] | 136 | public int getDragRegionLeft() { |
Adam Cohen | e3e27a8 | 2011-04-15 12:07:39 -0700 | [diff] [blame] | 137 | return mDragRegion.left; |
Michael Jurka | a63c452 | 2010-08-19 13:52:27 -0700 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | public int getDragRegionTop() { |
Adam Cohen | e3e27a8 | 2011-04-15 12:07:39 -0700 | [diff] [blame] | 141 | return mDragRegion.top; |
Michael Jurka | a63c452 | 2010-08-19 13:52:27 -0700 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | public int getDragRegionWidth() { |
Adam Cohen | e3e27a8 | 2011-04-15 12:07:39 -0700 | [diff] [blame] | 145 | return mDragRegion.width(); |
Michael Jurka | a63c452 | 2010-08-19 13:52:27 -0700 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | public int getDragRegionHeight() { |
Adam Cohen | e3e27a8 | 2011-04-15 12:07:39 -0700 | [diff] [blame] | 149 | return mDragRegion.height(); |
| 150 | } |
| 151 | |
Winson Chung | b8c69f3 | 2011-10-19 21:36:08 -0700 | [diff] [blame] | 152 | public void setDragVisualizeOffset(Point p) { |
| 153 | mDragVisualizeOffset = p; |
| 154 | } |
| 155 | |
| 156 | public Point getDragVisualizeOffset() { |
| 157 | return mDragVisualizeOffset; |
| 158 | } |
| 159 | |
Adam Cohen | e3e27a8 | 2011-04-15 12:07:39 -0700 | [diff] [blame] | 160 | public void setDragRegion(Rect r) { |
| 161 | mDragRegion = r; |
| 162 | } |
| 163 | |
| 164 | public Rect getDragRegion() { |
| 165 | return mDragRegion; |
Michael Jurka | a63c452 | 2010-08-19 13:52:27 -0700 | [diff] [blame] | 166 | } |
| 167 | |
Winson Chung | 043f2af | 2012-03-01 16:09:54 -0800 | [diff] [blame] | 168 | public float getInitialScale() { |
| 169 | return mInitialScale; |
| 170 | } |
| 171 | |
| 172 | public void updateInitialScaleToCurrentScale() { |
| 173 | mInitialScale = getScaleX(); |
| 174 | } |
| 175 | |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 176 | @Override |
| 177 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
Joe Onorato | eebd924 | 2009-11-04 13:48:32 -0500 | [diff] [blame] | 178 | setMeasuredDimension(mBitmap.getWidth(), mBitmap.getHeight()); |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | @Override |
| 182 | protected void onDraw(Canvas canvas) { |
Michael Jurka | 3a9fced | 2012-04-13 14:44:29 -0700 | [diff] [blame] | 183 | @SuppressWarnings("all") // suppress dead code warning |
| 184 | final boolean debug = false; |
| 185 | if (debug) { |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 186 | Paint p = new Paint(); |
| 187 | p.setStyle(Paint.Style.FILL); |
Winson Chung | eecf02d | 2012-03-02 17:14:58 -0800 | [diff] [blame] | 188 | p.setColor(0x66ffffff); |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 189 | canvas.drawRect(0, 0, getWidth(), getHeight(), p); |
| 190 | } |
Patrick Dubroy | a669d79 | 2010-11-23 14:40:33 -0800 | [diff] [blame] | 191 | |
Adam Cohen | fc53cd2 | 2011-07-20 15:45:11 -0700 | [diff] [blame] | 192 | mHasDrawn = true; |
Adam Cohen | ed66b2b | 2012-01-23 17:28:51 -0800 | [diff] [blame] | 193 | boolean crossFade = mCrossFadeProgress > 0 && mCrossFadeBitmap != null; |
| 194 | if (crossFade) { |
| 195 | int alpha = crossFade ? (int) (255 * (1 - mCrossFadeProgress)) : 255; |
| 196 | mPaint.setAlpha(alpha); |
| 197 | } |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 198 | canvas.drawBitmap(mBitmap, 0.0f, 0.0f, mPaint); |
Adam Cohen | ed66b2b | 2012-01-23 17:28:51 -0800 | [diff] [blame] | 199 | if (crossFade) { |
| 200 | mPaint.setAlpha((int) (255 * mCrossFadeProgress)); |
| 201 | canvas.save(); |
| 202 | float sX = (mBitmap.getWidth() * 1.0f) / mCrossFadeBitmap.getWidth(); |
| 203 | float sY = (mBitmap.getHeight() * 1.0f) / mCrossFadeBitmap.getHeight(); |
| 204 | canvas.scale(sX, sY); |
| 205 | canvas.drawBitmap(mCrossFadeBitmap, 0.0f, 0.0f, mPaint); |
| 206 | canvas.restore(); |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | public void setCrossFadeBitmap(Bitmap crossFadeBitmap) { |
| 211 | mCrossFadeBitmap = crossFadeBitmap; |
| 212 | } |
| 213 | |
| 214 | public void crossFade(int duration) { |
Michael Jurka | f1ad608 | 2013-03-13 12:55:46 +0100 | [diff] [blame] | 215 | ValueAnimator va = LauncherAnimUtils.ofFloat(this, 0f, 1f); |
Adam Cohen | ed66b2b | 2012-01-23 17:28:51 -0800 | [diff] [blame] | 216 | va.setDuration(duration); |
| 217 | va.setInterpolator(new DecelerateInterpolator(1.5f)); |
| 218 | va.addUpdateListener(new AnimatorUpdateListener() { |
| 219 | @Override |
| 220 | public void onAnimationUpdate(ValueAnimator animation) { |
| 221 | mCrossFadeProgress = animation.getAnimatedFraction(); |
| 222 | } |
| 223 | }); |
| 224 | va.start(); |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 225 | } |
| 226 | |
Winson Chung | 61967cb | 2012-02-28 18:11:33 -0800 | [diff] [blame] | 227 | public void setColor(int color) { |
Michael Jurka | 6cfafb9 | 2012-02-23 18:25:43 -0800 | [diff] [blame] | 228 | if (mPaint == null) { |
| 229 | mPaint = new Paint(Paint.FILTER_BITMAP_FLAG); |
| 230 | } |
Winson Chung | 61967cb | 2012-02-28 18:11:33 -0800 | [diff] [blame] | 231 | if (color != 0) { |
| 232 | mPaint.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)); |
| 233 | } else { |
| 234 | mPaint.setColorFilter(null); |
| 235 | } |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 236 | invalidate(); |
| 237 | } |
| 238 | |
Adam Cohen | fc53cd2 | 2011-07-20 15:45:11 -0700 | [diff] [blame] | 239 | public boolean hasDrawn() { |
| 240 | return mHasDrawn; |
| 241 | } |
| 242 | |
Adam Cohen | 3e8f811 | 2011-07-02 18:03:00 -0700 | [diff] [blame] | 243 | @Override |
| 244 | public void setAlpha(float alpha) { |
| 245 | super.setAlpha(alpha); |
Adam Cohen | 3e8f811 | 2011-07-02 18:03:00 -0700 | [diff] [blame] | 246 | mPaint.setAlpha((int) (255 * alpha)); |
| 247 | invalidate(); |
| 248 | } |
| 249 | |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 250 | /** |
| 251 | * Create a window containing this view and show it. |
| 252 | * |
| 253 | * @param windowToken obtained from v.getWindowToken() from one of your views |
Adam Cohen | 8dfcba4 | 2011-07-07 16:38:18 -0700 | [diff] [blame] | 254 | * @param touchX the x coordinate the user touched in DragLayer coordinates |
| 255 | * @param touchY the y coordinate the user touched in DragLayer coordinates |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 256 | */ |
Adam Cohen | 8dfcba4 | 2011-07-07 16:38:18 -0700 | [diff] [blame] | 257 | public void show(int touchX, int touchY) { |
| 258 | mDragLayer.addView(this); |
Winson Chung | 043f2af | 2012-03-01 16:09:54 -0800 | [diff] [blame] | 259 | |
Winson Chung | 043f2af | 2012-03-01 16:09:54 -0800 | [diff] [blame] | 260 | // Start the pick-up animation |
Adam Cohen | 8dfcba4 | 2011-07-07 16:38:18 -0700 | [diff] [blame] | 261 | DragLayer.LayoutParams lp = new DragLayer.LayoutParams(0, 0); |
| 262 | lp.width = mBitmap.getWidth(); |
| 263 | lp.height = mBitmap.getHeight(); |
Adam Cohen | 8dfcba4 | 2011-07-07 16:38:18 -0700 | [diff] [blame] | 264 | lp.customPosition = true; |
| 265 | setLayoutParams(lp); |
Winson Chung | 7bd1bbb | 2012-02-13 18:29:29 -0800 | [diff] [blame] | 266 | setTranslationX(touchX - mRegistrationX); |
| 267 | setTranslationY(touchY - mRegistrationY); |
Michael Jurka | ca99383 | 2012-06-29 15:17:04 -0700 | [diff] [blame] | 268 | // Post the animation to skip other expensive work happening on the first frame |
| 269 | post(new Runnable() { |
| 270 | public void run() { |
| 271 | mAnim.start(); |
| 272 | } |
| 273 | }); |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 274 | } |
Adam Cohen | 716b51e | 2011-06-30 12:09:54 -0700 | [diff] [blame] | 275 | |
Winson Chung | 7bd1bbb | 2012-02-13 18:29:29 -0800 | [diff] [blame] | 276 | public void cancelAnimation() { |
| 277 | if (mAnim != null && mAnim.isRunning()) { |
| 278 | mAnim.cancel(); |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | public void resetLayoutParams() { |
| 283 | mOffsetX = mOffsetY = 0; |
| 284 | requestLayout(); |
| 285 | } |
| 286 | |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 287 | /** |
| 288 | * Move the window containing this view. |
| 289 | * |
Adam Cohen | 8dfcba4 | 2011-07-07 16:38:18 -0700 | [diff] [blame] | 290 | * @param touchX the x coordinate the user touched in DragLayer coordinates |
| 291 | * @param touchY the y coordinate the user touched in DragLayer coordinates |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 292 | */ |
| 293 | void move(int touchX, int touchY) { |
Winson Chung | 7bd1bbb | 2012-02-13 18:29:29 -0800 | [diff] [blame] | 294 | setTranslationX(touchX - mRegistrationX + (int) mOffsetX); |
| 295 | setTranslationY(touchY - mRegistrationY + (int) mOffsetY); |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | void remove() { |
Winson Chung | 7bd1bbb | 2012-02-13 18:29:29 -0800 | [diff] [blame] | 299 | if (getParent() != null) { |
| 300 | mDragLayer.removeView(DragView.this); |
| 301 | } |
Patrick Dubroy | 6f13342 | 2011-02-24 12:16:12 -0800 | [diff] [blame] | 302 | } |
Joe Onorato | 00acb12 | 2009-08-04 16:04:30 -0400 | [diff] [blame] | 303 | } |
| 304 | |