Add a glidemodule to help with config

This commit is contained in:
Thomas Andres Gomez 2023-09-27 09:54:23 +02:00
parent e8504c3b52
commit 08f234dc44

View file

@ -1,15 +1,30 @@
package com.pixelized.rplexicon.utilitary
import android.content.Context
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.Stable
import androidx.compose.runtime.State
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableFloatStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.platform.LocalView
import com.bumptech.glide.GlideBuilder
import com.bumptech.glide.annotation.GlideModule
import com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory
import com.bumptech.glide.module.AppGlideModule
@GlideModule
class LexiconGlideModule : AppGlideModule() {
override fun applyOptions(context: Context, builder: GlideBuilder) {
val diskCacheSizeBytes = 1024 * 1024 * 100 // 100 MB
builder.setDiskCache(InternalCacheDiskCacheFactory(context, diskCacheSizeBytes.toLong()))
}
}
@Stable
class GlideLoadingTransition(
@ -27,14 +42,14 @@ fun rememberLoadingTransition(model: () -> Any?): GlideLoadingTransition {
return if (isInEditMode) {
remember {
GlideLoadingTransition(
target = mutableStateOf(1f),
alpha = mutableStateOf(1f),
target = mutableFloatStateOf(1f),
alpha = mutableFloatStateOf(1f),
)
}
} else {
val key = model()
val target = remember(key) {
mutableStateOf(0f)
mutableFloatStateOf(0f)
}
val alpha = animateFloatAsState(
targetValue = target.value,