use formatTime function

This commit is contained in:
LuftVerbot 2023-11-26 13:43:13 +01:00
parent df6a85a944
commit 4baf786d57

View file

@ -936,8 +936,8 @@ private fun LazyListScope.sharedEpisodeItems(
?.let { ?.let {
stringResource( stringResource(
R.string.episode_progress, R.string.episode_progress,
formatProgress(it), formatTime(it),
formatProgress(item.episode.totalSeconds), formatTime(item.episode.totalSeconds),
) )
}, },
scanlator = item.episode.scanlator.takeIf { !it.isNullOrBlank() }, scanlator = item.episode.scanlator.takeIf { !it.isNullOrBlank() },
@ -975,26 +975,6 @@ private fun LazyListScope.sharedEpisodeItems(
} }
} }
private fun formatProgress(milliseconds: Long): String {
return if (milliseconds > 3600000L) {
String.format(
"%d:%02d:%02d",
TimeUnit.MILLISECONDS.toHours(milliseconds),
TimeUnit.MILLISECONDS.toMinutes(milliseconds) -
TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(milliseconds)),
TimeUnit.MILLISECONDS.toSeconds(milliseconds) -
TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(milliseconds)),
)
} else {
String.format(
"%d:%02d",
TimeUnit.MILLISECONDS.toMinutes(milliseconds),
TimeUnit.MILLISECONDS.toSeconds(milliseconds) -
TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(milliseconds)),
)
}
}
private fun onEpisodeItemClick( private fun onEpisodeItemClick(
episodeItem: EpisodeList.Item, episodeItem: EpisodeList.Item,
isAnyEpisodeSelected: Boolean, isAnyEpisodeSelected: Boolean,