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