Skip to content
Snippets Groups Projects
Commit 649d49f1 authored by Thibault Wittemberg's avatar Thibault Wittemberg Committed by Aline Bonnet
Browse files

vcard: prevent NPE when vcard has an empty photo

Change-Id: If7d0206eef39a4d309ccaf9a37625feaad008c84
Tuleap: #1143
parent 19352bac
Branches
Tags
No related merge requests found
......@@ -153,7 +153,15 @@ public class ContactDetailsTask implements Runnable {
if (vcard != null && !vcard.getPhotos().isEmpty()) {
Photo tmp = vcard.getPhotos().get(0);
externalBMP = CropImageUtils.cropImageToCircle(tmp.getData());
Bitmap croppedBitmap;
if (tmp != null && tmp.getData() != null) {
croppedBitmap = CropImageUtils.cropImageToCircle(tmp.getData());
} else {
croppedBitmap = decodeSampledBitmapFromResource(mContext.getResources(), R.drawable.ic_contact_picture, mViewWidth, mViewHeight);
}
externalBMP = croppedBitmap != null ? croppedBitmap : decodeSampledBitmapFromResource(mContext.getResources(), R.drawable.ic_contact_picture, mViewWidth, mViewHeight);
} else {
Bitmap photoBmp;
try {
......
......@@ -138,10 +138,14 @@ public class SmartListAdapter extends BaseAdapter {
}
public class ViewHolder {
@BindView(R.id.conv_participant) TextView convParticipants;
@BindView(R.id.conv_last_item) TextView convStatus;
@BindView(R.id.conv_last_time) TextView convTime;
@BindView(R.id.photo) ImageView photo;
@BindView(R.id.conv_participant)
TextView convParticipants;
@BindView(R.id.conv_last_item)
TextView convStatus;
@BindView(R.id.conv_last_time)
TextView convTime;
@BindView(R.id.photo)
ImageView photo;
int position;
public Conversation conv;
......
......@@ -949,7 +949,12 @@ public class CallFragment extends Fragment implements CallInterface, ContactDeta
if (!vcard.getPhotos().isEmpty()) {
Photo tmp = vcard.getPhotos().get(0);
if(tmp.getData() != null) {
contactBubbleView.setImageBitmap(CropImageUtils.cropImageToCircle(tmp.getData()));
}
else{
setDefaultPhoto();
}
} else {
setDefaultPhoto();
}
......
......@@ -36,9 +36,13 @@ public class CropImageUtils {
@Nullable
public static Bitmap cropImageToCircle(@NonNull byte[] bArray) {
Bitmap bitmap = BitmapFactory.decodeByteArray(bArray, 0, bArray.length);
if (bitmap != null) {
return cropImageToCircle(bitmap);
}
return null;
}
@Nullable
public static Bitmap cropImageToCircle(@NonNull Bitmap image) {
int side = Math.min(image.getWidth(), image.getHeight());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment