1
0
mirror of https://github.com/TeamNewPipe/NewPipe/ synced 2024-12-11 17:15:47 +01:00

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 -> PicassoHelper.loadNotificationIcon(data.avatarUrl) { bitmap ->
builder.setLargeIcon(bitmap) bitmap?.let { builder.setLargeIcon(it) } // set only if != null
manager.notify(data.pseudoId, builder.build()) 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.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import com.squareup.picasso.Cache; import com.squareup.picasso.Cache;
@ -165,7 +164,6 @@ public final class PicassoHelper {
public static void loadNotificationIcon(final String url, public static void loadNotificationIcon(final String url,
final Context context,
final Consumer<Bitmap> bitmapConsumer) { final Consumer<Bitmap> bitmapConsumer) {
loadImageDefault(url, R.drawable.ic_newpipe_triangle_white) loadImageDefault(url, R.drawable.ic_newpipe_triangle_white)
.into(new Target() { .into(new Target() {
@ -176,8 +174,7 @@ public final class PicassoHelper {
@Override @Override
public void onBitmapFailed(final Exception e, final Drawable errorDrawable) { public void onBitmapFailed(final Exception e, final Drawable errorDrawable) {
bitmapConsumer.accept(BitmapFactory.decodeResource(context.getResources(), bitmapConsumer.accept(null);
R.drawable.ic_newpipe_triangle_white));
} }
@Override @Override