made avatar cache cleaning more efficent after name changes

This commit is contained in:
Daniel Gultsch 2017-08-23 21:49:25 +02:00
parent d348780dfc
commit e6a67a6c26
4 changed files with 19 additions and 11 deletions

View file

@ -256,13 +256,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() {

View file

@ -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();
}
@ -721,10 +722,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);
}
}
}

View file

@ -187,7 +187,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();

View file

@ -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";
}