summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHongwei Wang <hwwang@google.com>2013-09-18 17:14:44 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-09-18 17:14:44 +0000
commiteaebb31a53f1f44251009477e090813cb569f789 (patch)
treec9da36589325429e05c826a1936cfccd54a7017c
parentf59250951cf47d81fda125e9bab324d66ed75214 (diff)
parent774206bc2d92d542a2a064e0a0b1718418d3044f (diff)
Merge "Fixed the coordinates translation" into klp-dev
-rw-r--r--src/com/android/dialer/list/PhoneFavoritesTileAdapter.java16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
index 73d3c36ff..2e18118e1 100644
--- a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
+++ b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
@@ -21,7 +21,6 @@ import android.content.ContentValues;
import android.content.Context;
import android.content.res.Resources;
import android.database.Cursor;
-import android.graphics.Rect;
import android.net.Uri;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.Contacts;
@@ -930,18 +929,21 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements
*/
public int getItemIndex(float itemX, float itemY) {
if (mPosition < mMaxTiledRows) {
- final Rect childRect = new Rect();
if (DEBUG) {
Log.v(TAG, String.valueOf(itemX) + " " + String.valueOf(itemY));
}
for (int i = 0; i < getChildCount(); ++i) {
/** If the row contains multiple tiles, checks each tile to see if the point
* is contained in the tile. */
- getChildAt(i).getHitRect(childRect);
- if (DEBUG) {
- Log.v(TAG, childRect.toString());
- }
- if (childRect.contains((int)itemX, (int)itemY)) {
+ final View child = getChildAt(i);
+ /** The coordinates passed in are based on the ListView,
+ * translate for each child first */
+ final int xInListView = child.getLeft() + getLeft();
+ final int yInListView = child.getTop() + getTop();
+ final int distanceX = (int) itemX - xInListView;
+ final int distanceY = (int) itemY - yInListView;
+ if ((distanceX > 0 && distanceX < child.getWidth()) &&
+ (distanceY > 0 && distanceY < child.getHeight())) {
/** If the point is contained in the rectangle, computes the index of the
* item in the cached array. */
return i + (mPosition) * mColumnCount;