correct message sorting

This commit is contained in:
B. Petersen
2018-09-20 01:11:01 +02:00
parent 53b6c6648d
commit 1391c187a5
2 changed files with 7 additions and 4 deletions
+1 -1
View File
@@ -81,7 +81,7 @@ public class DcMsg {
}
public boolean isOutgoing() {
return getFromId() != DcContact.DC_CONTACT_ID_SELF;
return getFromId() == DcContact.DC_CONTACT_ID_SELF;
}
public boolean isGroupAction() {
@@ -130,7 +130,10 @@ public class ConversationAdapter <V extends View & BindableConversationItem>
}
private DcMsg getMsg(int position) {
return dcContext.getMsg(dcMsgList[position]);
if(position>=0 && position<dcMsgList.length) {
return dcContext.getMsg(dcMsgList[dcMsgList.length-1-position]);
}
return new DcMsg(0);
}
static class HeaderViewHolder extends RecyclerView.ViewHolder {
@@ -200,8 +203,8 @@ public class ConversationAdapter <V extends View & BindableConversationItem>
@Override
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
ConversationAdapter.ViewHolder holder = (ConversationAdapter.ViewHolder)viewHolder;
Optional<DcMsg> previous = position <= 0? Optional.absent() : Optional.of(getMsg(position-1));
Optional<DcMsg> next = position >= dcMsgList.length-1? Optional.absent() : Optional.of(getMsg(position+1));
Optional<DcMsg> previous = position >= dcMsgList.length-1? Optional.absent() : Optional.of(getMsg(position+1));
Optional<DcMsg> next = position <= 0? Optional.absent() : Optional.of(getMsg(position-1));
boolean pulseHighlight = dcMsgList[position] == recordToPulseHighlight;
holder.getItem().bind(getMsg(position), previous, next, glideRequests, locale, batchSelected, recipient, pulseHighlight);
}