blob: daabbcc4cf2923bd425db686f16478905ae88fb5 [file] [log] [blame]
The Android Open Source Project31dd5032009-03-03 19:32:27 -08001/*
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
Joe Onoratoa5902522009-07-30 13:37:37 -070017package com.android.launcher2;
The Android Open Source Project31dd5032009-03-03 19:32:27 -080018
Joe Onorato00acb122009-08-04 16:04:30 -040019import android.content.Context;
20import android.graphics.Bitmap;
Joe Onorato00acb122009-08-04 16:04:30 -040021import android.graphics.Rect;
22import android.graphics.RectF;
23import android.os.IBinder;
24import android.os.Handler;
25import android.os.Vibrator;
Joe Onoratoe048e8a2009-09-25 10:39:17 -070026import android.util.DisplayMetrics;
Joe Onorato00acb122009-08-04 16:04:30 -040027import android.util.Log;
The Android Open Source Project31dd5032009-03-03 19:32:27 -080028import android.view.View;
Joe Onorato00acb122009-08-04 16:04:30 -040029import android.view.KeyEvent;
30import android.view.MotionEvent;
Joe Onoratoe048e8a2009-09-25 10:39:17 -070031import android.view.WindowManager;
Joe Onorato00acb122009-08-04 16:04:30 -040032import android.view.inputmethod.InputMethodManager;
Joe Onorato00acb122009-08-04 16:04:30 -040033
34import java.util.ArrayList;
The Android Open Source Project31dd5032009-03-03 19:32:27 -080035
36/**
Joe Onorato00acb122009-08-04 16:04:30 -040037 * Class for initiating a drag within a view or across multiple views.
The Android Open Source Project31dd5032009-03-03 19:32:27 -080038 */
Joe Onorato00acb122009-08-04 16:04:30 -040039public class DragController {
Romain Guyea3763c2010-01-11 18:02:04 -080040 @SuppressWarnings({"UnusedDeclaration"})
Joe Onorato2e5c4322009-10-06 12:34:42 -070041 private static final String TAG = "Launcher.DragController";
42
Joe Onorato00acb122009-08-04 16:04:30 -040043 /** Indicates the drag is a move. */
44 public static int DRAG_ACTION_MOVE = 0;
45
46 /** Indicates the drag is a copy. */
47 public static int DRAG_ACTION_COPY = 1;
48
49 private static final int SCROLL_DELAY = 600;
50 private static final int SCROLL_ZONE = 20;
51 private static final int VIBRATE_DURATION = 35;
52
53 private static final boolean PROFILE_DRAWING_DURING_DRAG = false;
54
55 private static final int SCROLL_OUTSIDE_ZONE = 0;
56 private static final int SCROLL_WAITING_IN_ZONE = 1;
57
58 private static final int SCROLL_LEFT = 0;
59 private static final int SCROLL_RIGHT = 1;
60
61 private Context mContext;
62 private Handler mHandler;
63 private final Vibrator mVibrator = new Vibrator();
64
65 // temporaries to avoid gc thrash
66 private Rect mRectTemp = new Rect();
67 private final int[] mCoordinatesTemp = new int[2];
68
69 /** Whether or not we're dragging. */
70 private boolean mDragging;
71
72 /** X coordinate of the down event. */
73 private float mMotionDownX;
74
75 /** Y coordinate of the down event. */
76 private float mMotionDownY;
77
Joe Onoratoe048e8a2009-09-25 10:39:17 -070078 /** Info about the screen for clamping. */
79 private DisplayMetrics mDisplayMetrics = new DisplayMetrics();
80
Joe Onorato00acb122009-08-04 16:04:30 -040081 /** Original view that is being dragged. */
82 private View mOriginator;
83
Joe Onorato00acb122009-08-04 16:04:30 -040084 /** X offset from the upper-left corner of the cell to where we touched. */
85 private float mTouchOffsetX;
86
87 /** Y offset from the upper-left corner of the cell to where we touched. */
88 private float mTouchOffsetY;
89
90 /** Where the drag originated */
91 private DragSource mDragSource;
92
93 /** The data associated with the object being dragged */
94 private Object mDragInfo;
95
96 /** The view that moves around while you drag. */
97 private DragView mDragView;
98
99 /** Who can receive drop events */
100 private ArrayList<DropTarget> mDropTargets = new ArrayList<DropTarget>();
101
102 private DragListener mListener;
103
104 /** The window token used as the parent for the DragView. */
105 private IBinder mWindowToken;
106
107 /** The view that will be scrolled when dragging to the left and right edges of the screen. */
108 private View mScrollView;
109
Romain Guyea3763c2010-01-11 18:02:04 -0800110 private View mMoveTarget;
111
Joe Onorato00acb122009-08-04 16:04:30 -0400112 private DragScroller mDragScroller;
113 private int mScrollState = SCROLL_OUTSIDE_ZONE;
114 private ScrollRunnable mScrollRunnable = new ScrollRunnable();
115
116 private RectF mDeleteRegion;
117 private DropTarget mLastDropTarget;
118
119 private InputMethodManager mInputMethodManager;
120
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800121 /**
122 * Interface to receive notifications when a drag starts or stops
123 */
124 interface DragListener {
125
126 /**
127 * A drag has begun
128 *
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800129 * @param source An object representing where the drag originated
130 * @param info The data associated with the object that is being dragged
131 * @param dragAction The drag action: either {@link DragController#DRAG_ACTION_MOVE}
132 * or {@link DragController#DRAG_ACTION_COPY}
133 */
Joe Onorato5162ea92009-09-03 09:39:42 -0700134 void onDragStart(DragSource source, Object info, int dragAction);
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800135
136 /**
137 * The drag has eneded
138 */
139 void onDragEnd();
140 }
141
142 /**
Joe Onorato00acb122009-08-04 16:04:30 -0400143 * Used to create a new DragLayer from XML.
144 *
145 * @param context The application's context.
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800146 */
Joe Onorato00acb122009-08-04 16:04:30 -0400147 public DragController(Context context) {
148 mContext = context;
149 mHandler = new Handler();
150 }
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800151
152 /**
Joe Onorato5162ea92009-09-03 09:39:42 -0700153 * Starts a drag.
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800154 *
155 * @param v The view that is being dragged
156 * @param source An object representing where the drag originated
Romain Guyea3763c2010-01-11 18:02:04 -0800157 * @param dragInfo The data associated with the object that is being dragged
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800158 * @param dragAction The drag action: either {@link #DRAG_ACTION_MOVE} or
159 * {@link #DRAG_ACTION_COPY}
160 */
Joe Onorato00acb122009-08-04 16:04:30 -0400161 public void startDrag(View v, DragSource source, Object dragInfo, int dragAction) {
Joe Onorato5162ea92009-09-03 09:39:42 -0700162 mOriginator = v;
163
164 Bitmap b = getViewBitmap(v);
165
166 int[] loc = mCoordinatesTemp;
167 v.getLocationOnScreen(loc);
168 int screenX = loc[0];
169 int screenY = loc[1];
170
171 startDrag(b, screenX, screenY, 0, 0, b.getWidth(), b.getHeight(),
172 source, dragInfo, dragAction);
173
174 b.recycle();
175
176 if (dragAction == DRAG_ACTION_MOVE) {
177 v.setVisibility(View.GONE);
178 }
179 }
180
181 /**
182 * Starts a drag.
183 *
184 * @param b The bitmap to display as the drag image. It will be re-scaled to the
185 * enlarged size.
186 * @param screenX The x position on screen of the left-top of the bitmap.
187 * @param screenY The y position on screen of the left-top of the bitmap.
188 * @param textureLeft The left edge of the region inside b to use.
189 * @param textureTop The top edge of the region inside b to use.
190 * @param textureWidth The width of the region inside b to use.
191 * @param textureHeight The height of the region inside b to use.
192 * @param source An object representing where the drag originated
Romain Guyea3763c2010-01-11 18:02:04 -0800193 * @param dragInfo The data associated with the object that is being dragged
Joe Onorato5162ea92009-09-03 09:39:42 -0700194 * @param dragAction The drag action: either {@link #DRAG_ACTION_MOVE} or
195 * {@link #DRAG_ACTION_COPY}
196 */
197 public void startDrag(Bitmap b, int screenX, int screenY,
198 int textureLeft, int textureTop, int textureWidth, int textureHeight,
199 DragSource source, Object dragInfo, int dragAction) {
Joe Onorato00acb122009-08-04 16:04:30 -0400200 if (PROFILE_DRAWING_DURING_DRAG) {
201 android.os.Debug.startMethodTracing("Launcher");
202 }
203
204 // Hide soft keyboard, if visible
205 if (mInputMethodManager == null) {
206 mInputMethodManager = (InputMethodManager)
207 mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
208 }
209 mInputMethodManager.hideSoftInputFromWindow(mWindowToken, 0);
210
211 if (mListener != null) {
Joe Onorato5162ea92009-09-03 09:39:42 -0700212 mListener.onDragStart(source, dragInfo, dragAction);
Joe Onorato00acb122009-08-04 16:04:30 -0400213 }
214
Joe Onorato00acb122009-08-04 16:04:30 -0400215 int registrationX = ((int)mMotionDownX) - screenX;
216 int registrationY = ((int)mMotionDownY) - screenY;
217
218 mTouchOffsetX = mMotionDownX - screenX;
219 mTouchOffsetY = mMotionDownY - screenY;
220
221 mDragging = true;
Joe Onorato00acb122009-08-04 16:04:30 -0400222 mDragSource = source;
223 mDragInfo = dragInfo;
224
225 mVibrator.vibrate(VIBRATE_DURATION);
226
Joe Onorato5162ea92009-09-03 09:39:42 -0700227 DragView dragView = mDragView = new DragView(mContext, b, registrationX, registrationY,
228 textureLeft, textureTop, textureWidth, textureHeight);
Joe Onorato00acb122009-08-04 16:04:30 -0400229 dragView.show(mWindowToken, (int)mMotionDownX, (int)mMotionDownY);
Joe Onorato00acb122009-08-04 16:04:30 -0400230 }
231
232 /**
233 * Draw the view into a bitmap.
234 */
235 private Bitmap getViewBitmap(View v) {
236 v.clearFocus();
237 v.setPressed(false);
238
239 boolean willNotCache = v.willNotCacheDrawing();
240 v.setWillNotCacheDrawing(false);
241
242 // Reset the drawing cache background color to fully transparent
243 // for the duration of this operation
244 int color = v.getDrawingCacheBackgroundColor();
245 v.setDrawingCacheBackgroundColor(0);
246
247 if (color != 0) {
248 v.destroyDrawingCache();
249 }
250 v.buildDrawingCache();
251 Bitmap cacheBitmap = v.getDrawingCache();
252
253 Bitmap bitmap = Bitmap.createBitmap(cacheBitmap);
254
255 // Restore the view
256 v.destroyDrawingCache();
257 v.setWillNotCacheDrawing(willNotCache);
258 v.setDrawingCacheBackgroundColor(color);
259
260 return bitmap;
261 }
262
263 /**
264 * Call this from a drag source view like this:
265 *
266 * <pre>
267 * @Override
268 * public boolean dispatchKeyEvent(KeyEvent event) {
269 * return mDragController.dispatchKeyEvent(this, event)
270 * || super.dispatchKeyEvent(event);
271 * </pre>
272 */
Romain Guyea3763c2010-01-11 18:02:04 -0800273 @SuppressWarnings({"UnusedDeclaration"})
Joe Onorato00acb122009-08-04 16:04:30 -0400274 public boolean dispatchKeyEvent(KeyEvent event) {
275 return mDragging;
276 }
277
Joe Onorato24b6fd82009-11-12 13:47:09 -0800278 /**
279 * Stop dragging without dropping.
280 */
281 public void cancelDrag() {
282 endDrag();
283 }
284
Joe Onorato00acb122009-08-04 16:04:30 -0400285 private void endDrag() {
286 if (mDragging) {
287 mDragging = false;
288 if (mOriginator != null) {
289 mOriginator.setVisibility(View.VISIBLE);
290 }
291 if (mListener != null) {
292 mListener.onDragEnd();
293 }
294 if (mDragView != null) {
295 mDragView.remove();
296 mDragView = null;
297 }
Joe Onorato00acb122009-08-04 16:04:30 -0400298 }
299 }
300
301 /**
302 * Call this from a drag source view.
303 */
304 public boolean onInterceptTouchEvent(MotionEvent ev) {
Joe Onorato9c1289c2009-08-17 11:03:03 -0400305 if (false) {
Joe Onoratoa30ce8e2009-11-11 08:16:49 -0800306 Log.d(Launcher.TAG, "DragController.onInterceptTouchEvent " + ev + " mDragging="
Joe Onorato9c1289c2009-08-17 11:03:03 -0400307 + mDragging);
308 }
Joe Onorato00acb122009-08-04 16:04:30 -0400309 final int action = ev.getAction();
310
Joe Onorato87467d32009-11-08 14:36:43 -0500311 if (action == MotionEvent.ACTION_DOWN) {
312 recordScreenSize();
313 }
314
Joe Onoratoe048e8a2009-09-25 10:39:17 -0700315 final int screenX = clamp((int)ev.getRawX(), 0, mDisplayMetrics.widthPixels);
316 final int screenY = clamp((int)ev.getRawY(), 0, mDisplayMetrics.heightPixels);
Joe Onorato00acb122009-08-04 16:04:30 -0400317
318 switch (action) {
319 case MotionEvent.ACTION_MOVE:
320 break;
321
322 case MotionEvent.ACTION_DOWN:
323 // Remember location of down touch
324 mMotionDownX = screenX;
325 mMotionDownY = screenY;
326 mLastDropTarget = null;
327 break;
328
329 case MotionEvent.ACTION_CANCEL:
330 case MotionEvent.ACTION_UP:
331 if (mDragging) {
332 drop(screenX, screenY);
333 }
334 endDrag();
335 break;
336 }
337
338 return mDragging;
339 }
340
341 /**
Romain Guyea3763c2010-01-11 18:02:04 -0800342 * Sets the view that should handle move events.
343 */
344 void setMoveTarget(View view) {
345 mMoveTarget = view;
346 }
347
348 public boolean dispatchUnhandledMove(View focused, int direction) {
349 return mMoveTarget != null && mMoveTarget.dispatchUnhandledMove(focused, direction);
350 }
351
352 /**
Joe Onorato00acb122009-08-04 16:04:30 -0400353 * Call this from a drag source view.
354 */
355 public boolean onTouchEvent(MotionEvent ev) {
356 View scrollView = mScrollView;
357
358 if (!mDragging) {
359 return false;
360 }
361
362 final int action = ev.getAction();
Joe Onoratoe048e8a2009-09-25 10:39:17 -0700363 final int screenX = clamp((int)ev.getRawX(), 0, mDisplayMetrics.widthPixels);
364 final int screenY = clamp((int)ev.getRawY(), 0, mDisplayMetrics.heightPixels);
Joe Onorato00acb122009-08-04 16:04:30 -0400365
366 switch (action) {
367 case MotionEvent.ACTION_DOWN:
Joe Onorato00acb122009-08-04 16:04:30 -0400368 // Remember where the motion event started
Joe Onoratoe048e8a2009-09-25 10:39:17 -0700369 mMotionDownX = screenX;
370 mMotionDownY = screenY;
Joe Onorato00acb122009-08-04 16:04:30 -0400371
Joe Onoratoe048e8a2009-09-25 10:39:17 -0700372 if ((screenX < SCROLL_ZONE) || (screenX > scrollView.getWidth() - SCROLL_ZONE)) {
Joe Onorato00acb122009-08-04 16:04:30 -0400373 mScrollState = SCROLL_WAITING_IN_ZONE;
374 mHandler.postDelayed(mScrollRunnable, SCROLL_DELAY);
375 } else {
376 mScrollState = SCROLL_OUTSIDE_ZONE;
377 }
378
379 break;
380 case MotionEvent.ACTION_MOVE:
Joe Onoratoe048e8a2009-09-25 10:39:17 -0700381 // Update the drag view. Don't use the clamped pos here so the dragging looks
382 // like it goes off screen a little, intead of bumping up against the edge.
Joe Onorato00acb122009-08-04 16:04:30 -0400383 mDragView.move((int)ev.getRawX(), (int)ev.getRawY());
384
385 // Drop on someone?
386 final int[] coordinates = mCoordinatesTemp;
Romain Guyea3763c2010-01-11 18:02:04 -0800387 DropTarget dropTarget = findDropTarget(screenX, screenY, coordinates);
Joe Onorato00acb122009-08-04 16:04:30 -0400388 if (dropTarget != null) {
389 if (mLastDropTarget == dropTarget) {
390 dropTarget.onDragOver(mDragSource, coordinates[0], coordinates[1],
391 (int) mTouchOffsetX, (int) mTouchOffsetY, mDragView, mDragInfo);
392 } else {
393 if (mLastDropTarget != null) {
394 mLastDropTarget.onDragExit(mDragSource, coordinates[0], coordinates[1],
395 (int) mTouchOffsetX, (int) mTouchOffsetY, mDragView, mDragInfo);
396 }
397 dropTarget.onDragEnter(mDragSource, coordinates[0], coordinates[1],
398 (int) mTouchOffsetX, (int) mTouchOffsetY, mDragView, mDragInfo);
399 }
400 } else {
401 if (mLastDropTarget != null) {
402 mLastDropTarget.onDragExit(mDragSource, coordinates[0], coordinates[1],
403 (int) mTouchOffsetX, (int) mTouchOffsetY, mDragView, mDragInfo);
404 }
405 }
406 mLastDropTarget = dropTarget;
407
408 // Scroll, maybe, but not if we're in the delete region.
409 boolean inDeleteRegion = false;
410 if (mDeleteRegion != null) {
Joe Onoratoe048e8a2009-09-25 10:39:17 -0700411 inDeleteRegion = mDeleteRegion.contains(screenX, screenY);
Joe Onorato00acb122009-08-04 16:04:30 -0400412 }
Joe Onoratoe048e8a2009-09-25 10:39:17 -0700413 if (!inDeleteRegion && screenX < SCROLL_ZONE) {
Joe Onorato00acb122009-08-04 16:04:30 -0400414 if (mScrollState == SCROLL_OUTSIDE_ZONE) {
415 mScrollState = SCROLL_WAITING_IN_ZONE;
416 mScrollRunnable.setDirection(SCROLL_LEFT);
417 mHandler.postDelayed(mScrollRunnable, SCROLL_DELAY);
418 }
Joe Onoratoe048e8a2009-09-25 10:39:17 -0700419 } else if (!inDeleteRegion && screenX > scrollView.getWidth() - SCROLL_ZONE) {
Joe Onorato00acb122009-08-04 16:04:30 -0400420 if (mScrollState == SCROLL_OUTSIDE_ZONE) {
421 mScrollState = SCROLL_WAITING_IN_ZONE;
422 mScrollRunnable.setDirection(SCROLL_RIGHT);
423 mHandler.postDelayed(mScrollRunnable, SCROLL_DELAY);
424 }
425 } else {
426 if (mScrollState == SCROLL_WAITING_IN_ZONE) {
427 mScrollState = SCROLL_OUTSIDE_ZONE;
428 mScrollRunnable.setDirection(SCROLL_RIGHT);
429 mHandler.removeCallbacks(mScrollRunnable);
430 }
431 }
432
433 break;
434 case MotionEvent.ACTION_UP:
435 mHandler.removeCallbacks(mScrollRunnable);
436 if (mDragging) {
Joe Onoratoe048e8a2009-09-25 10:39:17 -0700437 drop(screenX, screenY);
Joe Onorato00acb122009-08-04 16:04:30 -0400438 }
439 endDrag();
440
441 break;
442 case MotionEvent.ACTION_CANCEL:
Joe Onorato24b6fd82009-11-12 13:47:09 -0800443 cancelDrag();
Joe Onorato00acb122009-08-04 16:04:30 -0400444 }
445
446 return true;
447 }
448
449 private boolean drop(float x, float y) {
450 final int[] coordinates = mCoordinatesTemp;
451 DropTarget dropTarget = findDropTarget((int) x, (int) y, coordinates);
452
453 if (dropTarget != null) {
454 dropTarget.onDragExit(mDragSource, coordinates[0], coordinates[1],
455 (int) mTouchOffsetX, (int) mTouchOffsetY, mDragView, mDragInfo);
456 if (dropTarget.acceptDrop(mDragSource, coordinates[0], coordinates[1],
457 (int) mTouchOffsetX, (int) mTouchOffsetY, mDragView, mDragInfo)) {
458 dropTarget.onDrop(mDragSource, coordinates[0], coordinates[1],
459 (int) mTouchOffsetX, (int) mTouchOffsetY, mDragView, mDragInfo);
460 mDragSource.onDropCompleted((View) dropTarget, true);
461 return true;
462 } else {
463 mDragSource.onDropCompleted((View) dropTarget, false);
464 return true;
465 }
466 }
467 return false;
468 }
469
470 private DropTarget findDropTarget(int x, int y, int[] dropCoordinates) {
471 final Rect r = mRectTemp;
472
473 final ArrayList<DropTarget> dropTargets = mDropTargets;
474 final int count = dropTargets.size();
475 for (int i=count-1; i>=0; i--) {
476 final DropTarget target = dropTargets.get(i);
477 target.getHitRect(r);
478 target.getLocationOnScreen(dropCoordinates);
479 r.offset(dropCoordinates[0] - target.getLeft(), dropCoordinates[1] - target.getTop());
480 if (r.contains(x, y)) {
481 dropCoordinates[0] = x - dropCoordinates[0];
482 dropCoordinates[1] = y - dropCoordinates[1];
483 return target;
484 }
485 }
486 return null;
487 }
488
Joe Onoratoe048e8a2009-09-25 10:39:17 -0700489 /**
490 * Get the screen size so we can clamp events to the screen size so even if
491 * you drag off the edge of the screen, we find something.
492 */
493 private void recordScreenSize() {
494 ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE))
495 .getDefaultDisplay().getMetrics(mDisplayMetrics);
496 }
497
498 /**
499 * Clamp val to be &gt;= min and &lt; max.
500 */
501 private static int clamp(int val, int min, int max) {
502 if (val < min) {
503 return min;
504 } else if (val >= max) {
505 return max - 1;
506 } else {
507 return val;
508 }
509 }
510
Joe Onorato00acb122009-08-04 16:04:30 -0400511 public void setDragScoller(DragScroller scroller) {
512 mDragScroller = scroller;
513 }
514
515 public void setWindowToken(IBinder token) {
516 mWindowToken = token;
517 }
518
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800519 /**
520 * Sets the drag listner which will be notified when a drag starts or ends.
521 */
Joe Onorato00acb122009-08-04 16:04:30 -0400522 public void setDragListener(DragListener l) {
523 mListener = l;
524 }
525
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800526 /**
527 * Remove a previously installed drag listener.
528 */
Joe Onorato00acb122009-08-04 16:04:30 -0400529 public void removeDragListener(DragListener l) {
530 mListener = null;
531 }
532
533 /**
534 * Add a DropTarget to the list of potential places to receive drop events.
535 */
536 public void addDropTarget(DropTarget target) {
537 mDropTargets.add(target);
538 }
539
540 /**
541 * Don't send drop events to <em>target</em> any more.
542 */
543 public void removeDropTarget(DropTarget target) {
544 mDropTargets.remove(target);
545 }
546
547 /**
548 * Set which view scrolls for touch events near the edge of the screen.
549 */
550 public void setScrollView(View v) {
551 mScrollView = v;
552 }
553
554 /**
555 * Specifies the delete region. We won't scroll on touch events over the delete region.
556 *
557 * @param region The rectangle in screen coordinates of the delete region.
558 */
559 void setDeleteRegion(RectF region) {
560 mDeleteRegion = region;
561 }
562
563 private class ScrollRunnable implements Runnable {
564 private int mDirection;
565
566 ScrollRunnable() {
567 }
568
569 public void run() {
570 if (mDragScroller != null) {
571 if (mDirection == SCROLL_LEFT) {
572 mDragScroller.scrollLeft();
573 } else {
574 mDragScroller.scrollRight();
575 }
576 mScrollState = SCROLL_OUTSIDE_ZONE;
577 }
578 }
579
580 void setDirection(int direction) {
581 mDirection = direction;
582 }
583 }
The Android Open Source Project31dd5032009-03-03 19:32:27 -0800584}