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 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/application/src/org/yaaic/activity/ConversationActivity.java
b/application/src/org/yaaic/activity/ConversationActivity.java
index 47dd2e7..55adced 100644
--- a/application/src/org/yaaic/activity/ConversationActivity.java
+++ b/application/src/org/yaaic/activity/ConversationActivity.java
@@ -167,7 +167,12 @@ public class ConversationActivity extends Activity
implements ServiceConnection,
Collection<Conversation> 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
@@ -443,13 +448,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
--
1.7.2.5