mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-11 11:45:01 -05:00
properly clear muc user avatar caches
This commit is contained in:
parent
9d1e8a34b2
commit
cd9a29718b
@ -213,8 +213,13 @@ public class MucOptions {
|
||||
return getAccount().getRoster().getContactFromRoster(getJid());
|
||||
}
|
||||
|
||||
public void setAvatar(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() {
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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,13 +352,13 @@ public class AvatarService {
|
||||
if (avatar != null) {
|
||||
Uri uri = mXmppConnectionService.getFileBackend().getAvatarUri(avatar);
|
||||
if (uri != null) {
|
||||
drawTile(canvas, uri, left, top, right, bottom);
|
||||
}
|
||||
} else {
|
||||
drawTile(canvas, account.getJid().toBareJid().toString(), left, top, right, bottom);
|
||||
}
|
||||
if (drawTile(canvas, uri, 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) {
|
||||
if (name != null) {
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user