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 finalHours = seconds / 3600
val finalMinutes = (seconds / 60) % 60 val finalMinutes = (seconds / 60) % 60
val finalSeconds = seconds % 60 val finalSeconds = seconds % 60
val parts = mutableListOf<String>() return buildList {
if (finalHours != 0) { if (finalHours != 0) {
parts.add(resources.getQuantityString(com.simplemobiletools.commons.R.plurals.hours, finalHours, finalHours)) add(resources.getQuantityString(com.simplemobiletools.commons.R.plurals.hours, finalHours, finalHours))
} }
if (finalMinutes != 0) { if (finalMinutes != 0) {
parts.add(resources.getQuantityString(com.simplemobiletools.commons.R.plurals.minutes, finalMinutes, finalMinutes)) add(resources.getQuantityString(com.simplemobiletools.commons.R.plurals.minutes, finalMinutes, finalMinutes))
} }
if (finalSeconds != 0) { if (finalSeconds != 0) {
parts.add(resources.getQuantityString(com.simplemobiletools.commons.R.plurals.seconds, finalSeconds, finalSeconds)) add(resources.getQuantityString(com.simplemobiletools.commons.R.plurals.seconds, finalSeconds, finalSeconds))
} }
return parts.joinToString(separator = " ") }.joinToString(separator = " ")
} }
private fun pickedSleepTimer(seconds: Int) { private fun pickedSleepTimer(seconds: Int) {