Bring positions back into photo setTag() for FT launching.
Earlier change had switched setTag() to store Photos._ID
values instead of list positions. This broke FastTrack
launching from lists.
This change adds a container class so both values happily
live in the same tag. Fixes http://b/2114632
diff --git a/src/com/android/contacts/ContactsListActivity.java b/src/com/android/contacts/ContactsListActivity.java
index 7d76531..a0a2258 100644
--- a/src/com/android/contacts/ContactsListActivity.java
+++ b/src/com/android/contacts/ContactsListActivity.java
@@ -570,9 +570,7 @@
private int[] mLocation = new int[2];
private Rect mRect = new Rect();
- private void showFastTrack(View anchor, long contactId) {
- final Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
-
+ private void showFastTrack(View anchor, Uri contactUri) {
anchor.getLocationInWindow(mLocation);
mRect.left = mLocation[0];
mRect.top = mLocation[1];
@@ -584,11 +582,11 @@
}
/** {@inheritDoc} */
- public void onClick(View v) {
+ public void onClick(View view) {
// Clicked on photo, so show fast-track
- final int position = (Integer)v.getTag();
- final long contactId = this.getListView().getItemIdAtPosition(position);
- showFastTrack(v, contactId);
+ final PhotoInfo info = (PhotoInfo)view.getTag();
+ final Uri contactUri = getContactUri(info.position);
+ showFastTrack(view, contactUri);
}
private void setEmptyText() {
@@ -1802,6 +1800,16 @@
public ImageView photoView;
}
+ final static class PhotoInfo {
+ public int position;
+ public long photoId;
+
+ public PhotoInfo(int position, long photoId) {
+ this.position = position;
+ this.photoId = photoId;
+ }
+ }
+
private final class ContactItemListAdapter extends ResourceCursorAdapter
implements SectionIndexer, OnScrollListener {
private SectionIndexer mIndexer;
@@ -1880,8 +1888,9 @@
}
switch(message.what) {
case FETCH_IMAGE_MSG: {
- ImageView imageView = (ImageView) message.obj;
- long photoId = (Long) imageView.getTag();
+ final ImageView imageView = (ImageView) message.obj;
+ final PhotoInfo info = (PhotoInfo)imageView.getTag();
+ final long photoId = info.photoId;
if (photoId == 0) {
break;
}
@@ -1902,7 +1911,8 @@
// Make sure the photoId on this image view has not changed
// while we were loading the image.
synchronized (imageView) {
- long currentPhotoId = (Long) imageView.getTag();
+ final PhotoInfo updatedInfo = (PhotoInfo)imageView.getTag();
+ long currentPhotoId = updatedInfo.photoId;
if (currentPhotoId == photoId) {
imageView.setImageBitmap(photo);
mItemsMissingImages.remove(imageView);
@@ -2117,7 +2127,8 @@
photoId = cursor.getLong(SUMMARY_PHOTO_ID_COLUMN_INDEX);
}
- cache.photoView.setTag(photoId);
+ final int position = cursor.getPosition();
+ cache.photoView.setTag(new PhotoInfo(position, photoId));
if (photoId == 0) {
cache.photoView.setImageResource(R.drawable.ic_contact_list_picture);
diff --git a/src/com/android/contacts/ui/FastTrackWindow.java b/src/com/android/contacts/ui/FastTrackWindow.java
index 01164f8..fd5036d 100644
--- a/src/com/android/contacts/ui/FastTrackWindow.java
+++ b/src/com/android/contacts/ui/FastTrackWindow.java
@@ -238,7 +238,7 @@
* Start showing a fast-track window for the given {@link Contacts#_ID}
* pointing towards the given location.
*/
- public void show(Uri aggUri, Rect anchor, int mode, String[] excludeMimes) {
+ public void show(Uri contactUri, Rect anchor, int mode, String[] excludeMimes) {
if (mShowing || mQuerying) {
Log.w(TAG, "already in process of showing");
return;
@@ -256,16 +256,13 @@
mHasValidSocial = false;
- mAggId = ContentUris.parseId(aggUri);
+ mAggId = ContentUris.parseId(contactUri);
mAnchor = new Rect(anchor);
mQuerying = true;
- Uri aggSummary = ContentUris.withAppendedId(
- ContactsContract.Contacts.CONTENT_URI, mAggId);
- Uri aggSocial = ContentUris.withAppendedId(
- SocialContract.Activities.CONTENT_CONTACT_STATUS_URI, mAggId);
- Uri aggData = Uri.withAppendedPath(aggUri,
- ContactsContract.Contacts.Data.CONTENT_DIRECTORY);
+ Uri aggSummary = ContentUris.withAppendedId(Contacts.CONTENT_URI, mAggId);
+ Uri aggSocial = ContentUris.withAppendedId(Activities.CONTENT_CONTACT_STATUS_URI, mAggId);
+ Uri aggData = Uri.withAppendedPath(aggSummary, Contacts.Data.CONTENT_DIRECTORY);
// Start data query in background
mHandler = new NotifyingAsyncQueryHandler(mContext, this);