From 633e8358172b6eb179f25d043eb2dc41b18457f9 Mon Sep 17 00:00:00 2001 From: IacobIonut01 Date: Sat, 11 Jan 2025 15:23:10 +0200 Subject: [PATCH] Fix Shimmer crashing on API 31 Fixes [BUG] app crahes when opening any Album #563 Signed-off-by: IacobIonut01 --- .../dot/gallery/core/presentation/components/LoadingAlbum.kt | 4 +++- .../dot/gallery/core/presentation/components/LoadingMedia.kt | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/dot/gallery/core/presentation/components/LoadingAlbum.kt b/app/src/main/kotlin/com/dot/gallery/core/presentation/components/LoadingAlbum.kt index 0df319096..8d68407be 100644 --- a/app/src/main/kotlin/com/dot/gallery/core/presentation/components/LoadingAlbum.kt +++ b/app/src/main/kotlin/com/dot/gallery/core/presentation/components/LoadingAlbum.kt @@ -5,6 +5,7 @@ package com.dot.gallery.core.presentation.components +import android.os.Build import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box @@ -36,12 +37,13 @@ fun LoadingAlbum( val gridSize by rememberAlbumGridSize() val grid = remember(gridSize) { albumCellsList.size - gridSize } val shape = remember { RoundedCornerShape(16.dp) } + val canShimmer = remember { Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU } Column( modifier = modifier .fillMaxSize() .padding(horizontal = 16.dp) .padding(top = 48.dp) - .then(if (shouldShimmer) Modifier.shimmer() else Modifier), + .then(if (shouldShimmer && canShimmer) Modifier.shimmer() else Modifier), verticalArrangement = Arrangement.spacedBy(8.dp), ) { repeat(2) { diff --git a/app/src/main/kotlin/com/dot/gallery/core/presentation/components/LoadingMedia.kt b/app/src/main/kotlin/com/dot/gallery/core/presentation/components/LoadingMedia.kt index 2cdffe9b9..1079479d1 100644 --- a/app/src/main/kotlin/com/dot/gallery/core/presentation/components/LoadingMedia.kt +++ b/app/src/main/kotlin/com/dot/gallery/core/presentation/components/LoadingMedia.kt @@ -5,6 +5,7 @@ package com.dot.gallery.core.presentation.components +import android.os.Build import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box @@ -39,10 +40,11 @@ fun LoadingMedia( ) { val gridSize by rememberGridSize() val grid = remember(gridSize) { cellsList.size - gridSize } + val canShimmer = remember { Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU } Column( modifier = modifier .fillMaxSize() - .then(if (shouldShimmer) Modifier.shimmer() else Modifier), + .then(if (shouldShimmer && canShimmer) Modifier.shimmer() else Modifier), verticalArrangement = Arrangement.spacedBy(1.dp), ) { if (topContent != null) {