Add cache usage for Glide.
This commit is contained in:
parent
20a7811602
commit
22abe55fce
1 changed files with 40 additions and 9 deletions
|
|
@ -6,12 +6,18 @@ import androidx.activity.compose.setContent
|
|||
import androidx.activity.viewModels
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Surface
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
||||
import androidx.core.view.WindowCompat
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.pixelized.biblib.ui.composable.SystemThemeColor
|
||||
import com.pixelized.biblib.ui.navigation.ScreenNavHost
|
||||
import com.pixelized.biblib.ui.screen.launch.LauncherViewModel
|
||||
import com.pixelized.biblib.ui.theme.BibLibTheme
|
||||
import com.skydoves.landscapist.glide.LocalGlideRequestOptions
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
|
||||
|
||||
|
|
@ -35,18 +41,43 @@ class MainActivity : ComponentActivity() {
|
|||
|
||||
// Compose
|
||||
setContent {
|
||||
BibLibTheme {
|
||||
SystemThemeColor {
|
||||
Surface(color = MaterialTheme.colors.background) {
|
||||
// Handle the main Navigation
|
||||
if (launcherViewModel.isLoadingDone) {
|
||||
ScreenNavHost(
|
||||
startDestination = launcherViewModel.startDestination
|
||||
)
|
||||
}
|
||||
BibLibActivityTheme {
|
||||
ProvideGlideOption {
|
||||
// Handle the main Navigation
|
||||
if (launcherViewModel.isLoadingDone) {
|
||||
ScreenNavHost(
|
||||
startDestination = launcherViewModel.startDestination
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun BibLibActivityTheme(
|
||||
background: Color = MaterialTheme.colors.background,
|
||||
content: @Composable () -> Unit,
|
||||
) {
|
||||
BibLibTheme {
|
||||
SystemThemeColor {
|
||||
Surface(
|
||||
color = background,
|
||||
content = content,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ProvideGlideOption(
|
||||
options: RequestOptions = RequestOptions().diskCacheStrategy(DiskCacheStrategy.ALL),
|
||||
content: @Composable () -> Unit,
|
||||
) {
|
||||
CompositionLocalProvider(
|
||||
LocalGlideRequestOptions provides options,
|
||||
) {
|
||||
content()
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue