Author: Adam Evyčędo <git@apiote.xyz>
show default alerts headers
%!v(PANIC=String method: strings: negative Repeat count)
diff --git a/app/src/main/java/xyz/apiote/bimba/czwek/departures/Departures.kt b/app/src/main/java/xyz/apiote/bimba/czwek/departures/Departures.kt index 3e08a953ccea76e24a3a5454bd934d9a7a4af9ca..47ad78346e5db2f3a22ef6ffe49d7c00d4659d10 100644 --- a/app/src/main/java/xyz/apiote/bimba/czwek/departures/Departures.kt +++ b/app/src/main/java/xyz/apiote/bimba/czwek/departures/Departures.kt @@ -299,8 +299,11 @@ } } if (departure.alerts.isNotEmpty()) { - findViewById<MaterialTextView>(R.id.alerts_text).text = - departure.alerts.joinToString(separator = "\n") { it.header } + findViewById<MaterialTextView>(R.id.alerts_text).text = departure.alerts.map { + it.header.ifEmpty { + getString(R.string.alert_header) + } + }.toSet().joinToString(separator = "\n") findViewById<LinearLayout>(R.id.alerts).apply { visibility = View.VISIBLE setOnClickListener { diff --git a/app/src/main/java/xyz/apiote/bimba/czwek/departures/DeparturesActivity.kt b/app/src/main/java/xyz/apiote/bimba/czwek/departures/DeparturesActivity.kt index 99c53d9f59c726de2f0dd60fc24eb13c8d44d69d..9dc89693b118a24847ff43bf057d7635e5e7923f 100644 --- a/app/src/main/java/xyz/apiote/bimba/czwek/departures/DeparturesActivity.kt +++ b/app/src/main/java/xyz/apiote/bimba/czwek/departures/DeparturesActivity.kt @@ -98,7 +98,11 @@ viewModel.departures.observe(this) { stopDepartures -> if (stopDepartures.alerts.isNotEmpty()) { binding.alerts.visibility = View.VISIBLE - binding.alertsText.text = stopDepartures.alerts.joinToString(separator = "\n") { it.header } + binding.alertsText.text = stopDepartures.alerts.map { + it.header.ifEmpty { + getString(R.string.alert_header) + } + }.toSet().joinToString(separator = "\n") alertDescriptions = stopDepartures.alerts.map { it.description }.filter { it != "" } .joinToString(separator = "\n") binding.moreButton.visibility = if (alertDescriptions == "") View.GONE else View.VISIBLE