avoided unecessary message searchs

This commit is contained in:
iNPUTmice 2014-10-02 18:54:21 +02:00
parent f8be57d43f
commit cc76e15b95

View File

@ -1533,6 +1533,9 @@ public class XmppConnectionService extends Service {
public boolean markMessage(Account account, String recipient, String uuid, public boolean markMessage(Account account, String recipient, String uuid,
int status) { int status) {
if (uuid == null) {
return false;
} else {
for (Conversation conversation : getConversations()) { for (Conversation conversation : getConversations()) {
if (conversation.getContactJid().equals(recipient) if (conversation.getContactJid().equals(recipient)
&& conversation.getAccount().equals(account)) { && conversation.getAccount().equals(account)) {
@ -1541,11 +1544,15 @@ public class XmppConnectionService extends Service {
} }
return false; return false;
} }
}
public boolean markMessage(Conversation conversation, String uuid, public boolean markMessage(Conversation conversation, String uuid,
int status) { int status) {
if (uuid == null) {
return false;
} else {
for (Message message : conversation.getMessages()) { for (Message message : conversation.getMessages()) {
if (message.getUuid().equals(uuid) if (uuid.equals(message.getUuid())
|| (message.getStatus() >= Message.STATUS_SEND && uuid || (message.getStatus() >= Message.STATUS_SEND && uuid
.equals(message.getRemoteMsgId()))) { .equals(message.getRemoteMsgId()))) {
markMessage(message, status); markMessage(message, status);
@ -1554,6 +1561,7 @@ public class XmppConnectionService extends Service {
} }
return false; return false;
} }
}
public void markMessage(Message message, int status) { public void markMessage(Message message, int status) {
if (status == Message.STATUS_SEND_FAILED if (status == Message.STATUS_SEND_FAILED