From fcd2d63df47709a1e96c79f12f67247c02839aa1 Mon Sep 17 00:00:00 2001 From: Stypox Date: Fri, 31 Dec 2021 18:38:35 +0100 Subject: [PATCH] Don't show any channel notification thumbnail if it could not be loaded --- .../newpipe/local/feed/notifications/NotificationHelper.kt | 4 ++-- app/src/main/java/org/schabi/newpipe/util/PicassoHelper.java | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/feed/notifications/NotificationHelper.kt b/app/src/main/java/org/schabi/newpipe/local/feed/notifications/NotificationHelper.kt index e61db1dfa..8ce59b14a 100644 --- a/app/src/main/java/org/schabi/newpipe/local/feed/notifications/NotificationHelper.kt +++ b/app/src/main/java/org/schabi/newpipe/local/feed/notifications/NotificationHelper.kt @@ -84,8 +84,8 @@ class NotificationHelper(val context: Context) { ) ) - PicassoHelper.loadNotificationIcon(data.avatarUrl, context) { bitmap -> - builder.setLargeIcon(bitmap) + PicassoHelper.loadNotificationIcon(data.avatarUrl) { bitmap -> + bitmap?.let { builder.setLargeIcon(it) } // set only if != null manager.notify(data.pseudoId, builder.build()) } } diff --git a/app/src/main/java/org/schabi/newpipe/util/PicassoHelper.java b/app/src/main/java/org/schabi/newpipe/util/PicassoHelper.java index d5552ae65..9e157f458 100644 --- a/app/src/main/java/org/schabi/newpipe/util/PicassoHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/PicassoHelper.java @@ -5,7 +5,6 @@ import static org.schabi.newpipe.extractor.utils.Utils.isBlank; import android.annotation.SuppressLint; import android.content.Context; import android.graphics.Bitmap; -import android.graphics.BitmapFactory; import android.graphics.drawable.Drawable; import com.squareup.picasso.Cache; @@ -165,7 +164,6 @@ public final class PicassoHelper { public static void loadNotificationIcon(final String url, - final Context context, final Consumer bitmapConsumer) { loadImageDefault(url, R.drawable.ic_newpipe_triangle_white) .into(new Target() { @@ -176,8 +174,7 @@ public final class PicassoHelper { @Override public void onBitmapFailed(final Exception e, final Drawable errorDrawable) { - bitmapConsumer.accept(BitmapFactory.decodeResource(context.getResources(), - R.drawable.ic_newpipe_triangle_white)); + bitmapConsumer.accept(null); } @Override