From f1b57c9e25197ea2098aa814ea6087f0399f41c3 Mon Sep 17 00:00:00 2001 From: Steven Luo Date: Sun, 29 May 2011 17:49:42 -0700 Subject: [PATCH] Don't scroll to a conversation in onCreate() unless it was previously selected This has two advantages: (1) The activity remembers which conversation was last selected if it's destroyed (e.g. via the Back button) and then recreated with the connection still running. (2) It prevents onCreate() from clearing all the mentioned notifications for the conversations in that activity. --- .../org/yaaic/activity/ConversationActivity.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/application/src/org/yaaic/activity/ConversationActivity.java b/application/src/org/yaaic/activity/ConversationActivity.java index c72a871..ecfa693 100644 --- a/application/src/org/yaaic/activity/ConversationActivity.java +++ b/application/src/org/yaaic/activity/ConversationActivity.java @@ -166,7 +166,12 @@ public class ConversationActivity extends Activity implements ServiceConnection, Collection mConversations = server.getConversations(); for (Conversation conversation : mConversations) { - onNewConversation(conversation.getName()); + // Only scroll to new conversation if it was selected before + if (conversation.getStatus() == Conversation.STATUS_SELECTED) { + onNewConversation(conversation.getName()); + } else { + createNewConversation(conversation.getName()); + } } // keep compatibility with api level 3 @@ -430,13 +435,17 @@ public class ConversationActivity extends Activity implements ServiceConnection, @Override public void onNewConversation(String target) { - deckAdapter.addItem(server.getConversation(target)); + createNewConversation(target); if (!deckAdapter.isSwitched()) { // Scroll to new conversation deck.setSelection(deckAdapter.getCount() - 1); } } + public void createNewConversation(String target) + { + deckAdapter.addItem(server.getConversation(target)); + } /** * On conversation remove