private void drawTile( Canvas canvas, MucOptions.User user, int left, int top, int right, int bottom) { Contact contact = user.getContact(); if (contact != null) { Uri uri = null; if (contact.getProfilePhoto() != null) { uri = Uri.parse(contact.getProfilePhoto()); } else if (contact.getAvatar() != null) { uri = mXmppConnectionService.getFileBackend().getAvatarUri(contact.getAvatar()); } if (uri != null) { Bitmap bitmap = mXmppConnectionService.getFileBackend().cropCenter(uri, bottom - top, right - left); if (bitmap != null) { drawTile(canvas, bitmap, left, top, right, bottom); return; } } } String name = user.getName(); String letter; int color; if (name.length() > 0) { letter = name.substring(0, 1); color = this.getColorForName(name); } else { letter = "X"; color = PLACEHOLDER_COLOR; } drawTile(canvas, letter, color, left, top, right, bottom); }
public Bitmap get(Contact contact, int size) { final String KEY = key(contact, size); Bitmap avatar = this.mXmppConnectionService.getBitmapCache().get(KEY); if (avatar != null) { return avatar; } if (contact.getProfilePhoto() != null) { avatar = mXmppConnectionService .getFileBackend() .cropCenterSquare(Uri.parse(contact.getProfilePhoto()), size); } if (avatar == null && contact.getAvatar() != null) { avatar = mXmppConnectionService.getFileBackend().getAvatar(contact.getAvatar(), size); } if (avatar == null) { avatar = get(contact.getDisplayName(), size); } this.mXmppConnectionService.getBitmapCache().put(KEY, avatar); return avatar; }