diff options
author | BrianBlade <n.gelbertz@gmail.com> | 2015-04-06 11:37:07 +0200 |
---|---|---|
committer | BrianBlade <n.gelbertz@gmail.com> | 2015-04-06 19:17:20 +0200 |
commit | 5c5ff5cc7aa9c139865e2d319a7e23385d4d171a (patch) | |
tree | 20530195193f9f8e996e5294ef7d12b03a8f1d6b | |
parent | 5d3b884cdb8ea72303e1bf7b03afe6fb9fc4dc70 (diff) |
Fix discardUndo(); re-init selectedConversation
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/ConversationActivity.java | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java index 69e90cc1..82939355 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java @@ -115,7 +115,6 @@ public class ConversationActivity extends XmppActivity public void hideConversationsOverview() { if (mContentView instanceof SlidingPaneLayout) { - listView.discardUndo(); SlidingPaneLayout mSlidingPaneLayout = (SlidingPaneLayout) mContentView; mSlidingPaneLayout.closePane(); } @@ -185,26 +184,35 @@ public class ConversationActivity extends XmppActivity @Override public EnhancedListView.Undoable onDismiss(EnhancedListView enhancedListView, final int position) { + + boolean formerlySelected; swipedConversation = listAdapter.getItem(position); listAdapter.remove(swipedConversation); - listAdapter.notifyDataSetChanged(); swipedConversation.markRead(); if (position == 0 && listAdapter.getCount() == 0) { endConversation(swipedConversation, false, true); return null; - } - else if (getSelectedConversation() == swipedConversation) { + } else if (getSelectedConversation() == swipedConversation) { + formerlySelected = true; setSelectedConversation(listAdapter.getItem(0)); ConversationActivity.this.mConversationFragment .reInit(getSelectedConversation()); + } else { + formerlySelected = false; } + final boolean wasSelected = formerlySelected; return new EnhancedListView.Undoable() { + @Override public void undo() { listAdapter.insert(swipedConversation, position); - listAdapter.notifyDataSetChanged(); + if (wasSelected) { + setSelectedConversation(swipedConversation); + ConversationActivity.this.mConversationFragment + .reInit(getSelectedConversation()); + } swipedConversation = null; } @@ -262,6 +270,7 @@ public class ConversationActivity extends XmppActivity @Override public void onPanelClosed(View arg0) { + listView.discardUndo(); openConversation(); } |