catch conversations sort exception. not vital at this point
This commit is contained in:
parent
33a02faad9
commit
cb7c47bc62
|
@ -28,7 +28,7 @@ import eu.siacs.conversations.xmpp.jid.InvalidJidException;
|
||||||
import eu.siacs.conversations.xmpp.jid.Jid;
|
import eu.siacs.conversations.xmpp.jid.Jid;
|
||||||
|
|
||||||
|
|
||||||
public class Conversation extends AbstractEntity implements Blockable {
|
public class Conversation extends AbstractEntity implements Blockable, Comparable<Conversation> {
|
||||||
public static final String TABLENAME = "conversations";
|
public static final String TABLENAME = "conversations";
|
||||||
|
|
||||||
public static final int STATUS_AVAILABLE = 0;
|
public static final int STATUS_AVAILABLE = 0;
|
||||||
|
@ -356,6 +356,19 @@ public class Conversation extends AbstractEntity implements Blockable {
|
||||||
return getContact().isSelf();
|
return getContact().isSelf();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(Conversation another) {
|
||||||
|
final Message left = getLatestMessage();
|
||||||
|
final Message right = another.getLatestMessage();
|
||||||
|
if (left.getTimeSent() > right.getTimeSent()) {
|
||||||
|
return -1;
|
||||||
|
} else if (left.getTimeSent() < right.getTimeSent()) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public interface OnMessageFound {
|
public interface OnMessageFound {
|
||||||
void onMessageFound(final Message message);
|
void onMessageFound(final Message message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1297,21 +1297,12 @@ public class XmppConnectionService extends Service {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Collections.sort(list, new Comparator<Conversation>() {
|
try {
|
||||||
@Override
|
Collections.sort(list);
|
||||||
public int compare(Conversation lhs, Conversation rhs) {
|
} catch (IllegalArgumentException e) {
|
||||||
Message left = lhs.getLatestMessage();
|
//ignore
|
||||||
Message right = rhs.getLatestMessage();
|
|
||||||
if (left.getTimeSent() > right.getTimeSent()) {
|
|
||||||
return -1;
|
|
||||||
} else if (left.getTimeSent() < right.getTimeSent()) {
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadMoreMessages(final Conversation conversation, final long timestamp, final OnMoreMessagesLoaded callback) {
|
public void loadMoreMessages(final Conversation conversation, final long timestamp, final OnMoreMessagesLoaded callback) {
|
||||||
if (XmppConnectionService.this.getMessageArchiveService().queryInProgress(conversation, callback)) {
|
if (XmppConnectionService.this.getMessageArchiveService().queryInProgress(conversation, callback)) {
|
||||||
|
|
Loading…
Reference in New Issue