Author: Adam Evyčędo <git@apiote.xyz>
show separate arrivals and departures in transitous
%!v(PANIC=String method: strings: negative Repeat count)
diff --git a/app/src/main/java/xyz/apiote/bimba/czwek/api/transitousDepartures.kt b/app/src/main/java/xyz/apiote/bimba/czwek/api/transitousDepartures.kt index 8441a76e9e6e38c5c8978feaebe9cba650ecc040..67bbcb416081b6771ed5de98a157adff8460c249 100644 --- a/app/src/main/java/xyz/apiote/bimba/czwek/api/transitousDepartures.kt +++ b/app/src/main/java/xyz/apiote/bimba/czwek/api/transitousDepartures.kt @@ -60,8 +60,12 @@ longitude = it.place.lon stopName = it.place.name Event( it.tripId + it.source, - Time.fromOffsetTime(it.place.departure ?: it.place.arrival!!, ZoneId.systemDefault()), - Time.fromOffsetTime(it.place.departure ?: it.place.arrival!!, ZoneId.systemDefault()), + it.place.arrival?.let { + Time.fromOffsetTime(it, ZoneId.systemDefault()) + }, + it.place.departure?.let { + Time.fromOffsetTime(it, ZoneId.systemDefault()) + }, 0u, it.realTime, Vehicle( 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 fe2c6f61568b7c976c20ded71586077877d1329b..a5d676e2b8392b6aca5f6efb899b86d44fff2a97 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 @@ -381,37 +381,41 @@ } private fun setContent(view: View, ctx: Context, updating: Boolean = false) { view.apply { + val arrivalStatus = findViewById<TextView>(R.id.arrival_status) + val arrivalTime = findViewById<TextView>(R.id.arrival_time) + val departureStatus = findViewById<TextView>(R.id.departure_status) + val departureTime = findViewById<TextView>(R.id.departure_time) if (event.arrivalTime == event.departureTime) { if (!event.exact) { - findViewById<TextView>(R.id.arrival_status).apply { + arrivalStatus.apply { visibility = View.VISIBLE text = context.getString(R.string.approximately) } } else { - findViewById<TextView>(R.id.arrival_status).visibility = View.GONE + arrivalStatus.visibility = View.GONE } findViewById<TextView>(R.id.arrival_time).apply { text = event.arrivalTimeString(ctx) visibility = View.VISIBLE } - findViewById<TextView>(R.id.departure_status).visibility = View.GONE - findViewById<TextView>(R.id.departure_time).visibility = View.GONE + departureStatus.visibility = View.GONE + departureTime.visibility = View.GONE } else { if (event.arrivalTime != null) { - findViewById<TextView>(R.id.arrival_time).visibility = View.VISIBLE - findViewById<TextView>(R.id.arrival_time).text = event.arrivalTimeString(ctx) - findViewById<TextView>(R.id.arrival_status).visibility = View.VISIBLE - findViewById<TextView>(R.id.arrival_status).text = if (!event.exact) { + arrivalTime.visibility = View.VISIBLE + arrivalTime.text = event.arrivalTimeString(ctx) + arrivalStatus.visibility = View.VISIBLE + arrivalStatus.text = if (!event.exact) { context?.getString(R.string.arrival_approximate) } else { context?.getString(R.string.arrival) } } if (event.departureTime != null) { - findViewById<TextView>(R.id.departure_time).visibility = View.VISIBLE - findViewById<TextView>(R.id.departure_time).text = event.departureTimeString(ctx) - findViewById<TextView>(R.id.departure_status).visibility = View.VISIBLE - findViewById<TextView>(R.id.departure_status).text = if (!event.exact) { + departureTime.visibility = View.VISIBLE + departureTime.text = event.departureTimeString(ctx) + departureStatus.visibility = View.VISIBLE + departureStatus.text = if (!event.exact) { context?.getString(R.string.departure_approximate) } else { context?.getString(R.string.departure) diff --git a/app/src/main/res/layout/departure_bottom_sheet.xml b/app/src/main/res/layout/departure_bottom_sheet.xml index f2bb7dc23101df9ee440b0a8997d2ebbfbe753ce..8fb3f89430cb97b27c1a5b1b825567850ee1c374 100644 --- a/app/src/main/res/layout/departure_bottom_sheet.xml +++ b/app/src/main/res/layout/departure_bottom_sheet.xml @@ -24,6 +24,7 @@ android:id="@+id/arrival_status" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="0dp" + android:visibility="gone" android:textAppearance="@style/TextAppearance.Material3.BodySmall" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -35,6 +36,7 @@ android:id="@+id/arrival_time" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="0dp" + android:visibility="gone" android:textAppearance="@style/TextAppearance.Material3.DisplaySmall" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"