From 77bfd0c0999573315af7d29268e69e918bbfb009 Mon Sep 17 00:00:00 2001 From: arkon Date: Wed, 26 Jul 2023 23:09:16 -0400 Subject: [PATCH] Don't attempt to show non-bitmap image in notification when saving Fixes #9758 --- .../kanade/tachiyomi/ui/reader/SaveImageNotifier.kt | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/SaveImageNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/SaveImageNotifier.kt index 24a6441a1..574cd1cab 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/SaveImageNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/SaveImageNotifier.kt @@ -35,12 +35,8 @@ class SaveImageNotifier(private val context: Context) { .memoryCachePolicy(CachePolicy.DISABLED) .size(720, 1280) .target( - onSuccess = { result -> - showCompleteNotification(uri, (result as BitmapDrawable).bitmap) - }, - onError = { - onError(null) - }, + onSuccess = { showCompleteNotification(uri, (it as? BitmapDrawable)?.bitmap) }, + onError = { onError(null) }, ) .build() context.imageLoader.enqueue(request) @@ -67,11 +63,11 @@ class SaveImageNotifier(private val context: Context) { updateNotification() } - private fun showCompleteNotification(uri: Uri, image: Bitmap) { + private fun showCompleteNotification(uri: Uri, image: Bitmap?) { with(notificationBuilder) { setContentTitle(context.getString(R.string.picture_saved)) setSmallIcon(R.drawable.ic_photo_24dp) - setStyle(NotificationCompat.BigPictureStyle().bigPicture(image)) + image?.let { setStyle(NotificationCompat.BigPictureStyle().bigPicture(it)) } setLargeIcon(image) setAutoCancel(true)