Don't attempt to show non-bitmap image in notification when saving

Fixes #9758
This commit is contained in:
arkon 2023-07-26 23:09:16 -04:00
parent 8ff0c9d61a
commit 77bfd0c099

View file

@ -35,12 +35,8 @@ class SaveImageNotifier(private val context: Context) {
.memoryCachePolicy(CachePolicy.DISABLED) .memoryCachePolicy(CachePolicy.DISABLED)
.size(720, 1280) .size(720, 1280)
.target( .target(
onSuccess = { result -> onSuccess = { showCompleteNotification(uri, (it as? BitmapDrawable)?.bitmap) },
showCompleteNotification(uri, (result as BitmapDrawable).bitmap) onError = { onError(null) },
},
onError = {
onError(null)
},
) )
.build() .build()
context.imageLoader.enqueue(request) context.imageLoader.enqueue(request)
@ -67,11 +63,11 @@ class SaveImageNotifier(private val context: Context) {
updateNotification() updateNotification()
} }
private fun showCompleteNotification(uri: Uri, image: Bitmap) { private fun showCompleteNotification(uri: Uri, image: Bitmap?) {
with(notificationBuilder) { with(notificationBuilder) {
setContentTitle(context.getString(R.string.picture_saved)) setContentTitle(context.getString(R.string.picture_saved))
setSmallIcon(R.drawable.ic_photo_24dp) setSmallIcon(R.drawable.ic_photo_24dp)
setStyle(NotificationCompat.BigPictureStyle().bigPicture(image)) image?.let { setStyle(NotificationCompat.BigPictureStyle().bigPicture(it)) }
setLargeIcon(image) setLargeIcon(image)
setAutoCancel(true) setAutoCancel(true)