From a27d98a682cf982c6b6d465e54d735ab36facf63 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 13 Oct 2020 09:56:12 +0200 Subject: [PATCH] Scroll item to top on swipe/ask --- app/src/main/java/eu/faircode/email/FragmentMessages.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index fb3e168cbb..7d1cb8c1a2 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -2092,7 +2092,12 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences. } private void onSwipeAsk(final @NonNull TupleMessageEx message, @NonNull RecyclerView.ViewHolder viewHolder) { - PopupMenuLifecycle popupMenu = new PopupMenuLifecycle(getContext(), getViewLifecycleOwner(), viewHolder.itemView); + LinearLayoutManager llm = (LinearLayoutManager) rvMessage.getLayoutManager(); + int pos = viewHolder.getAdapterPosition(); + if (pos != NO_POSITION) + llm.scrollToPositionWithOffset(pos, 0); + + PopupMenuLifecycle popupMenu = new PopupMenuLifecycle(getContext(), getViewLifecycleOwner(), vwAnchor); if (message.ui_seen) popupMenu.getMenu().add(Menu.NONE, R.string.title_unseen, 1, R.string.title_unseen);