From cfda150630a1f9b74953c7b998d8364d84703a7c Mon Sep 17 00:00:00 2001 From: Koitharu Date: Mon, 2 Oct 2023 15:22:35 +0300 Subject: [PATCH] Fix crash on request pin shortcut --- .../koitharu/kotatsu/core/os/AppShortcutManager.kt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/os/AppShortcutManager.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/os/AppShortcutManager.kt index e58b34878..8c92b6b3e 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/os/AppShortcutManager.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/os/AppShortcutManager.kt @@ -76,12 +76,18 @@ class AppShortcutManager @Inject constructor( } } - suspend fun requestPinShortcut(manga: Manga): Boolean { - return ShortcutManagerCompat.requestPinShortcut(context, buildShortcutInfo(manga), null) + suspend fun requestPinShortcut(manga: Manga): Boolean = try { + ShortcutManagerCompat.requestPinShortcut(context, buildShortcutInfo(manga), null) + } catch (e: IllegalStateException) { + e.printStackTraceDebug() + false } - suspend fun requestPinShortcut(source: MangaSource): Boolean { - return ShortcutManagerCompat.requestPinShortcut(context, buildShortcutInfo(source), null) + suspend fun requestPinShortcut(source: MangaSource): Boolean = try { + ShortcutManagerCompat.requestPinShortcut(context, buildShortcutInfo(source), null) + } catch (e: IllegalStateException) { + e.printStackTraceDebug() + false } @VisibleForTesting