fix(status): AMSAT page load failure, refresh spinner, retry button
- P0: fetchStatus() now runs on Dispatchers.IO - the previous synchronous URLConnection on the main thread threw NetworkOnMainThreadException and showed "load failed" on every open - P1: refresh button rotates a vector icon (ic_refresh) instead of the "↻" text glyph, whose off-center font metrics made the spinner orbit around a shifted pivot - P2: error state gains a Retry button (4 locales); amsat_refresh string added (5 locales) - versionCode 456 (bump for reinstalling over 455), versionName stays 4.5.5
This commit is contained in:
1 parent
6221516893
commit
f789a15338
9 files changed
+47
-10
No files matched your search
+5
-3
@@ -8,20 +8,22 @@ import com.rtbishop.look4sat.core.domain.model.SatSlot
|
||||
import com.rtbishop.look4sat.core.domain.model.SatStatus
|
||||
import com.rtbishop.look4sat.core.domain.model.SatStatusPage
|
||||
import com.rtbishop.look4sat.core.domain.repository.IAmSatRepository
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.util.Calendar
|
||||
import java.util.TimeZone
|
||||
|
||||
/** AMSAT status repository: official API v1 -> SatStatusPage (replaces the HTML parser). */
|
||||
class AmSatRepository(private val apiClient: AmSatApiClient) : IAmSatRepository {
|
||||
|
||||
override suspend fun fetchStatus(): SatStatusPage? {
|
||||
override suspend fun fetchStatus(): SatStatusPage? = withContext(Dispatchers.IO) {
|
||||
val nowSec = System.currentTimeMillis() / 1000
|
||||
val names = apiClient.fetchCatalog()
|
||||
val reports = apiClient.fetchAllReports(hours = 168)
|
||||
if (names.isEmpty() && reports.isEmpty()) return null
|
||||
if (names.isEmpty() && reports.isEmpty()) return@withContext null
|
||||
val statuses = buildStatuses(names, reports, nowSec)
|
||||
val reportMap = reports.associate { it.id to toSatReport(it) }
|
||||
return SatStatusPage(System.currentTimeMillis(), statuses, reportMap)
|
||||
SatStatusPage(System.currentTimeMillis(), statuses, reportMap)
|
||||
}
|
||||
|
||||
/** Build one SatStatus (6 days x 12 slots) per catalog satellite, slotting reports by age. */
|
||||
|
||||
@@ -46,6 +46,8 @@
|
||||
<string name="nav_log">Log</string>
|
||||
<string name="nav_amsat">AMSAT</string>
|
||||
<string name="amsat_title">Status Satelit AMSAT</string>
|
||||
<string name="amsat_refresh">Segarkan</string>
|
||||
<string name="amsat_retry">Coba lagi</string>
|
||||
<string name="amsat_updated">Diperbarui:</string>
|
||||
<string name="amsat_active">Aktif</string>
|
||||
<string name="amsat_tlm">TLM/beacon</string>
|
||||
|
||||
@@ -46,6 +46,8 @@
|
||||
<string name="nav_log">Log</string>
|
||||
<string name="nav_amsat">AMSAT</string>
|
||||
<string name="amsat_title">Status Satelit AMSAT</string>
|
||||
<string name="amsat_refresh">Segarkan</string>
|
||||
<string name="amsat_retry">Coba lagi</string>
|
||||
<string name="amsat_updated">Diperbarui:</string>
|
||||
<string name="amsat_active">Aktif</string>
|
||||
<string name="amsat_tlm">TLM/beacon</string>
|
||||
|
||||
@@ -47,6 +47,8 @@
|
||||
<string name="nav_log">Günlük</string>
|
||||
<string name="nav_amsat">AMSAT</string>
|
||||
<string name="amsat_title">AMSAT Uydu Durumu</string>
|
||||
<string name="amsat_refresh">Yenile</string>
|
||||
<string name="amsat_retry">Tekrar dene</string>
|
||||
<string name="amsat_updated">Güncellendi:</string>
|
||||
<string name="amsat_active">Aktif</string>
|
||||
<string name="amsat_tlm">TLM/işaret</string>
|
||||
|
||||
@@ -48,6 +48,8 @@
|
||||
<string name="nav_log">日志</string>
|
||||
<string name="nav_amsat">AMSAT</string>
|
||||
<string name="amsat_title">AMSAT 卫星状态</string>
|
||||
<string name="amsat_refresh">刷新</string>
|
||||
<string name="amsat_retry">重试</string>
|
||||
<string name="amsat_updated">更新:</string>
|
||||
<string name="amsat_active">活跃</string>
|
||||
<string name="amsat_tlm">仅遥测</string>
|
||||
|
||||
@@ -49,6 +49,8 @@
|
||||
<string name="nav_log">Log</string>
|
||||
<string name="nav_amsat">AMSAT</string>
|
||||
<string name="amsat_title">AMSAT Satellite Status</string>
|
||||
<string name="amsat_refresh">Refresh</string>
|
||||
<string name="amsat_retry">Retry</string>
|
||||
<string name="amsat_updated">Updated:</string>
|
||||
<string name="amsat_active">Active</string>
|
||||
<string name="amsat_tlm">TLM/Beacon</string>
|
||||
|
||||
Reference in new issue
Block a user