when no avatar found show avatar of contact and not the muc user in conferences

This commit is contained in:
Daniel Gultsch 2015-12-09 10:30:26 +01:00
parent aea664a0ec
commit 11e58607c9
3 changed files with 13 additions and 5 deletions

View file

@ -302,15 +302,15 @@ public class MucOptions {
return hasFeature("muc_moderated");
}
public void deleteUser(String name) {
public User deleteUser(String name) {
synchronized (this.users) {
for (int i = 0; i < users.size(); ++i) {
if (users.get(i).getName().equals(name)) {
users.remove(i);
return;
return users.remove(i);
}
}
}
return null;
}
public void addUser(User user) {

View file

@ -110,7 +110,10 @@ public class PresenceParser extends AbstractParser implements
mucOptions.setError(MucOptions.ERROR_UNKNOWN);
}
} else if (!from.isBareJid()){
mucOptions.deleteUser(from.getResourcepart());
MucOptions.User user = mucOptions.deleteUser(from.getResourcepart());
if (user != null) {
mXmppConnectionService.getAvatarService().clear(user);
}
}
} else if (type.equals("error")) {
Element error = packet.findChild("error");

View file

@ -77,7 +77,12 @@ public class AvatarService {
avatar = mXmppConnectionService.getFileBackend().getAvatar(user.getAvatar(), size);
}
if (avatar == null) {
avatar = get(user.getName(), size, cachedOnly);
Contact contact = user.getContact();
if (contact != null) {
avatar = get(contact, size, cachedOnly);
} else {
avatar = get(user.getName(), size, cachedOnly);
}
}
this.mXmppConnectionService.getBitmapCache().put(KEY, avatar);
return avatar;