forked from mirror/monocles_chat_clean
update fork #128
1 changed files with 28 additions and 8 deletions
Prioritize real avatars over generated ones in stories
commit
fbf61765c2
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.siacs.conversations.ui.adapter;
|
package eu.siacs.conversations.ui.adapter;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.text.format.DateUtils;
|
import android.text.format.DateUtils;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
@ -76,24 +77,43 @@ public class StoryAdapter extends RecyclerView.Adapter<StoryAdapter.StoryViewHol
|
||||||
public void onBindViewHolder(@NonNull StoryViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull StoryViewHolder holder, int position) {
|
||||||
final Story story = stories.get(position);
|
final Story story = stories.get(position);
|
||||||
final Jid jid = story.getContact();
|
final Jid jid = story.getContact();
|
||||||
Contact contact = null;
|
Contact contact = null;Account storyAccount = null;
|
||||||
Account storyAccount = null;
|
Drawable avatar = null;
|
||||||
|
|
||||||
|
final int avatarSize = activity.getResources().getDimensionPixelSize(R.dimen.avatar_story_size);
|
||||||
|
|
||||||
for (Account account : activity.xmppConnectionService.getAccounts()) {
|
for (Account account : activity.xmppConnectionService.getAccounts()) {
|
||||||
contact = account.getRoster().getContact(jid);
|
final Contact c = account.getRoster().getContact(jid);
|
||||||
if (contact != null) {
|
if (c != null) {
|
||||||
storyAccount = account;
|
final Drawable d = activity.xmppConnectionService.getAvatarService().get(c, avatarSize);
|
||||||
break;
|
if (!(d instanceof eu.siacs.conversations.services.AvatarService.TextDrawable)) {
|
||||||
|
contact = c;
|
||||||
|
storyAccount = account;
|
||||||
|
avatar = d;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (contact == null) {
|
||||||
|
contact = c;
|
||||||
|
storyAccount = account;
|
||||||
|
avatar = d;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contact == null) {
|
if (contact == null) {
|
||||||
storyAccount = activity.xmppConnectionService.findAccountByJid(jid);
|
storyAccount = activity.xmppConnectionService.findAccountByJid(jid);
|
||||||
if (storyAccount != null) {
|
if (storyAccount != null) {
|
||||||
contact = storyAccount.getSelfContact();
|
contact = storyAccount.getSelfContact();
|
||||||
|
avatar = activity.xmppConnectionService.getAvatarService().get(contact, avatarSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (contact != null) {
|
|
||||||
|
if (contact != null && avatar != null) {
|
||||||
holder.storyTitle.setText(contact.getDisplayName());
|
holder.storyTitle.setText(contact.getDisplayName());
|
||||||
holder.storyImage.setImageDrawable(activity.xmppConnectionService.getAvatarService().get(contact, activity.getResources().getDimensionPixelSize(R.dimen.avatar_story_size)));
|
holder.storyImage.setImageDrawable(avatar);
|
||||||
|
} else if (contact != null) {
|
||||||
|
holder.storyTitle.setText(contact.getDisplayName());
|
||||||
|
holder.storyImage.setImageResource(R.drawable.ic_person_black_48dp);
|
||||||
} else {
|
} else {
|
||||||
holder.storyTitle.setText(jid.asBareJid().toString());
|
holder.storyTitle.setText(jid.asBareJid().toString());
|
||||||
holder.storyImage.setImageResource(R.drawable.ic_person_black_48dp);
|
holder.storyImage.setImageResource(R.drawable.ic_person_black_48dp);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue