From 5c5ff5cc7aa9c139865e2d319a7e23385d4d171a Mon Sep 17 00:00:00 2001 From: BrianBlade Date: Mon, 6 Apr 2015 11:37:07 +0200 Subject: Fix discardUndo(); re-init selectedConversation --- .../siacs/conversations/ui/ConversationActivity.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/main/java/eu') 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(); } -- cgit v1.2.3