made avatar cache cleaning more efficent after name changes
This commit is contained in:
parent
d348780dfc
commit
e6a67a6c26
|
@ -256,13 +256,15 @@ public class Contact implements ListItem, Blockable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setSystemName(String systemName) {
|
public boolean setSystemName(String systemName) {
|
||||||
String old = this.systemName;
|
final String old = getDisplayName();
|
||||||
this.systemName = systemName;
|
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;
|
this.presenceName = presenceName;
|
||||||
|
return !old.equals(getDisplayName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Uri getSystemAccount() {
|
public Uri getSystemAccount() {
|
||||||
|
|
|
@ -280,12 +280,13 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ("http://jabber.org/protocol/nick".equals(node)) {
|
} else if ("http://jabber.org/protocol/nick".equals(node)) {
|
||||||
Element i = items.findChild("item");
|
final Element i = items.findChild("item");
|
||||||
Element nick = i == null ? null : i.findChild("nick", "http://jabber.org/protocol/nick");
|
final String nick = i == null ? null : i.findChildContent("nick", Namespace.NICK);
|
||||||
if (nick != null && nick.getContent() != null) {
|
if (nick != null) {
|
||||||
Contact contact = account.getRoster().getContact(from);
|
Contact contact = account.getRoster().getContact(from);
|
||||||
contact.setPresenceName(nick.getContent());
|
if (contact.setPresenceName(nick)) {
|
||||||
mXmppConnectionService.getAvatarService().clear(account);
|
mXmppConnectionService.getAvatarService().clear(contact);
|
||||||
|
}
|
||||||
mXmppConnectionService.updateConversationUi();
|
mXmppConnectionService.updateConversationUi();
|
||||||
mXmppConnectionService.updateAccountUi();
|
mXmppConnectionService.updateAccountUi();
|
||||||
}
|
}
|
||||||
|
@ -721,10 +722,12 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
||||||
parseEvent(event, original.getFrom(), account);
|
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) {
|
if (nick != null) {
|
||||||
Contact contact = account.getRoster().getContact(from);
|
Contact contact = account.getRoster().getContact(from);
|
||||||
contact.setPresenceName(nick);
|
if (contact.setPresenceName(nick)) {
|
||||||
|
mXmppConnectionService.getAvatarService().clear(contact);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -187,7 +187,9 @@ public class PresenceParser extends AbstractParser implements
|
||||||
final Contact contact = account.getRoster().getContact(from);
|
final Contact contact = account.getRoster().getContact(from);
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
final String resource = from.isBareJid() ? "" : from.getResourcepart();
|
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"));
|
Avatar avatar = Avatar.parsePresence(packet.findChild("x", "vcard-temp:x:update"));
|
||||||
if (avatar != null && (!contact.isSelf() || account.getAvatar() == null)) {
|
if (avatar != null && (!contact.isSelf() || account.getAvatar() == null)) {
|
||||||
avatar.owner = from.toBareJid();
|
avatar.owner = from.toBareJid();
|
||||||
|
|
|
@ -15,4 +15,5 @@ public final class Namespace {
|
||||||
public static final String TLS = "urn:ietf:params:xml:ns:xmpp-tls";
|
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_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 PUBSUB_ERROR = "http://jabber.org/protocol/pubsub#errors";
|
||||||
|
public static final String NICK = "http://jabber.org/protocol/nick";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue