diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 026021e3f..747e2f48c 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -226,7 +226,7 @@ public class ConversationFragment extends XmppFragment @ColorInt private int primaryColor = -1; - private LinkedList replyJumps = new LinkedList<>(); + private Message previousClickedReply = null; private ActionMode selectionActionMode; private final OnClickListener clickToMuc = @@ -590,19 +590,16 @@ public class ConversationFragment extends XmppFragment public void onClick(View v) { stopScrolling(); - if (!replyJumps.isEmpty()) { + if (previousClickedReply != null) { int lastVisiblePosition = binding.messagesView.getLastVisiblePosition(); Message lastVisibleMessage = messageListAdapter.getItem(lastVisiblePosition); - if (lastVisibleMessage == null) { - replyJumps.clear(); - } else { - while (!replyJumps.isEmpty()) { - Message jump = replyJumps.pop(); - if (jump.getMergedTimeSent() > lastVisibleMessage.getMergedTimeSent()) { - Runnable postSelectionRunnable = () -> highlightMessage(jump.getUuid()); - updateSelection(jump.getUuid(), binding.messagesView.getHeight() / 2, postSelectionRunnable, false, false); - return; - } + Message jump = previousClickedReply; + previousClickedReply = null; + if (lastVisibleMessage != null) { + if (jump.getMergedTimeSent() > lastVisibleMessage.getMergedTimeSent()) { + Runnable postSelectionRunnable = () -> highlightMessage(jump.getUuid()); + updateSelection(jump.getUuid(), binding.messagesView.getHeight() / 2, postSelectionRunnable, false, false); + return; } } } @@ -1592,7 +1589,7 @@ public class ConversationFragment extends XmppFragment if (replyId != null) { Runnable postSelectionRunnable = () -> highlightMessage(replyId); - replyJumps.push(message); + previousClickedReply = message; updateSelection(replyId, binding.messagesView.getHeight() / 2, postSelectionRunnable, true, false); } } @@ -3075,7 +3072,7 @@ public class ConversationFragment extends XmppFragment refreshCommands(); } - replyJumps.clear(); + previousClickedReply = null; return true; } @@ -3128,7 +3125,7 @@ public class ConversationFragment extends XmppFragment } this.binding.scrollToBottomButton.setEnabled(false); this.binding.scrollToBottomButton.hide(); - replyJumps.clear(); + previousClickedReply = null; this.binding.unreadCountCustomView.setVisibility(View.GONE); }