mirror of https://github.com/M66B/FairEmail.git
Fixed empty photo in message view
This commit is contained in:
parent
4f5972f07f
commit
70417266c1
|
@ -489,17 +489,22 @@ public class FragmentMessage extends FragmentEx {
|
||||||
|
|
||||||
setSeen();
|
setSeen();
|
||||||
|
|
||||||
if (message.avatar == null ||
|
boolean photo = false;
|
||||||
|
if (message.avatar != null &&
|
||||||
ContextCompat.checkSelfPermission(getContext(), Manifest.permission.READ_CONTACTS)
|
ContextCompat.checkSelfPermission(getContext(), Manifest.permission.READ_CONTACTS)
|
||||||
!= PackageManager.PERMISSION_GRANTED) {
|
== PackageManager.PERMISSION_GRANTED) {
|
||||||
|
ContentResolver resolver = getContext().getContentResolver();
|
||||||
|
InputStream is = ContactsContract.Contacts.openContactPhotoInputStream(resolver, Uri.parse(message.avatar));
|
||||||
|
if (is != null) {
|
||||||
|
photo = true;
|
||||||
|
ivAvatar.setImageDrawable(Drawable.createFromStream(is, "avatar"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!photo) {
|
||||||
ViewGroup.LayoutParams lp = ivAvatar.getLayoutParams();
|
ViewGroup.LayoutParams lp = ivAvatar.getLayoutParams();
|
||||||
lp.height = 0;
|
lp.height = 0;
|
||||||
lp.width = 0;
|
lp.width = 0;
|
||||||
ivAvatar.setLayoutParams(lp);
|
ivAvatar.setLayoutParams(lp);
|
||||||
} else {
|
|
||||||
ContentResolver resolver = getContext().getContentResolver();
|
|
||||||
InputStream is = ContactsContract.Contacts.openContactPhotoInputStream(resolver, Uri.parse(message.avatar));
|
|
||||||
ivAvatar.setImageDrawable(Drawable.createFromStream(is, "avatar"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.from == null ||
|
if (message.from == null ||
|
||||||
|
|
Loading…
Reference in New Issue