From 23af9183ba386f51d912bfdab782e8151936a5e8 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 25 Jun 2018 20:04:30 +0200 Subject: [PATCH] dismiss snackbar when executing pending action --- .../ui/ConversationsOverviewFragment.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationsOverviewFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationsOverviewFragment.java index f9b761fc6..3c89103c3 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationsOverviewFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationsOverviewFragment.java @@ -136,15 +136,6 @@ public class ConversationsOverviewFragment extends XmppFragment { boolean isMuc = swipedConversation.peek().getMode() == Conversation.MODE_MULTI; int title = isMuc ? R.string.title_undo_swipe_out_muc : R.string.title_undo_swipe_out_conversation; - pendingActionHelper.push(() -> { - Conversation c = swipedConversation.pop(); - if(c != null){ - if (!c.isRead() && c.getMode() == Conversation.MODE_SINGLE) { - return; - } - activity.xmppConnectionService.archiveConversation(c); - } - }); final Snackbar snackbar = Snackbar.make(binding.list, title, 5000) .setAction(R.string.undo, v -> { pendingActionHelper.undo(); @@ -171,6 +162,20 @@ public class ConversationsOverviewFragment extends XmppFragment { } } }); + + pendingActionHelper.push(() -> { + if (snackbar.isShownOrQueued()) { + snackbar.dismiss(); + } + Conversation c = swipedConversation.pop(); + if(c != null){ + if (!c.isRead() && c.getMode() == Conversation.MODE_SINGLE) { + return; + } + activity.xmppConnectionService.archiveConversation(c); + } + }); + ThemeHelper.fix(snackbar); snackbar.show(); }