diff options
Diffstat (limited to 'src/main/java/de/pixart/messenger/services/AvatarService.java')
-rw-r--r-- | src/main/java/de/pixart/messenger/services/AvatarService.java | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/main/java/de/pixart/messenger/services/AvatarService.java b/src/main/java/de/pixart/messenger/services/AvatarService.java index aa861c147..bd157f442 100644 --- a/src/main/java/de/pixart/messenger/services/AvatarService.java +++ b/src/main/java/de/pixart/messenger/services/AvatarService.java @@ -12,6 +12,7 @@ import android.graphics.RectF; import android.graphics.Typeface; import android.net.Uri; import android.support.annotation.Nullable; +import android.text.TextUtils; import android.util.DisplayMetrics; import android.util.Log; import android.util.LruCache; @@ -80,7 +81,7 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded { if (avatar != null || cachedOnly) { return avatar; } - if (avatar == null && contact.getAvatarFilename() != null) { + if (contact.getAvatarFilename() != null) { avatar = mXmppConnectionService.getFileBackend().getAvatar(contact.getAvatarFilename(), size); } if (avatar == null && contact.getProfilePhoto() != null) { @@ -91,7 +92,7 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded { } } if (avatar == null) { - avatar = get(contact.getDisplayName(), contact.getJid().asBareJid().toString(), size, cachedOnly); + avatar = get(contact.getDisplayName(), contact.getJid().asBareJid().toString(), size, false); } this.mXmppConnectionService.getBitmapCache().put(KEY, avatar); return avatar; @@ -165,10 +166,10 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded { if (avatar == null) { Contact contact = user.getContact(); if (contact != null) { - avatar = get(contact, size, cachedOnly); + avatar = get(contact, size, false); } else { String seed = user.getRealJid() != null ? user.getRealJid().asBareJid().toString() : null; - avatar = get(user.getName(), seed, size, cachedOnly); + avatar = get(user.getName(), seed, size, false); } } this.mXmppConnectionService.getBitmapCache().put(KEY, avatar); @@ -235,7 +236,7 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded { if (bookmark.getConversation() != null) { return get(bookmark.getConversation(), size, cachedOnly); } else { - Jid jid = bookmark.getJid(); + final Jid jid = bookmark.getFullJid(); Account account = bookmark.getAccount(); Contact contact = jid == null ? null : account.getRoster().getContact(jid); if (contact != null && contact.getAvatarFilename() != null) { @@ -406,7 +407,8 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded { } avatar = mXmppConnectionService.getFileBackend().getAvatar(account.getAvatar(), size); if (avatar == null) { - avatar = get(account.getJid().asBareJid().toString(), null, size, false); + final String jid = account.getJid().asBareJid().toEscapedString(); + avatar = get(jid, null, size, false); } mXmppConnectionService.getBitmapCache().put(KEY, avatar); return avatar; @@ -474,7 +476,7 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded { } public Bitmap get(final String name, String seed, final int size, boolean cachedOnly) { - final String KEY = key(seed == null ? name : seed, size); + final String KEY = key(seed == null ? name : name + "\0" + seed, size); Bitmap bitmap = mXmppConnectionService.getBitmapCache().get(KEY); if (bitmap != null || cachedOnly) { return bitmap; @@ -524,11 +526,14 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded { Contact contact = user.getContact(); if (contact != null) { Uri uri = null; - if (contact.getProfilePhoto() != null) { + if (contact.getAvatarFilename() != null) { + try { + uri = mXmppConnectionService.getFileBackend().getAvatarUri(contact.getAvatarFilename()); + } catch (Exception e) { + e.printStackTrace(); + } + } else if (contact.getProfilePhoto() != null) { uri = Uri.parse(contact.getProfilePhoto()); - } else if (contact.getAvatarFilename() != null) { - uri = mXmppConnectionService.getFileBackend().getAvatarUri( - contact.getAvatarFilename()); } if (drawTile(canvas, uri, left, top, right, bottom)) { return true; |