From 8fa1320afeadab6a1b5137303cc126488654ad69 Mon Sep 17 00:00:00 2001 From: Conny Duck Date: Mon, 15 Jan 2018 17:06:21 +0100 Subject: [PATCH] prevent crash in NotificationsAdapter when avatar url is not set --- .../tusky/adapter/NotificationsAdapter.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/NotificationsAdapter.java b/app/src/main/java/com/keylesspalace/tusky/adapter/NotificationsAdapter.java index 8eb36187..947b7cc8 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/NotificationsAdapter.java +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/NotificationsAdapter.java @@ -264,12 +264,16 @@ public class NotificationsAdapter extends RecyclerView.Adapter { displayNameView.setText(displayName); - Picasso.with(context) - .load(avatarUrl) - .fit() - .transform(new RoundedTransformation(7, 0)) - .placeholder(R.drawable.avatar_default) - .into(avatar); + if (TextUtils.isEmpty(avatarUrl)) { + avatar.setImageResource(R.drawable.avatar_default); + } else { + Picasso.with(context) + .load(avatarUrl) + .fit() + .transform(new RoundedTransformation(7, 0)) + .placeholder(R.drawable.avatar_default) + .into(avatar); + } } void setupButtons(final NotificationActionListener listener, final String accountId) { @@ -407,7 +411,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter { void setAvatars(@Nullable String statusAvatarUrl, @Nullable String notificationAvatarUrl) { Context context = statusAvatar.getContext(); - if (statusAvatarUrl == null || statusAvatarUrl.isEmpty()) { + if (TextUtils.isEmpty(statusAvatarUrl)) { statusAvatar.setImageResource(R.drawable.avatar_default); } else { Picasso.with(context) @@ -417,7 +421,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter { .into(statusAvatar); } - if (notificationAvatarUrl == null || notificationAvatarUrl.isEmpty()) { + if (TextUtils.isEmpty(notificationAvatarUrl)) { notificationAvatar.setImageResource(R.drawable.avatar_default); } else { Picasso.with(context)