Small improvement

pull/147/head
M66B 6 years ago
parent 7f2b54f28b
commit 05a03e11ea

@ -469,6 +469,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ivAvatar.setTag(message.id);
ivAvatar.setVisibility(View.INVISIBLE);
tvFrom.setTag(message.id);
Address[] addresses = (Address[]) args.getSerializable("addresses");
tvFrom.setText(MessageHelper.formatAddresses(addresses, !compact, false));
}
@Override
@ -505,9 +507,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (info != null && info.hasDisplayName())
try {
Address[] addresses = (Address[]) args.getSerializable("addresses");
InternetAddress ia = (InternetAddress) addresses[0];
ia.setPersonal(info.getDisplayName());
tvFrom.setText(MessageHelper.formatAddresses(new Address[]{ia}, !compact, false));
((InternetAddress) addresses[0]).setPersonal(info.getDisplayName());
tvFrom.setText(MessageHelper.formatAddresses(addresses, !compact, false));
} catch (UnsupportedEncodingException ex) {
Log.w(ex);
}
@ -536,7 +537,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ivFlagged.setImageTintList(ColorStateList.valueOf(flagged > 0 ? colorAccent : textColorSecondary));
ivFlagged.setVisibility(message.uid == null ? View.INVISIBLE : View.VISIBLE);
tvFrom.setText(MessageHelper.formatAddresses(outgoing ? message.to : message.from, !compact, false));
tvSize.setText(message.size == null ? null : Helper.humanReadableByteCount(message.size, true));
tvSize.setVisibility(message.size == null || message.content ? View.GONE : View.VISIBLE);
tvTime.setText(tf.format(message.received));

@ -71,7 +71,7 @@ public class ContactInfo {
}
static ContactInfo get(Context context, Address[] addresses) {
if (addresses == null)
if (addresses == null || addresses.length == 0)
return null;
if (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_CONTACTS)
@ -79,7 +79,6 @@ public class ContactInfo {
return null;
try {
for (Address address : addresses) {
Cursor cursor = null;
try {
ContentResolver resolver = context.getContentResolver();
@ -91,7 +90,7 @@ public class ContactInfo {
},
ContactsContract.CommonDataKinds.Email.ADDRESS + " = ?",
new String[]{
((InternetAddress) address).getAddress()
((InternetAddress) addresses[0]).getAddress()
}, null);
if (cursor != null && cursor.moveToNext()) {
@ -113,7 +112,6 @@ public class ContactInfo {
if (cursor != null)
cursor.close();
}
}
} catch (Throwable ex) {
Log.e(ex);
}

Loading…
Cancel
Save