summaryrefslogtreecommitdiff
path: root/src/com/android
diff options
context:
space:
mode:
authorChristine Chen <christinech@google.com>2013-07-31 18:01:29 -0700
committerChristine Chen <christinech@google.com>2013-07-31 18:32:16 -0700
commit1a94e74284791cd9af52ff1717766de9e9515d54 (patch)
tree384c1af42e2e244f9bb011440f1d5d5cc311b7ac /src/com/android
parent6b7bbff7aaae1e51d57c255c21a0ef1c4faf7655 (diff)
Fix drag and drop lag.
Change-Id: I5d92fa60aca02883ce624ce6f643c5aedd224039
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/dialer/list/PhoneFavoriteDragAndDropListeners.java58
1 files changed, 35 insertions, 23 deletions
diff --git a/src/com/android/dialer/list/PhoneFavoriteDragAndDropListeners.java b/src/com/android/dialer/list/PhoneFavoriteDragAndDropListeners.java
index 846b2a74f..7e86a4742 100644
--- a/src/com/android/dialer/list/PhoneFavoriteDragAndDropListeners.java
+++ b/src/com/android/dialer/list/PhoneFavoriteDragAndDropListeners.java
@@ -16,6 +16,7 @@
package com.android.dialer.list;
import android.content.ClipData;
+import android.graphics.Rect;
import android.util.Log;
import android.view.DragEvent;
import android.view.GestureDetector.SimpleOnGestureListener;
@@ -136,6 +137,37 @@ public class PhoneFavoriteDragAndDropListeners {
// Handles drag events.
switch (event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
+ if (mTileAdapter != null && mContactTileRow != null
+ && !mTileAdapter.getInDragging()) {
+ // Gets the current drag location with respect to the whole Dialer view.
+ mX = event.getX();
+ mY = event.getY();
+ if (DEBUG) {
+ Log.v(TAG, String.valueOf(mX) + "; " + String.valueOf(mY));
+ }
+
+ final int[] rowLocation = new int[2];
+ mContactTileRow.getLocationOnScreen(rowLocation);
+
+ final Rect locationRect = new Rect(rowLocation[0], rowLocation[1],
+ rowLocation[0] + mContactTileRow.getWidth(),
+ rowLocation[1] + mContactTileRow.getHeight());
+
+ if (locationRect.contains((int) mX, (int) mY)) {
+ // Finds out which item is being dragged.
+ // Computes relative coordinates as we get absolute coordinates.
+ final int dragIndex = mContactTileRow.getItemIndex(
+ mX - rowLocation[0], mY - rowLocation[1]);
+ if (DEBUG) {
+ Log.v(TAG, "Start dragging " + String.valueOf(dragIndex));
+ }
+ // Indicates a drag has started.
+ mTileAdapter.setInDragging(true);
+
+ // Temporarily pops out the Contact entry.
+ mTileAdapter.popContactEntry(dragIndex);
+ }
+ }
break;
case DragEvent.ACTION_DRAG_ENTERED:
break;
@@ -145,6 +177,9 @@ public class PhoneFavoriteDragAndDropListeners {
// Gets the location of the drag with respect to the whole Dialer view.
mX = event.getX() + v.getLeft();
mY = event.getY() + v.getTop();
+ if (DEBUG) {
+ Log.v(TAG, String.valueOf(mX) + "; " + String.valueOf(mY));
+ }
// Indicates a drag has finished.
if (mTileAdapter != null && mContactTileRow != null) {
@@ -163,29 +198,6 @@ public class PhoneFavoriteDragAndDropListeners {
case DragEvent.ACTION_DRAG_ENDED:
break;
case DragEvent.ACTION_DRAG_LOCATION:
- // Gets the current drag location with respect to the whole Dialer view.
- mX = event.getX() + v.getLeft();
- mY = event.getY() + v.getTop();
- if (DEBUG) {
- Log.v(TAG, String.valueOf(mX) + "; " + String.valueOf(mY));
- }
-
- if (mTileAdapter != null && mContactTileRow != null) {
- // If there is no drag in process, initializes the drag.
- if (!mTileAdapter.getInDragging()) {
- // Finds out which item is being dragged.
- final int dragIndex = mContactTileRow.getItemIndex(mX, mY);
- if (DEBUG) {
- Log.v(TAG, "Start dragging " + String.valueOf(dragIndex));
- }
-
- // Indicates a drag has started.
- mTileAdapter.setInDragging(true);
-
- // Temporarily pops out the Contact entry.
- mTileAdapter.popContactEntry(dragIndex);
- }
- }
break;
default:
break;