reorder and scroll down after resending a message

This commit is contained in:
Daniel Gultsch 2018-03-05 13:23:04 +01:00
parent 3bff110587
commit de2f5e7a83
3 changed files with 17 additions and 11 deletions

View File

@ -848,9 +848,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
public void sort() {
synchronized (this.messages) {
Collections.sort(this.messages, new Comparator<Message>() {
@Override
public int compare(Message left, Message right) {
Collections.sort(this.messages, (left, right) -> {
if (left.getTimeSent() < right.getTimeSent()) {
return -1;
} else if (left.getTimeSent() > right.getTimeSent()) {
@ -858,7 +856,6 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
} else {
return 0;
}
}
});
untieMessages();
}

View File

@ -3588,6 +3588,8 @@ public class XmppConnectionService extends Service {
markMessage(msg, Message.STATUS_WAITING);
this.resendMessage(msg, false);
}
message.getConversation().sort();
updateConversationUi();
}
public void clearConversationHistory(final Conversation conversation) {

View File

@ -1528,6 +1528,10 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
activity.selectPresence(conversation, () -> {
message.setCounterpart(conversation.getNextCounterpart());
activity.xmppConnectionService.resendFailedMessages(message);
new Handler().post(() -> {
int size = messageList.size();
this.binding.messagesView.setSelection(size - 1);
});
});
return;
}
@ -1540,7 +1544,10 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
}
}
activity.xmppConnectionService.resendFailedMessages(message);
}
new Handler().post(() -> {
int size = messageList.size();
this.binding.messagesView.setSelection(size - 1);
}); }
private void copyUrl(Message message) {
final String url;