From f84369bc19313d351049696a47ef02112af86866 Mon Sep 17 00:00:00 2001 From: Steven Luo Date: Tue, 16 Aug 2011 02:11:04 -0700 Subject: [PATCH] Add new conversations to DeckAdapter in onResume() Currently, when the user opens a ConversationActivity, goes off to do something else without closing it, and then comes back to the activity, conversations started since the ConversationActivity was paused (e.g. by an incoming private message) will not appear in the ConversationGallery; this is because we never check for new conversations in the onResume() path. Fortunately, this is an easy fix: we're already looping over all the conversations in onResume() in order to add new messages to the MessageListViews, so just look out for the new conversations and add them to the ConversationGallery when we see them. --- .../src/org/yaaic/activity/ConversationActivity.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/application/src/org/yaaic/activity/ConversationActivity.java b/application/src/org/yaaic/activity/ConversationActivity.java index b72f456..86e07eb 100644 --- a/application/src/org/yaaic/activity/ConversationActivity.java +++ b/application/src/org/yaaic/activity/ConversationActivity.java @@ -312,11 +312,17 @@ public class ConversationActivity extends Activity implements ServiceConnection, // Fill view with messages that have been buffered while paused for (Conversation conversation : mConversations) { - mAdapter = deckAdapter.getItemAdapter(conversation.getName()); + String name = conversation.getName(); + mAdapter = deckAdapter.getItemAdapter(name); if (mAdapter != null) { mAdapter.addBulkMessages(conversation.getBuffer()); conversation.clearBuffer(); + } else { + // Was conversation created while we were paused? + if (deckAdapter.getPositionByName(name) == -1) { + onNewConversation(name); + } } // Clear new message notifications for the selected conversation @@ -324,7 +330,7 @@ public class ConversationActivity extends Activity implements ServiceConnection, Intent ackIntent = new Intent(this, IRCService.class); ackIntent.setAction(IRCService.ACTION_ACK_NEW_MENTIONS); ackIntent.putExtra(IRCService.EXTRA_ACK_SERVERID, serverId); - ackIntent.putExtra(IRCService.EXTRA_ACK_CONVTITLE, conversation.getName()); + ackIntent.putExtra(IRCService.EXTRA_ACK_CONVTITLE, name); startService(ackIntent); } }