Skip to content

Commit 3a48e33

Browse files
committed
Cache immutable value
1 parent 6f577d8 commit 3a48e33

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

vector/src/main/java/im/vector/app/features/home/ShortcutsHandler.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class ShortcutsHandler @Inject constructor(
3939
private val activeSessionHolder: ActiveSessionHolder,
4040
private val pinCodeStore: PinCodeStore
4141
) {
42+
private val isRequestPinShortcutSupported = ShortcutManagerCompat.isRequestPinShortcutSupported(context)
4243

4344
fun observeRoomsAndBuildShortcuts(): Disposable {
4445
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) {
@@ -71,7 +72,7 @@ class ShortcutsHandler @Inject constructor(
7172
if (deadShortcutIds.isNotEmpty()) {
7273
Timber.d("Removing shortcut(s) $deadShortcutIds")
7374
ShortcutManagerCompat.removeLongLivedShortcuts(context, deadShortcutIds)
74-
if (ShortcutManagerCompat.isRequestPinShortcutSupported(context)) {
75+
if (isRequestPinShortcutSupported) {
7576
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
7677
context.getSystemService<ShortcutManager>()?.disableShortcuts(deadShortcutIds)
7778
}
@@ -107,7 +108,7 @@ class ShortcutsHandler @Inject constructor(
107108
ShortcutManagerCompat.removeLongLivedShortcuts(context, shortcuts)
108109

109110
// We can only disabled pinned shortcuts with the API, but at least it will prevent the crash
110-
if (ShortcutManagerCompat.isRequestPinShortcutSupported(context)) {
111+
if (isRequestPinShortcutSupported) {
111112
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
112113
context.getSystemService<ShortcutManager>()
113114
?.let {

0 commit comments

Comments
 (0)