mirror of
https://github.com/Myzel394/Alibi.git
synced 2025-06-18 23:05: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,
|
shape = MaterialTheme.shapes.medium,
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(formatDuration(settings.audioRecorderSettings.maxDuration))
|
||||||
text = formatDuration(settings.audioRecorderSettings.maxDuration),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
extra = {
|
extra = {
|
||||||
@ -102,9 +100,7 @@ fun MaxDurationTile() {
|
|||||||
items = AudioRecorderSettings.EXAMPLE_MAX_DURATIONS,
|
items = AudioRecorderSettings.EXAMPLE_MAX_DURATIONS,
|
||||||
onItemSelected = ::updateValue,
|
onItemSelected = ::updateValue,
|
||||||
) {maxDuration ->
|
) {maxDuration ->
|
||||||
Text(
|
Text(formatDuration(maxDuration))
|
||||||
text = formatDuration(maxDuration),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -11,7 +11,7 @@ fun formatDuration(
|
|||||||
|
|
||||||
val hours = floor(totalSeconds / 3600.0).toInt()
|
val hours = floor(totalSeconds / 3600.0).toInt()
|
||||||
val minutes = floor(totalSeconds / 60.0).toInt() % 60
|
val minutes = floor(totalSeconds / 60.0).toInt() % 60
|
||||||
val seconds = totalSeconds - (minutes * 60)
|
val seconds = totalSeconds - (minutes * 60) - (hours * 3600)
|
||||||
|
|
||||||
if (formatFull) {
|
if (formatFull) {
|
||||||
return "" +
|
return "" +
|
||||||
@ -29,5 +29,12 @@ fun formatDuration(
|
|||||||
return "00:${totalSeconds.toString().padStart(2, '0')}"
|
return "00:${totalSeconds.toString().padStart(2, '0')}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hours <= 0) {
|
||||||
return "${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '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