From 7fea27b299a91079305c4a86ca837545f6f96aca Mon Sep 17 00:00:00 2001 From: Bnyro Date: Fri, 19 Aug 2022 15:15:27 +0200 Subject: [PATCH] fix options dialog crash --- .../github/libretube/dialogs/VideoOptionsDialog.kt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/github/libretube/dialogs/VideoOptionsDialog.kt b/app/src/main/java/com/github/libretube/dialogs/VideoOptionsDialog.kt index 9f007bd79..688e76a95 100644 --- a/app/src/main/java/com/github/libretube/dialogs/VideoOptionsDialog.kt +++ b/app/src/main/java/com/github/libretube/dialogs/VideoOptionsDialog.kt @@ -39,12 +39,16 @@ class VideoOptionsDialog( /** * Check whether the player is running by observing the notification */ - val notificationManager = - context?.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager - notificationManager.activeNotifications.forEach { - if (it.id == PLAYER_NOTIFICATION_ID) { - optionsList += context?.getString(R.string.add_to_queue) + try { + val notificationManager = + context?.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager + notificationManager.activeNotifications.forEach { + if (it.id == PLAYER_NOTIFICATION_ID) { + optionsList += context?.getString(R.string.add_to_queue) + } } + } catch (e: Exception) { + e.printStackTrace() } return MaterialAlertDialogBuilder(requireContext())