Skip to content

Commit

Permalink
[fix|build] Fix coil lifecycle not null crash; update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyD666 committed Nov 14, 2024
1 parent 6e06023 commit aa6337c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 10 deletions.
3 changes: 0 additions & 3 deletions app/src/main/java/com/skyd/anivu/ui/component/AniVuImage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import coil3.compose.AsyncImage
import coil3.request.CachePolicy
import coil3.request.ImageRequest
import coil3.request.crossfade
import coil3.request.lifecycle
import coil3.util.DebugLogger
import com.skyd.anivu.ext.imageLoaderBuilder

Expand All @@ -35,10 +34,8 @@ fun AniVuImage(
model
} else {
val context = LocalContext.current
val lifecycleOwner = LocalLifecycleOwner.current
remember(model) {
ImageRequest.Builder(context)
.lifecycle(lifecycleOwner)
.diskCachePolicy(CachePolicy.ENABLED)
.memoryCachePolicy(CachePolicy.ENABLED)
.data(model)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,11 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.TextUnit
import androidx.compose.ui.unit.TextUnitType
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.LocalLifecycleOwner
import coil3.EventListener
import coil3.request.CachePolicy
import coil3.request.ErrorResult
import coil3.request.ImageRequest
import coil3.request.crossfade
import coil3.request.lifecycle
import com.skyd.anivu.R
import com.skyd.anivu.ext.fileSize
import com.skyd.anivu.ext.openWith
Expand Down Expand Up @@ -119,12 +117,10 @@ fun Media1Item(
}
if (data.isMedia && LocalMediaShowThumbnail.current) {
if (showThumbnail) {
val lifecycleOwner = LocalLifecycleOwner.current
AniVuImage(
modifier = Modifier.fillMaxSize(),
model = remember(data.file.path) {
ImageRequest.Builder(context)
.lifecycle(lifecycleOwner)
.diskCachePolicy(CachePolicy.ENABLED)
.memoryCachePolicy(CachePolicy.ENABLED)
.data(data.file.path)
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ kotlin = "2.0.21"
androidx-core-ktx = { module = "androidx.core:core-ktx", version = "1.15.0" }
androidx-appcompat = { module = "androidx.appcompat:appcompat", version = "1.7.0" }
androidx-activity-ktx = { module = "androidx.activity:activity-ktx", version = "1.9.3" }
androidx-constraintlayout-compose = { module = "androidx.constraintlayout:constraintlayout-compose", version = "1.1.0-rc01" }
androidx-constraintlayout-compose = { module = "androidx.constraintlayout:constraintlayout-compose", version = "1.1.0" }
androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version = "2.8.4" }
androidx-lifecycle-runtime-compose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version = "2.8.7" }
androidx-compose-ui = { module = "androidx.compose.ui:ui", version.ref = "composeMaterial" }
Expand All @@ -31,10 +31,10 @@ androidx-room-runtime = { module = "androidx.room:room-runtime", version.ref = "
androidx-room-ktx = { module = "androidx.room:room-ktx", version.ref = "room" }
androidx-room-paging = { module = "androidx.room:room-paging", version.ref = "room" }
androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref = "room" }
androidx-work-runtime-ktx = { module = "androidx.work:work-runtime-ktx", version = "2.9.1" }
androidx-work-runtime-ktx = { module = "androidx.work:work-runtime-ktx", version = "2.10.0" }
androidx-datastore-preferences = { module = "androidx.datastore:datastore-preferences", version = "1.1.1" }
androidx-core-splashscreen = { module = "androidx.core:core-splashscreen", version = "1.0.1" }
androidx-paging-compose = { module = "androidx.paging:paging-compose", version = "3.3.2" }
androidx-paging-compose = { module = "androidx.paging:paging-compose", version = "3.3.4" }
androidx-hilt-navigation-compose = { module = "androidx.hilt:hilt-navigation-compose", version = "1.2.0" }
androidx-profileinstaller = { module = "androidx.profileinstaller:profileinstaller", version = "1.4.1" }

Expand Down

0 comments on commit aa6337c

Please sign in to comment.