Skip to content

Commit

Permalink
introduce empty data state incase user deselects all options
Browse files Browse the repository at this point in the history
  • Loading branch information
odaridavid committed Mar 11, 2024
1 parent d04f433 commit 8283909
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ enum class ExcludedData(val value:String){
DAILY("daily"),
MINUTELY("minutely"),
ALERTS("alerts"),
NONE(""),
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.github.odaridavid.weatherapp.ui.settings

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.github.odaridavid.weatherapp.core.api.Logger
import com.github.odaridavid.weatherapp.core.api.SettingsRepository
import com.github.odaridavid.weatherapp.core.model.ExcludedData
import dagger.hilt.android.lifecycle.HiltViewModel
Expand All @@ -14,7 +15,8 @@ import javax.inject.Inject

@HiltViewModel
class SettingsViewModel @Inject constructor(
private val settingsRepository: SettingsRepository
private val settingsRepository: SettingsRepository,
private val logger: Logger,
) : ViewModel() {

private val _state = MutableStateFlow(SettingsScreenViewState())
Expand Down Expand Up @@ -104,7 +106,10 @@ class SettingsViewModel @Inject constructor(
ExcludedData.DAILY.value -> ExcludedData.DAILY
ExcludedData.MINUTELY.value -> ExcludedData.MINUTELY
ExcludedData.ALERTS.value -> ExcludedData.ALERTS
else -> throw IllegalArgumentException("Invalid excluded data")
else ->{
logger.logException(IllegalArgumentException("Invalid excluded data"))
ExcludedData.NONE
}
}
}
}
Expand Down

0 comments on commit 8283909

Please sign in to comment.