Don't show any channel notification thumbnail if it could not be loaded

This commit is contained in:
Stypox 2021-12-31 18:38:35 +01:00
parent e68d49e7df
commit fcd2d63df4
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
2 changed files with 3 additions and 6 deletions

View File

@ -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())
}
}

View File

@ -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<Bitmap> 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