mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
Don't calculate date header item for adapter header
Fixes #6098 // FREEBIE
This commit is contained in:
parent
d46d3b72c8
commit
15a389c171
@ -6,6 +6,13 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@android:id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scrollbars="vertical"
|
||||
android:cacheColorHint="?conversation_background" />
|
||||
|
||||
<TextView android:id="@+id/scroll_date_header"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@ -22,13 +29,6 @@
|
||||
android:visibility="gone"
|
||||
tools:text="March 1, 2015" />
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@android:id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scrollbars="vertical"
|
||||
android:cacheColorHint="?conversation_background" />
|
||||
|
||||
<View android:id="@+id/compose_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2dp"
|
||||
|
@ -289,6 +289,9 @@ public class ConversationAdapter <V extends View & BindableConversationItem>
|
||||
@Override
|
||||
public long getHeaderId(int position) {
|
||||
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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,11 +187,11 @@ public abstract class CursorRecyclerViewAdapter<VH extends RecyclerView.ViewHold
|
||||
return valid && cursor != null;
|
||||
}
|
||||
|
||||
private boolean isFooterPosition(int position) {
|
||||
protected boolean isFooterPosition(int position) {
|
||||
return hasFooterView() && position == getItemCount() - 1;
|
||||
}
|
||||
|
||||
private boolean isHeaderPosition(int position) {
|
||||
protected boolean isHeaderPosition(int position) {
|
||||
return hasHeaderView() && position == 0;
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ import android.support.v4.view.ViewCompat;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.RecyclerView.ViewHolder;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
@ -58,15 +59,19 @@ public class StickyHeaderDecoration extends RecyclerView.ItemDecoration {
|
||||
|
||||
private boolean hasHeader(RecyclerView parent, StickyHeaderAdapter adapter, int adapterPos) {
|
||||
boolean isReverse = isReverseLayout(parent);
|
||||
int itemCount = ((RecyclerView.Adapter)adapter).getItemCount();
|
||||
|
||||
if (isReverse && adapterPos == ((RecyclerView.Adapter)adapter).getItemCount() - 1 || !isReverse && adapterPos == 0) {
|
||||
if ((isReverse && adapterPos == itemCount - 1 && adapter.getHeaderId(adapterPos) != -1) ||
|
||||
(!isReverse && adapterPos == 0))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int previous = adapterPos + (isReverse ? 1 : -1);
|
||||
long headerId = adapter.getHeaderId(adapterPos);
|
||||
long previousHeaderId = adapter.getHeaderId(previous);
|
||||
|
||||
return headerId != NO_HEADER_ID && (headerId != adapter.getHeaderId(previous));
|
||||
return headerId != NO_HEADER_ID && previousHeaderId != NO_HEADER_ID && headerId != previousHeaderId;
|
||||
}
|
||||
|
||||
private ViewHolder getHeader(RecyclerView parent, StickyHeaderAdapter adapter, int position) {
|
||||
|
Loading…
Reference in New Issue
Block a user