Skip to content

Commit

Permalink
bug #3319036: fix one of the (severe) SMS bugs where the wrong conver…
Browse files Browse the repository at this point in the history
…sation is opened.

- the code in ConversationList.onListItemClicked() was extracting the conversation data
from the ConversationListItem view passed in. However, ListItem views can be recycled
when rebound, so the view we got could now be reassigned to a different list position
and contain different data.

Intead of depend on ConversationListItem to store the conversation data, always load
the cursor at the position clicked, and get the conversation data from the cursor.

Merge from gingerbread

Conflicts:

	src/com/android/mms/ui/ConversationList.java

Change-Id: I276a2ffc48fb51a99c87584d7604f188aec1cb98
  • Loading branch information
Tom Taylor authored and hyperb1iss committed Jan 22, 2011
1 parent a26034c commit d5d2219
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/com/android/mms/ui/ConversationList.java
Expand Up @@ -348,10 +348,23 @@ protected void onListItemClick(ListView l, View v, int position, long id) {

if (position == 0) {
createNewMessage();
} else if (v instanceof ConversationListItem) {
ConversationListItem headerView = (ConversationListItem) v;
ConversationListItemData ch = headerView.getConversationHeader();
openThread(ch.getThreadId());
} else {
// Note: don't read the thread id data from the ConversationListItem view passed in.
// It's unreliable to read the cached data stored in the view because the ListItem
// can be recycled, and the same view could be assigned to a different position
// if you click the list item fast enough. Instead, get the cursor at the position
// clicked and load the data from the cursor.
// (ConversationListAdapter extends CursorAdapter, so getItemAtPosition() should
// return the cursor object, which is moved to the position passed in)
Cursor cursor = (Cursor) getListView().getItemAtPosition(position);
Conversation conv = Conversation.from(this, cursor);
long tid = conv.getThreadId();

if (LOCAL_LOGV) {
Log.v(TAG, "onListItemClick: pos=" + position + ", view=" + v + ", tid=" + tid);
}

openThread(tid);
}
}

Expand Down

0 comments on commit d5d2219

Please sign in to comment.