Use `buildList` in `secondsToString` in `MainActivity`

This commit is contained in:
Ensar Sarajčić 2023-10-13 11:29:30 +02:00
parent 1600a072ef
commit 7533ad1fa2
1 changed files with 11 additions and 11 deletions

View File

@ -369,17 +369,17 @@ class MainActivity : ComponentActivity() {
val finalHours = seconds / 3600
val finalMinutes = (seconds / 60) % 60
val finalSeconds = seconds % 60
val parts = mutableListOf<String>()
if (finalHours != 0) {
parts.add(resources.getQuantityString(com.simplemobiletools.commons.R.plurals.hours, finalHours, finalHours))
}
if (finalMinutes != 0) {
parts.add(resources.getQuantityString(com.simplemobiletools.commons.R.plurals.minutes, finalMinutes, finalMinutes))
}
if (finalSeconds != 0) {
parts.add(resources.getQuantityString(com.simplemobiletools.commons.R.plurals.seconds, finalSeconds, finalSeconds))
}
return parts.joinToString(separator = " ")
return buildList {
if (finalHours != 0) {
add(resources.getQuantityString(com.simplemobiletools.commons.R.plurals.hours, finalHours, finalHours))
}
if (finalMinutes != 0) {
add(resources.getQuantityString(com.simplemobiletools.commons.R.plurals.minutes, finalMinutes, finalMinutes))
}
if (finalSeconds != 0) {
add(resources.getQuantityString(com.simplemobiletools.commons.R.plurals.seconds, finalSeconds, finalSeconds))
}
}.joinToString(separator = " ")
}
private fun pickedSleepTimer(seconds: Int) {