From 804ae552e575e25cf22e51e3ffa756383435e845 Mon Sep 17 00:00:00 2001 From: SkyD666 Date: Wed, 28 Aug 2024 23:47:46 +0800 Subject: [PATCH] [optimize] Optimize download percentage and speed text alignment --- app/build.gradle.kts | 2 +- .../anivu/ui/screen/article/ArticlePartialStateChange.kt | 6 +++--- .../com/skyd/anivu/ui/screen/download/DownloadItem.kt | 9 +++++++-- .../com/skyd/anivu/ui/screen/media/list/Media1Item.kt | 3 +++ 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 1dcd006b..0ec5acc1 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -22,7 +22,7 @@ android { minSdk = 24 targetSdk = 35 versionCode = 22 - versionName = "2.1-alpha23" + versionName = "2.1-alpha24" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" diff --git a/app/src/main/java/com/skyd/anivu/ui/screen/article/ArticlePartialStateChange.kt b/app/src/main/java/com/skyd/anivu/ui/screen/article/ArticlePartialStateChange.kt index 76919035..2696cfd3 100644 --- a/app/src/main/java/com/skyd/anivu/ui/screen/article/ArticlePartialStateChange.kt +++ b/app/src/main/java/com/skyd/anivu/ui/screen/article/ArticlePartialStateChange.kt @@ -34,9 +34,9 @@ internal sealed interface ArticlePartialStateChange { Loading -> oldState.copy( articleListState = oldState.articleListState.let { when (it) { - is ArticleListState.Failed -> it.copy(loading = false) - is ArticleListState.Init -> it.copy(loading = false) - is ArticleListState.Success -> it.copy(loading = false) + is ArticleListState.Failed -> it.copy(loading = true) + is ArticleListState.Init -> it.copy(loading = true) + is ArticleListState.Success -> it.copy(loading = true) } }, loadingDialog = false, diff --git a/app/src/main/java/com/skyd/anivu/ui/screen/download/DownloadItem.kt b/app/src/main/java/com/skyd/anivu/ui/screen/download/DownloadItem.kt index 744fcdec..a1f988e3 100644 --- a/app/src/main/java/com/skyd/anivu/ui/screen/download/DownloadItem.kt +++ b/app/src/main/java/com/skyd/anivu/ui/screen/download/DownloadItem.kt @@ -137,13 +137,16 @@ fun DownloadItem( Spacer(modifier = Modifier.height(6.dp)) Row { Text( + modifier = Modifier.alignByBaseline(), text = data.progress.toPercentage(), style = MaterialTheme.typography.labelMedium, maxLines = 1, overflow = TextOverflow.Ellipsis, ) Text( - modifier = Modifier.padding(start = 12.dp), + modifier = Modifier + .padding(start = 12.dp) + .alignByBaseline(), text = stringResource( R.string.download_download_payload_rate, data.downloadPayloadRate.toLong().fileSize(context) + "/s" @@ -153,7 +156,9 @@ fun DownloadItem( overflow = TextOverflow.Ellipsis, ) Text( - modifier = Modifier.padding(start = 12.dp), + modifier = Modifier + .padding(start = 12.dp) + .alignByBaseline(), text = stringResource( R.string.download_upload_payload_rate, data.uploadPayloadRate.toLong().fileSize(context) + "/s" diff --git a/app/src/main/java/com/skyd/anivu/ui/screen/media/list/Media1Item.kt b/app/src/main/java/com/skyd/anivu/ui/screen/media/list/Media1Item.kt index a4c46710..433fd0a1 100644 --- a/app/src/main/java/com/skyd/anivu/ui/screen/media/list/Media1Item.kt +++ b/app/src/main/java/com/skyd/anivu/ui/screen/media/list/Media1Item.kt @@ -41,6 +41,7 @@ import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.LocalLifecycleOwner import coil.EventListener import coil.decode.VideoFrameDecoder +import coil.request.CachePolicy import coil.request.ErrorResult import coil.request.ImageRequest import coil.request.videoFramePercent @@ -123,6 +124,8 @@ fun Media1Item( model = remember(data.file.path) { ImageRequest.Builder(context) .lifecycle(lifecycleOwner) + .diskCachePolicy(CachePolicy.ENABLED) + .memoryCachePolicy(CachePolicy.ENABLED) .data(data.file.path) .videoFramePercent(0.5) .crossfade(true)