From b06152ba58a0364c28e34f2a6f3636fc668061e6 Mon Sep 17 00:00:00 2001 From: Alex Hart Date: Mon, 2 Mar 2020 08:55:53 -0400 Subject: [PATCH] Fix and simplify Y translation calculation for Conversation. --- .../securesms/conversation/ConversationFragment.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) 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 333281f698..5b09be243f 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationFragment.java +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationFragment.java @@ -236,20 +236,14 @@ public class ConversationFragment extends Fragment } private void setListVerticalTranslation() { - int heightOfChildren = 0; - for (int i = 0; i < list.getChildCount(); i++) { - heightOfChildren += list.getChildAt(i).getMeasuredHeight(); - } - - Log.i(TAG, "Height of children: " + heightOfChildren + " my height: " + list.getMeasuredHeight()); - if (heightOfChildren > list.getMeasuredHeight()) { + if (list.canScrollVertically(1) || list.canScrollVertically(-1) || list.getChildCount() == 0) { list.setTranslationY(0); list.setOverScrollMode(RecyclerView.OVER_SCROLL_IF_CONTENT_SCROLLS); } else { - list.setTranslationY(heightOfChildren - list.getMeasuredHeight()); + int chTop = list.getChildAt(list.getChildCount() - 1).getTop(); + list.setTranslationY(Math.min(0, -chTop)); list.setOverScrollMode(RecyclerView.OVER_SCROLL_NEVER); } - listener.onListVerticalTranslationChanged(list.getTranslationY()); }