From 3a48e33c812662ef188ee7872b86f134c5c59630 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 27 Oct 2021 15:26:31 +0200 Subject: [PATCH] Cache immutable value --- .../java/im/vector/app/features/home/ShortcutsHandler.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/ShortcutsHandler.kt b/vector/src/main/java/im/vector/app/features/home/ShortcutsHandler.kt index 005ca30845..d7e1122246 100644 --- a/vector/src/main/java/im/vector/app/features/home/ShortcutsHandler.kt +++ b/vector/src/main/java/im/vector/app/features/home/ShortcutsHandler.kt @@ -39,6 +39,7 @@ class ShortcutsHandler @Inject constructor( private val activeSessionHolder: ActiveSessionHolder, private val pinCodeStore: PinCodeStore ) { + private val isRequestPinShortcutSupported = ShortcutManagerCompat.isRequestPinShortcutSupported(context) fun observeRoomsAndBuildShortcuts(): Disposable { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) { @@ -71,7 +72,7 @@ class ShortcutsHandler @Inject constructor( if (deadShortcutIds.isNotEmpty()) { Timber.d("Removing shortcut(s) $deadShortcutIds") ShortcutManagerCompat.removeLongLivedShortcuts(context, deadShortcutIds) - if (ShortcutManagerCompat.isRequestPinShortcutSupported(context)) { + if (isRequestPinShortcutSupported) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { context.getSystemService()?.disableShortcuts(deadShortcutIds) } @@ -107,7 +108,7 @@ class ShortcutsHandler @Inject constructor( ShortcutManagerCompat.removeLongLivedShortcuts(context, shortcuts) // We can only disabled pinned shortcuts with the API, but at least it will prevent the crash - if (ShortcutManagerCompat.isRequestPinShortcutSupported(context)) { + if (isRequestPinShortcutSupported) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { context.getSystemService() ?.let {