Skip to content

Commit

Permalink
[optimize] Optimize download percentage and speed text alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyD666 committed Aug 28, 2024
1 parent 505713c commit 804ae55
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ android {
minSdk = 24
targetSdk = 35
versionCode = 22
versionName = "2.1-alpha23"
versionName = "2.1-alpha24"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 804ae55

Please sign in to comment.