diff options
Diffstat (limited to '')
4 files changed, 30 insertions, 13 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/MucOptions.java b/src/main/java/eu/siacs/conversations/entities/MucOptions.java index 92254b90..853a8408 100644 --- a/src/main/java/eu/siacs/conversations/entities/MucOptions.java +++ b/src/main/java/eu/siacs/conversations/entities/MucOptions.java @@ -213,8 +213,13 @@ public class MucOptions { return getAccount().getRoster().getContactFromRoster(getJid()); } - public void setAvatar(Avatar avatar) { - this.avatar = avatar; + public boolean setAvatar(Avatar avatar) { + if (this.avatar != null && this.avatar.equals(avatar)) { + return false; + } else { + this.avatar = avatar; + return true; + } } public String getAvatar() { diff --git a/src/main/java/eu/siacs/conversations/parser/PresenceParser.java b/src/main/java/eu/siacs/conversations/parser/PresenceParser.java index 12ffd33f..b8a2a7e9 100644 --- a/src/main/java/eu/siacs/conversations/parser/PresenceParser.java +++ b/src/main/java/eu/siacs/conversations/parser/PresenceParser.java @@ -35,7 +35,7 @@ public class PresenceParser extends AbstractParser implements processConferencePresence(packet, mucOptions); final List<MucOptions.User> tileUserAfter = mucOptions.getUsers(5); if (!tileUserAfter.equals(tileUserBefore)) { - mXmppConnectionService.getAvatarService().clear(conversation); + mXmppConnectionService.getAvatarService().clear(mucOptions); } if (before != mucOptions.online() || (mucOptions.online() && count != mucOptions.getUserCount())) { mXmppConnectionService.updateConversationUi(); @@ -86,7 +86,9 @@ public class PresenceParser extends AbstractParser implements if (avatar != null) { avatar.owner = from; if (mXmppConnectionService.getFileBackend().isAvatarCached(avatar)) { - user.setAvatar(avatar); + if (user.setAvatar(avatar)) { + mXmppConnectionService.getAvatarService().clear(user); + } } else { mXmppConnectionService.fetchAvatar(mucOptions.getAccount(), avatar); } diff --git a/src/main/java/eu/siacs/conversations/services/AvatarService.java b/src/main/java/eu/siacs/conversations/services/AvatarService.java index 8c113ab0..be320b6b 100644 --- a/src/main/java/eu/siacs/conversations/services/AvatarService.java +++ b/src/main/java/eu/siacs/conversations/services/AvatarService.java @@ -197,8 +197,7 @@ public class AvatarService { public void clear(MucOptions options) { synchronized (this.sizes) { for (Integer size : sizes) { - this.mXmppConnectionService.getBitmapCache().remove( - key(options, size)); + this.mXmppConnectionService.getBitmapCache().remove(key(options, size)); } } } @@ -253,8 +252,15 @@ public class AvatarService { public void clear(Account account) { synchronized (this.sizes) { for (Integer size : sizes) { - this.mXmppConnectionService.getBitmapCache().remove( - key(account, size)); + this.mXmppConnectionService.getBitmapCache().remove(key(account, size)); + } + } + } + + public void clear(MucOptions.User user) { + synchronized (this.sizes) { + for (Integer size : sizes) { + this.mXmppConnectionService.getBitmapCache().remove(key(user, size)); } } } @@ -346,12 +352,12 @@ public class AvatarService { if (avatar != null) { Uri uri = mXmppConnectionService.getFileBackend().getAvatarUri(avatar); if (uri != null) { - drawTile(canvas, uri, left, top, right, bottom); + if (drawTile(canvas, uri, left, top, right, bottom)) { + return true; + } } - } else { - drawTile(canvas, account.getJid().toBareJid().toString(), left, top, right, bottom); } - return true; + return drawTile(canvas, account.getJid().toBareJid().toString(), left, top, right, bottom); } private boolean drawTile(Canvas canvas, String name, int left, int top, int right, int bottom) { diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 77606956..dbc4825c 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -2367,7 +2367,11 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa if (conversation != null && conversation.getMode() == Conversation.MODE_MULTI) { MucOptions.User user = conversation.getMucOptions().findUser(avatar.owner.getResourcepart()); if (user != null) { - user.setAvatar(avatar); + if (user.setAvatar(avatar)) { + getAvatarService().clear(user); + updateConversationUi(); + updateMucRosterUi(); + } } } } |