Commit 2ca025f0 authored by Hussein's avatar Hussein

P4A-1132 Add null check and fallback for when message.from is null or empty

parent db59131f
......@@ -298,12 +298,7 @@ public class MessageHeader extends LinearLayout implements OnClickListener, OnLo
public void populate(final Message message, final Account account) {
if (PEpUtils.isMessageOnOutgoingFolder(message, account)) {
loadpEpRating(message, account.ispEpPrivacyProtected());
}
else {
loadpEpRating(message.getFrom()[0], account.ispEpPrivacyProtected());
}
populateRating(message, account);
final Contacts contacts =
permissionChecker.hasContactsPermission() &&
......@@ -398,6 +393,22 @@ public class MessageHeader extends LinearLayout implements OnClickListener, OnLo
}
}
private void populateRating(Message message, Account account) {
if (PEpUtils.isMessageOnOutgoingFolder(message, account)) {
loadpEpRating(message, account.ispEpPrivacyProtected());
}
else {
if (message.getFrom() != null && message.getFrom().length > 0) {
loadpEpRating(message.getFrom()[0], account.ispEpPrivacyProtected());
} else {
Timber.e("Message %s from is null or empty, uid = %s",
message.getMessageId(), message.getUid());
pEpRating = Rating.pEpRatingUndefined;
mContactBadge.setPepRating(pEpRating, account.ispEpPrivacyProtected());
}
}
}
private void loadpEpRating(Address from, boolean isPrivacyProtected) {
PEpProvider pEp = ((K9) getContext().getApplicationContext()).getpEpProvider();
pEp.getRating(from, new PEpProvider.ResultCallback<Rating>() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment