From 77256eb3c05884d34f1b2be5dac7bdbd187bafe7 Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Thu, 26 Mar 2020 10:24:18 -0300 Subject: [PATCH] [FIX] Check if avatar exists before create Icon (#1927) Co-authored-by: Diego Mello --- .../reactnative/CustomPushNotification.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/android/app/src/main/java/chat/rocket/reactnative/CustomPushNotification.java b/android/app/src/main/java/chat/rocket/reactnative/CustomPushNotification.java index dd2022687..17002faa0 100644 --- a/android/app/src/main/java/chat/rocket/reactnative/CustomPushNotification.java +++ b/android/app/src/main/java/chat/rocket/reactnative/CustomPushNotification.java @@ -237,12 +237,19 @@ public class CustomPushNotification extends PushNotification { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) { messageStyle.addMessage(m, timestamp, username); } else { - Person sender = new Person.Builder() + Bitmap avatar = getAvatar(avatarUri); + + Person.Builder sender = new Person.Builder() .setKey(senderId) - .setName(username) - .setIcon(Icon.createWithBitmap(getAvatar(avatarUri))) - .build(); - messageStyle.addMessage(m, timestamp, sender); + .setName(username); + + if (avatar != null) { + sender.setIcon(Icon.createWithBitmap(avatar)); + } + + Person person = sender.build(); + + messageStyle.addMessage(m, timestamp, person); } } }