From 0fbc6ac15165471a16a660976d9caa31daa77fc7 Mon Sep 17 00:00:00 2001 From: Cody Henthorne Date: Wed, 17 Jun 2020 15:50:29 -0400 Subject: [PATCH] Revert improperly removed code for Message Request footer. --- .../conversation/ConversationFragment.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationFragment.java b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationFragment.java index 11060918f2..ff7b2370bf 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationFragment.java +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationFragment.java @@ -212,6 +212,8 @@ public class ConversationFragment extends Fragment { this::handleReplyMessage ).attachToRecyclerView(list); + setupListLayoutListeners(); + this.conversationViewModel = ViewModelProviders.of(requireActivity(), new ConversationViewModel.Factory()).get(ConversationViewModel.class); conversationViewModel.getMessages().observe(this, list -> { if (getListAdapter() != null && !list.getDataSource().isInvalid()) { @@ -226,6 +228,22 @@ public class ConversationFragment extends Fragment { return view; } + private void setupListLayoutListeners() { + list.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> setListVerticalTranslation()); + + list.addOnChildAttachStateChangeListener(new RecyclerView.OnChildAttachStateChangeListener() { + @Override + public void onChildViewAttachedToWindow(@NonNull View view) { + setListVerticalTranslation(); + } + + @Override + public void onChildViewDetachedFromWindow(@NonNull View view) { + setListVerticalTranslation(); + } + }); + } + private void setListVerticalTranslation() { if (list.canScrollVertically(1) || list.canScrollVertically(-1) || list.getChildCount() == 0) { list.setTranslationY(0);