Open offline at once when there's no connection

With airplane mode on, checking the stored sign-in waited out every retry and
timeout, about 90 seconds on a Galaxy S20, before showing the downloads. The
phone app now tells AppState whether the device has any network, and with none
it goes straight to the offline screen; the network callback signs in again
once a connection appears. The TV keeps trying as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Yuriy PanovandClaude Opus 5.5 committed 2026-10-23 16:27:59 +06:00
1 parent a60194c5a7
commit 891b1b6efd
2 files changed
+20 -8

No files matched your search

@@ -44,6 +44,12 @@ class Musyx : Application(), SingletonImageLoader.Factory {
watchNetwork()
}
private fun online(): Boolean {
val connectivity = getSystemService(ConnectivityManager::class.java)
val network = connectivity.activeNetwork ?: return false
return connectivity.getNetworkCapabilities(network)?.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) == true
}
/** A connection coming back reconnects an offline session and resumes downloads. */
private fun watchNetwork() {
val request = NetworkRequest.Builder().addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET).build()
@@ -70,6 +76,7 @@ class Musyx : Application(), SingletonImageLoader.Factory {
// Mobile data slows and drops out: buffer whole tracks and preload the next one.
buffering = Buffering.Mobile,
coverSizes = listOf(COVER_SMALL, COVER_LARGE),
online = ::online,
)
}