mirror of
https://github.com/oxen-io/session-android.git
synced 2025-05-25 19:08:16 +00:00
Fix crash with conversations with "uknown contact" header.
We weren't accounting for ConversationAdapter header position when getting the next and previous record in a conversation.
This commit is contained in:
parent
6a090bd5f1
commit
a4214300ec
@ -190,10 +190,12 @@ public class ConversationAdapter <V extends View & BindableConversationItem>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onBindItemViewHolder(ViewHolder viewHolder, @NonNull MessageRecord messageRecord, int position) {
|
protected void onBindItemViewHolder(ViewHolder viewHolder, @NonNull MessageRecord messageRecord, int adjustedPosition) {
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
MessageRecord previousRecord = position < getItemCount() - 1 ? getRecordForPositionOrThrow(position + 1) : null;
|
long start = System.currentTimeMillis();
|
||||||
MessageRecord nextRecord = position > 0 ? getRecordForPositionOrThrow(position - 1) : null;
|
int rawPosition = getRawCursorPosition(adjustedPosition);
|
||||||
|
MessageRecord previousRecord = rawPosition < getItemCount() - 1 && !isFooterPosition(rawPosition + 1) ? getRecordForPositionOrThrow(rawPosition + 1) : null;
|
||||||
|
MessageRecord nextRecord = rawPosition > 0 && !isHeaderPosition(rawPosition - 1) ? getRecordForPositionOrThrow(rawPosition - 1) : null;
|
||||||
|
|
||||||
viewHolder.getView().bind(messageRecord,
|
viewHolder.getView().bind(messageRecord,
|
||||||
Optional.fromNullable(previousRecord),
|
Optional.fromNullable(previousRecord),
|
||||||
|
@ -211,6 +211,13 @@ public abstract class CursorRecyclerViewAdapter<VH extends RecyclerView.ViewHold
|
|||||||
return position - getFastAccessSize();
|
return position - getFastAccessSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected int getRawCursorPosition(int position) {
|
||||||
|
if (hasHeaderView()) {
|
||||||
|
position += 1;
|
||||||
|
}
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
protected int getFastAccessItemViewType(int position) {
|
protected int getFastAccessItemViewType(int position) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user