Use contact photo placeholders

pull/147/head
M66B 6 years ago
parent 29248811f7
commit 8d99da214b

@ -355,8 +355,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} }
if (avatars || identicons) { if (avatars || identicons) {
ivAvatar.setVisibility(compact ? View.GONE : View.INVISIBLE);
Bundle aargs = new Bundle(); Bundle aargs = new Bundle();
aargs.putLong("id", message.id); aargs.putLong("id", message.id);
aargs.putString("uri", message.avatar); aargs.putString("uri", message.avatar);
@ -366,6 +364,11 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ivAvatar.setTag(message.id); ivAvatar.setTag(message.id);
new SimpleTask<Drawable>() { new SimpleTask<Drawable>() {
@Override
protected void onPreExecute(Bundle args) {
ivAvatar.setVisibility(View.INVISIBLE);
}
@Override @Override
protected Drawable onExecute(Context context, Bundle args) { protected Drawable onExecute(Context context, Bundle args) {
String uri = args.getString("uri"); String uri = args.getString("uri");
@ -380,25 +383,25 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} }
String from = args.getString("from"); String from = args.getString("from");
if (identicons && !outgoing && from != null) { if (identicons && !outgoing && from != null)
return new BitmapDrawable( return new BitmapDrawable(
context.getResources(), context.getResources(),
Identicon.generate(from, dp24, 5, "light".equals(theme))); Identicon.generate(from, dp24, 5, "light".equals(theme)));
}
return null; return null;
} }
@Override @Override
protected void onExecuted(Bundle args, Drawable avatar) { protected void onExecuted(Bundle args, Drawable avatar) {
if (avatar != null) {
if ((long) ivAvatar.getTag() == args.getLong("id")) { if ((long) ivAvatar.getTag() == args.getLong("id")) {
if (avatar == null && !outgoing)
ivAvatar.setImageResource(R.drawable.baseline_person_24);
else
ivAvatar.setImageDrawable(avatar); ivAvatar.setImageDrawable(avatar);
ivAvatar.setVisibility(View.VISIBLE); ivAvatar.setVisibility(View.VISIBLE);
} else } else
Log.i("Skipping avatar"); Log.i("Skipping avatar");
} }
}
@Override @Override
protected void onException(Bundle args, Throwable ex) { protected void onException(Bundle args, Throwable ex) {

Loading…
Cancel
Save