clear avatar cache when system name changes

This commit is contained in:
Daniel Gultsch 2017-02-10 20:26:21 +01:00
parent 5e367cb115
commit 6b81ff70e5
2 changed files with 9 additions and 5 deletions

View File

@ -255,8 +255,10 @@ public class Contact implements ListItem, Blockable {
this.serverName = serverName; this.serverName = serverName;
} }
public void setSystemName(String systemName) { public boolean setSystemName(String systemName) {
String old = this.systemName;
this.systemName = systemName; this.systemName = systemName;
return (old == null && systemName != null) || (old != null && !old.equals(systemName));
} }
public void setPresenceName(String presenceName) { public void setPresenceName(String presenceName) {

View File

@ -1518,16 +1518,18 @@ public class XmppConnectionService extends Service {
+ "#" + "#"
+ phoneContact.getString("lookup"); + phoneContact.getString("lookup");
contact.setSystemAccount(systemAccount); contact.setSystemAccount(systemAccount);
if (contact.setPhotoUri(phoneContact.getString("photouri"))) { boolean needsCacheClean = contact.setPhotoUri(phoneContact.getString("photouri"));
needsCacheClean |= contact.setSystemName(phoneContact.getString("displayname"));
if (needsCacheClean) {
getAvatarService().clear(contact); getAvatarService().clear(contact);
} }
contact.setSystemName(phoneContact.getString("displayname"));
withSystemAccounts.remove(contact); withSystemAccounts.remove(contact);
} }
for (Contact contact : withSystemAccounts) { for (Contact contact : withSystemAccounts) {
contact.setSystemAccount(null); contact.setSystemAccount(null);
contact.setSystemName(null); boolean needsCacheClean = contact.setPhotoUri(null);
if (contact.setPhotoUri(null)) { needsCacheClean |= contact.setSystemName(null);
if (needsCacheClean) {
getAvatarService().clear(contact); getAvatarService().clear(contact);
} }
} }