From 15a389c171e424fd03ea1b0c76f0071482c96393 Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Wed, 25 Jan 2017 18:00:26 -0800 Subject: [PATCH] Don't calculate date header item for adapter header Fixes #6098 // FREEBIE --- res/layout/conversation_fragment.xml | 14 +++++++------- .../securesms/ConversationAdapter.java | 5 ++++- .../securesms/ConversationFragment.java | 4 +++- .../database/CursorRecyclerViewAdapter.java | 4 ++-- .../securesms/util/StickyHeaderDecoration.java | 13 +++++++++---- 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/res/layout/conversation_fragment.xml b/res/layout/conversation_fragment.xml index 5797b6e87f..68e2f6f040 100644 --- a/res/layout/conversation_fragment.xml +++ b/res/layout/conversation_fragment.xml @@ -6,6 +6,13 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"> + + - - @Override public long getHeaderId(int position) { - if (!isActiveCursor()) return -1; + if (!isActiveCursor()) return -1; + if (isHeaderPosition(position)) return -1; + if (isFooterPosition(position)) return -1; + if (position >= getItemCount()) return -1; Cursor cursor = getCursorAtPositionOrThrow(position); MessageRecord record = getMessageRecord(cursor); diff --git a/src/org/thoughtcrime/securesms/ConversationFragment.java b/src/org/thoughtcrime/securesms/ConversationFragment.java index 8cf9df1f9e..e840a4bc68 100644 --- a/src/org/thoughtcrime/securesms/ConversationFragment.java +++ b/src/org/thoughtcrime/securesms/ConversationFragment.java @@ -488,7 +488,9 @@ public class ConversationFragment extends Fragment } private void bindScrollHeader(HeaderViewHolder headerViewHolder, int positionId) { - ((ConversationAdapter)list.getAdapter()).onBindHeaderViewHolder(headerViewHolder, positionId); + if (((ConversationAdapter)list.getAdapter()).getHeaderId(positionId) != -1) { + ((ConversationAdapter) list.getAdapter()).onBindHeaderViewHolder(headerViewHolder, positionId); + } } } diff --git a/src/org/thoughtcrime/securesms/database/CursorRecyclerViewAdapter.java b/src/org/thoughtcrime/securesms/database/CursorRecyclerViewAdapter.java index 93bcc6f7f0..fdbcf2824f 100644 --- a/src/org/thoughtcrime/securesms/database/CursorRecyclerViewAdapter.java +++ b/src/org/thoughtcrime/securesms/database/CursorRecyclerViewAdapter.java @@ -187,11 +187,11 @@ public abstract class CursorRecyclerViewAdapter