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

View file

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

View file

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