aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2017-09-04 20:59:35 +0200
committerChristian Schneppe <christian@pix-art.de>2017-09-04 20:59:35 +0200
commit494fb2d3275fe990450c6c1de9a8435dcb317c2f (patch)
tree9afc92be0ccfa1943c8fde0fc953087b6bd1adbc /src/main/java
parenta558ea31ea2d69e4e6777b6ed56fad1e68de1880 (diff)
made avatar cache cleaning more efficent after name changes
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/de/pixart/messenger/entities/Contact.java8
-rw-r--r--src/main/java/de/pixart/messenger/parser/MessageParser.java17
-rw-r--r--src/main/java/de/pixart/messenger/parser/PresenceParser.java4
-rw-r--r--src/main/java/de/pixart/messenger/utils/Namespace.java1
4 files changed, 19 insertions, 11 deletions
diff --git a/src/main/java/de/pixart/messenger/entities/Contact.java b/src/main/java/de/pixart/messenger/entities/Contact.java
index 9681e69bc..7eb1394ce 100644
--- a/src/main/java/de/pixart/messenger/entities/Contact.java
+++ b/src/main/java/de/pixart/messenger/entities/Contact.java
@@ -263,13 +263,15 @@ public class Contact implements ListItem, Blockable {
}
public boolean setSystemName(String systemName) {
- String old = this.systemName;
+ final String old = getDisplayName();
this.systemName = systemName;
- return (old == null && systemName != null) || (old != null && !old.equals(systemName));
+ return !old.equals(getDisplayName());
}
- public void setPresenceName(String presenceName) {
+ public boolean setPresenceName(String presenceName) {
+ final String old = getDisplayName();
this.presenceName = presenceName;
+ return !old.equals(getDisplayName());
}
public Uri getSystemAccount() {
diff --git a/src/main/java/de/pixart/messenger/parser/MessageParser.java b/src/main/java/de/pixart/messenger/parser/MessageParser.java
index 25190b32d..54a4571cc 100644
--- a/src/main/java/de/pixart/messenger/parser/MessageParser.java
+++ b/src/main/java/de/pixart/messenger/parser/MessageParser.java
@@ -280,12 +280,13 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
}
}
} else if ("http://jabber.org/protocol/nick".equals(node)) {
- Element i = items.findChild("item");
- Element nick = i == null ? null : i.findChild("nick", "http://jabber.org/protocol/nick");
- if (nick != null && nick.getContent() != null) {
+ final Element i = items.findChild("item");
+ final String nick = i == null ? null : i.findChildContent("nick", Namespace.NICK);
+ if (nick != null) {
Contact contact = account.getRoster().getContact(from);
- contact.setPresenceName(nick.getContent());
- mXmppConnectionService.getAvatarService().clear(account);
+ if (contact.setPresenceName(nick)) {
+ mXmppConnectionService.getAvatarService().clear(contact);
+ }
mXmppConnectionService.updateConversationUi();
mXmppConnectionService.updateAccountUi();
}
@@ -707,10 +708,12 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
parseEvent(event, original.getFrom(), account);
}
- String nick = packet.findChildContent("nick", "http://jabber.org/protocol/nick");
+ final String nick = packet.findChildContent("nick", Namespace.NICK);
if (nick != null) {
Contact contact = account.getRoster().getContact(from);
- contact.setPresenceName(nick);
+ if (contact.setPresenceName(nick)) {
+ mXmppConnectionService.getAvatarService().clear(contact);
+ }
}
}
diff --git a/src/main/java/de/pixart/messenger/parser/PresenceParser.java b/src/main/java/de/pixart/messenger/parser/PresenceParser.java
index 37efcdc8b..0ade1abc3 100644
--- a/src/main/java/de/pixart/messenger/parser/PresenceParser.java
+++ b/src/main/java/de/pixart/messenger/parser/PresenceParser.java
@@ -185,7 +185,9 @@ public class PresenceParser extends AbstractParser implements
final Contact contact = account.getRoster().getContact(from);
if (type == null) {
final String resource = from.isBareJid() ? "" : from.getResourcepart();
- contact.setPresenceName(packet.findChildContent("nick", "http://jabber.org/protocol/nick"));
+ if (contact.setPresenceName(packet.findChildContent("nick", Namespace.NICK))) {
+ mXmppConnectionService.getAvatarService().clear(contact);
+ }
Avatar avatar = Avatar.parsePresence(packet.findChild("x", "vcard-temp:x:update"));
if (avatar != null && (!contact.isSelf() || account.getAvatar() == null)) {
avatar.owner = from.toBareJid();
diff --git a/src/main/java/de/pixart/messenger/utils/Namespace.java b/src/main/java/de/pixart/messenger/utils/Namespace.java
index 1cf4d5c74..d80b31d33 100644
--- a/src/main/java/de/pixart/messenger/utils/Namespace.java
+++ b/src/main/java/de/pixart/messenger/utils/Namespace.java
@@ -15,4 +15,5 @@ public final class Namespace {
public static final String TLS = "urn:ietf:params:xml:ns:xmpp-tls";
public static final String PUBSUB_PUBLISH_OPTIONS = "http://jabber.org/protocol/pubsub#publish-options";
public static final String PUBSUB_ERROR = "http://jabber.org/protocol/pubsub#errors";
+ public static final String NICK = "http://jabber.org/protocol/nick";
}