mirror of
https://github.com/moparisthebest/Yaaic
synced 2024-11-29 12:22:21 -05:00
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.
This commit is contained in:
parent
3102340762
commit
f1b57c9e25
@ -166,7 +166,12 @@ public class ConversationActivity extends Activity implements ServiceConnection,
|
|||||||
Collection<Conversation> mConversations = server.getConversations();
|
Collection<Conversation> mConversations = server.getConversations();
|
||||||
|
|
||||||
for (Conversation conversation : mConversations) {
|
for (Conversation conversation : mConversations) {
|
||||||
|
// Only scroll to new conversation if it was selected before
|
||||||
|
if (conversation.getStatus() == Conversation.STATUS_SELECTED) {
|
||||||
onNewConversation(conversation.getName());
|
onNewConversation(conversation.getName());
|
||||||
|
} else {
|
||||||
|
createNewConversation(conversation.getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// keep compatibility with api level 3
|
// keep compatibility with api level 3
|
||||||
@ -430,13 +435,17 @@ public class ConversationActivity extends Activity implements ServiceConnection,
|
|||||||
@Override
|
@Override
|
||||||
public void onNewConversation(String target)
|
public void onNewConversation(String target)
|
||||||
{
|
{
|
||||||
deckAdapter.addItem(server.getConversation(target));
|
createNewConversation(target);
|
||||||
|
|
||||||
if (!deckAdapter.isSwitched()) {
|
if (!deckAdapter.isSwitched()) {
|
||||||
// Scroll to new conversation
|
// Scroll to new conversation
|
||||||
deck.setSelection(deckAdapter.getCount() - 1);
|
deck.setSelection(deckAdapter.getCount() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void createNewConversation(String target)
|
||||||
|
{
|
||||||
|
deckAdapter.addItem(server.getConversation(target));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On conversation remove
|
* On conversation remove
|
||||||
|
Loading…
Reference in New Issue
Block a user