Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

bug #3319036: fix one of the (severe) SMS bugs where the wrong conver…

…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...
commit d5d22194f33c47f61ffef62678d308a1fa3d4a0e 1 parent a26034c
authored January 05, 2011 cyanogen committed January 21, 2011
21  src/com/android/mms/ui/ConversationList.java
@@ -348,10 +348,23 @@ protected void onListItemClick(ListView l, View v, int position, long id) {
348 348
 
349 349
         if (position == 0) {
350 350
             createNewMessage();
351  
-        } else if (v instanceof ConversationListItem) {
352  
-            ConversationListItem headerView = (ConversationListItem) v;
353  
-            ConversationListItemData ch = headerView.getConversationHeader();
354  
-            openThread(ch.getThreadId());
  351
+        } else {
  352
+            // Note: don't read the thread id data from the ConversationListItem view passed in.
  353
+            // It's unreliable to read the cached data stored in the view because the ListItem
  354
+            // can be recycled, and the same view could be assigned to a different position
  355
+            // if you click the list item fast enough. Instead, get the cursor at the position
  356
+            // clicked and load the data from the cursor.
  357
+            // (ConversationListAdapter extends CursorAdapter, so getItemAtPosition() should
  358
+            // return the cursor object, which is moved to the position passed in)
  359
+            Cursor cursor  = (Cursor) getListView().getItemAtPosition(position);
  360
+            Conversation conv = Conversation.from(this, cursor);
  361
+            long tid = conv.getThreadId();
  362
+
  363
+            if (LOCAL_LOGV) {
  364
+                Log.v(TAG, "onListItemClick: pos=" + position + ", view=" + v + ", tid=" + tid);
  365
+            }
  366
+
  367
+            openThread(tid);
355 368
         }
356 369
     }
357 370
 

0 notes on commit d5d2219

Please sign in to comment.
Something went wrong with that request. Please try again.