From 828f72095536877fa734993aeee8cc27c00c0710 Mon Sep 17 00:00:00 2001 From: QIU Date: Fri, 14 Aug 2026 15:27:43 +0000 Subject: [PATCH] fix(status): show gray cell instead of crashing on an empty day AmSatParser deliberately uses getOrNull + mapNotNull while reading each day's 12 slots, so a shortened HTML row can legitimately produce SatDay(slots=[]). StatusRow then selected the first non-gray slot and fell back to slots.first(), which throws NoSuchElementException and crashes the entire AMSAT status screen. Use firstOrNull for both lookups and render a zero-count gray placeholder when no slot exists. Real amsat.org HTML currently has all 41 satellite rows at the full 73 cells, but the parser's own tolerance contract means the UI must handle what it can emit. Verified against the live page: parser matches 41/41 rows and 477/477 reports; :feature:status:compileReleaseKotlin BUILD SUCCESSFUL. --- .../rtbishop/look4sat/feature/status/SatStatusScreen.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/feature/status/src/main/java/com/rtbishop/look4sat/feature/status/SatStatusScreen.kt b/feature/status/src/main/java/com/rtbishop/look4sat/feature/status/SatStatusScreen.kt index 96f003c9..9372c1f2 100644 --- a/feature/status/src/main/java/com/rtbishop/look4sat/feature/status/SatStatusScreen.kt +++ b/feature/status/src/main/java/com/rtbishop/look4sat/feature/status/SatStatusScreen.kt @@ -280,7 +280,13 @@ private fun StatusRow(status: SatStatus, onClickDay: (SatDay) -> Unit) { modifier = Modifier.weight(2f).padding(start = 4.dp) ) status.days.forEach { day -> - val slot = day.slots.firstOrNull { it.statusColor != noReportGray } ?: day.slots.first() + // A day can legitimately carry no slots: the parser skips cells it + // cannot find, so a page that ships fewer than 12 cells for a day + // yields an empty list. first() would crash the whole status screen, + // so fall back to a gray placeholder instead. + val slot = day.slots.firstOrNull { it.statusColor != noReportGray } + ?: day.slots.firstOrNull() + ?: SatSlot(statusColor = noReportGray, count = 0) DayCell( slot = slot, modifier = Modifier.weight(0.8f).padding(horizontal = 1.dp),