Untitled
unknown
plain_text
a month ago
2.2 kB
2
Indexable
Never
private fun buildItems(): List<Group> { val done = items.filter { it.status == NewBuildingProgressStatus.DONE } val development = items.filter { it.status == NewBuildingProgressStatus.DEVELOPMENT } val wait = items.filter { it.status == NewBuildingProgressStatus.WAIT } val items = mutableListOf<NewBuildingProgress>() if (development.isEmpty() && wait.isEmpty()) { items.addAll(done.take(MAX_DISPLAY_ITEM)) } else { if (development.isNotEmpty()) { if (done.isNotEmpty()) { if (done.size > 1) { items.addAll(done.take(2)) items.add(development.first()) } else { items.add(done.first()) if (development.size > 1) { items.addAll(development.take(2)) } else { items.add(development.first()) wait.firstOrNull()?.let { items.add(it) } } } } else { if (wait.isNotEmpty()) { if (development.size > 1) { items.addAll(development.take(2)) items.add(wait.first()) } else { items.add(development.first()) items.addAll(wait.take(2)) } } else { items.addAll(development.take(3)) } } } else { if (done.isNotEmpty()) { if (done.size > 1) { items.addAll(done.take(2)) items.add(wait.first()) } else { items.add(done.first()) items.addAll(wait.take(2)) } } else { items.addAll(wait.take(MAX_DISPLAY_ITEM)) } } } return items.take(MAX_DISPLAY_ITEM).map { NewBuildingConstructionItem(it) } }
Leave a Comment