mirror of
https://github.com/Myzel394/Alibi.git
synced 2025-06-18 14:55:26 +02:00
fix: Improve formatDuration
This commit is contained in:
parent
a8cb592632
commit
f131f40ba1
@ -92,9 +92,7 @@ fun MaxDurationTile() {
|
||||
),
|
||||
shape = MaterialTheme.shapes.medium,
|
||||
) {
|
||||
Text(
|
||||
text = formatDuration(settings.audioRecorderSettings.maxDuration),
|
||||
)
|
||||
Text(formatDuration(settings.audioRecorderSettings.maxDuration))
|
||||
}
|
||||
},
|
||||
extra = {
|
||||
@ -102,9 +100,7 @@ fun MaxDurationTile() {
|
||||
items = AudioRecorderSettings.EXAMPLE_MAX_DURATIONS,
|
||||
onItemSelected = ::updateValue,
|
||||
) {maxDuration ->
|
||||
Text(
|
||||
text = formatDuration(maxDuration),
|
||||
)
|
||||
Text(formatDuration(maxDuration))
|
||||
}
|
||||
}
|
||||
)
|
||||
|
@ -11,7 +11,7 @@ fun formatDuration(
|
||||
|
||||
val hours = floor(totalSeconds / 3600.0).toInt()
|
||||
val minutes = floor(totalSeconds / 60.0).toInt() % 60
|
||||
val seconds = totalSeconds - (minutes * 60)
|
||||
val seconds = totalSeconds - (minutes * 60) - (hours * 3600)
|
||||
|
||||
if (formatFull) {
|
||||
return "" +
|
||||
@ -29,5 +29,12 @@ fun formatDuration(
|
||||
return "00:${totalSeconds.toString().padStart(2, '0')}"
|
||||
}
|
||||
|
||||
return "${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}"
|
||||
if (hours <= 0) {
|
||||
return "${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}"
|
||||
}
|
||||
|
||||
return "" +
|
||||
hours.toString().padStart(2, '0') +
|
||||
":" + minutes.toString().padStart(2, '0') +
|
||||
":" + seconds.toString().padStart(2, '0')
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user