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());
|
return getAccount().getRoster().getContactFromRoster(getJid());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAvatar(Avatar avatar) {
|
public boolean setAvatar(Avatar avatar) {
|
||||||
this.avatar = avatar;
|
if (this.avatar != null && this.avatar.equals(avatar)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
this.avatar = avatar;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAvatar() {
|
public String getAvatar() {
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class PresenceParser extends AbstractParser implements
|
||||||
processConferencePresence(packet, mucOptions);
|
processConferencePresence(packet, mucOptions);
|
||||||
final List<MucOptions.User> tileUserAfter = mucOptions.getUsers(5);
|
final List<MucOptions.User> tileUserAfter = mucOptions.getUsers(5);
|
||||||
if (!tileUserAfter.equals(tileUserBefore)) {
|
if (!tileUserAfter.equals(tileUserBefore)) {
|
||||||
mXmppConnectionService.getAvatarService().clear(conversation);
|
mXmppConnectionService.getAvatarService().clear(mucOptions);
|
||||||
}
|
}
|
||||||
if (before != mucOptions.online() || (mucOptions.online() && count != mucOptions.getUserCount())) {
|
if (before != mucOptions.online() || (mucOptions.online() && count != mucOptions.getUserCount())) {
|
||||||
mXmppConnectionService.updateConversationUi();
|
mXmppConnectionService.updateConversationUi();
|
||||||
|
@ -86,7 +86,9 @@ public class PresenceParser extends AbstractParser implements
|
||||||
if (avatar != null) {
|
if (avatar != null) {
|
||||||
avatar.owner = from;
|
avatar.owner = from;
|
||||||
if (mXmppConnectionService.getFileBackend().isAvatarCached(avatar)) {
|
if (mXmppConnectionService.getFileBackend().isAvatarCached(avatar)) {
|
||||||
user.setAvatar(avatar);
|
if (user.setAvatar(avatar)) {
|
||||||
|
mXmppConnectionService.getAvatarService().clear(user);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
mXmppConnectionService.fetchAvatar(mucOptions.getAccount(), avatar);
|
mXmppConnectionService.fetchAvatar(mucOptions.getAccount(), avatar);
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,8 +197,7 @@ public class AvatarService {
|
||||||
public void clear(MucOptions options) {
|
public void clear(MucOptions options) {
|
||||||
synchronized (this.sizes) {
|
synchronized (this.sizes) {
|
||||||
for (Integer size : sizes) {
|
for (Integer size : sizes) {
|
||||||
this.mXmppConnectionService.getBitmapCache().remove(
|
this.mXmppConnectionService.getBitmapCache().remove(key(options, size));
|
||||||
key(options, size));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -253,8 +252,15 @@ public class AvatarService {
|
||||||
public void clear(Account account) {
|
public void clear(Account account) {
|
||||||
synchronized (this.sizes) {
|
synchronized (this.sizes) {
|
||||||
for (Integer size : sizes) {
|
for (Integer size : sizes) {
|
||||||
this.mXmppConnectionService.getBitmapCache().remove(
|
this.mXmppConnectionService.getBitmapCache().remove(key(account, size));
|
||||||
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) {
|
if (avatar != null) {
|
||||||
Uri uri = mXmppConnectionService.getFileBackend().getAvatarUri(avatar);
|
Uri uri = mXmppConnectionService.getFileBackend().getAvatarUri(avatar);
|
||||||
if (uri != null) {
|
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) {
|
private boolean drawTile(Canvas canvas, String name, int left, int top, int right, int bottom) {
|
||||||
|
|
|
@ -2367,7 +2367,11 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||||
if (conversation != null && conversation.getMode() == Conversation.MODE_MULTI) {
|
if (conversation != null && conversation.getMode() == Conversation.MODE_MULTI) {
|
||||||
MucOptions.User user = conversation.getMucOptions().findUser(avatar.owner.getResourcepart());
|
MucOptions.User user = conversation.getMucOptions().findUser(avatar.owner.getResourcepart());
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
user.setAvatar(avatar);
|
if (user.setAvatar(avatar)) {
|
||||||
|
getAvatarService().clear(user);
|
||||||
|
updateConversationUi();
|
||||||
|
updateMucRosterUi();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue