Simplified changeColumnCount items array creating

This commit is contained in:
merkost 2023-07-22 22:43:15 +10:00
parent e3697eb349
commit 4ab95c4bb3
1 changed files with 4 additions and 3 deletions

View File

@ -248,12 +248,13 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
} }
private fun changeColumnCount() { private fun changeColumnCount() {
val items = (1..CONTACTS_GRID_MAX_COLUMNS_COUNT).map { val items = ArrayList<RadioItem>()
RadioItem(it, resources.getQuantityString(R.plurals.column_counts, it, it)) for (i in 1..CONTACTS_GRID_MAX_COLUMNS_COUNT) {
items.add(RadioItem(i, resources.getQuantityString(R.plurals.column_counts, i, i)))
} }
val currentColumnCount = config.contactsGridColumnCount val currentColumnCount = config.contactsGridColumnCount
RadioGroupDialog(this, ArrayList(items), currentColumnCount) { RadioGroupDialog(this, items, currentColumnCount) {
val newColumnCount = it as Int val newColumnCount = it as Int
if (currentColumnCount != newColumnCount) { if (currentColumnCount != newColumnCount) {
config.contactsGridColumnCount = newColumnCount config.contactsGridColumnCount = newColumnCount