Fix "no gps" / "no weather data" is not displayed in data fields anymore (#67)

This commit is contained in:
timklge 2025-03-08 13:33:01 +01:00 committed by GitHub
parent 3a4515268e
commit 107c7a575d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 6 additions and 7 deletions

View File

@ -89,9 +89,6 @@ class KarooHeadwindExtension : KarooExtension("karoo-headwind", BuildConfig.VERS
) )
} }
data class StreamData(val settings: HeadwindSettings, val gps: GpsCoordinates?,
val profile: UserProfile? = null, val upcomingRoute: UpcomingRoute? = null)
@OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class) @OptIn(ExperimentalCoroutinesApi::class, FlowPreview::class)
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()

View File

@ -202,7 +202,7 @@ abstract class ForecastDataType(private val karooSystem: KarooSystemService, typ
dataFlow.collect { (allData, settingsAndProfile, widgetSettings, userProfile, headingResponse, upcomingRoute) -> dataFlow.collect { (allData, settingsAndProfile, widgetSettings, userProfile, headingResponse, upcomingRoute) ->
Log.d(KarooHeadwindExtension.TAG, "Updating weather forecast view") Log.d(KarooHeadwindExtension.TAG, "Updating weather forecast view")
if (allData == null){ if (allData.isNullOrEmpty()){
emitter.updateView( emitter.updateView(
getErrorWidget( getErrorWidget(
glance, glance,

View File

@ -28,6 +28,7 @@ import kotlinx.coroutines.awaitCancellation
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.emitAll
import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlin.math.roundToInt import kotlin.math.roundToInt
@ -127,7 +128,10 @@ class HeadwindDirectionDataType(
previewFlow() previewFlow()
} else { } else {
val directionFlow = streamValues() val directionFlow = streamValues()
val speedFlow = UserWindSpeedDataType.streamValues(context, karooSystem) val speedFlow = flow {
emit(0.0)
emitAll(UserWindSpeedDataType.streamValues(context, karooSystem))
}
combine(directionFlow, speedFlow) { direction, speed -> combine(directionFlow, speedFlow) { direction, speed ->
DirectionAndSpeed(direction, speed) DirectionAndSpeed(direction, speed)

View File

@ -19,7 +19,6 @@ import androidx.compose.material3.Tab
import androidx.compose.material3.TabRow import androidx.compose.material3.TabRow
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.pulltorefresh.PullToRefreshBox import androidx.compose.material3.pulltorefresh.PullToRefreshBox
import androidx.compose.material3.pulltorefresh.rememberPullToRefreshState
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.LaunchedEffect
@ -55,7 +54,6 @@ fun MainScreen(close: () -> Unit) {
var tabIndex by remember { mutableIntStateOf(0) } var tabIndex by remember { mutableIntStateOf(0) }
var isRefreshing by remember { mutableStateOf(false) } var isRefreshing by remember { mutableStateOf(false) }
val swipeRefreshState = rememberPullToRefreshState()
val tabs = listOf("Weather", "Settings") val tabs = listOf("Weather", "Settings")