Skip to content

Commit

Permalink
ktlintFormat
Browse files Browse the repository at this point in the history
  • Loading branch information
murjune committed Sep 26, 2024
1 parent aaaa367 commit bfa43f8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ class BattleActivity : ToolbarActivity<ActivityBattleBinding>(R.layout.activity_

private fun initSpinner() {
binding.spinnerWeather.adapter = weatherAdapter
binding.spinnerWeather.onItemSelectedListener = itemSelectListener<WeatherUiModel> {
viewModel.updateWeather(it)
}
binding.spinnerWeather.onItemSelectedListener =
itemSelectListener<WeatherUiModel> {
viewModel.updateWeather(it)
}
}

private fun initObserver() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,16 @@ class BattleViewModel(
private val _selectedState = MutableStateFlow(BattleSelectionsState.DEFAULT)
val selectedState = _selectedState.asStateFlow()

val weatherPos: StateFlow<Int> = combine(
battleRepository.savedWeatherStream(),
weathers,
) { weather, weathers ->
if (weather == null || weathers.isEmpty()) return@combine null
if (weathers.any { it.id == weather.id }.not()) return@combine null
weathers.indexOfFirst { it.id == weather.id }
}.filterNotNull()
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), 0)
val weatherPos: StateFlow<Int> =
combine(
battleRepository.savedWeatherStream(),
weathers,
) { weather, weathers ->
if (weather == null || weathers.isEmpty()) return@combine null
if (weathers.any { it.id == weather.id }.not()) return@combine null
weathers.indexOfFirst { it.id == weather.id }
}.filterNotNull()
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), 0)

private val _navigateToSelection = MutableSharedFlow<SelectionNavigationData>()
val navigateToSelection = _navigateToSelection.asSharedFlow()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ inline fun <reified T> itemSelectListener(crossinline onSelected: (T) -> Unit):

override fun onNothingSelected(parent: AdapterView<*>?) {}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,14 @@ class DefaultBattleRepository(
opponentPokemonId = opponentPokemonId,
)

override suspend fun savePokemon(pokemonId: String) =
localBattleDataSource.savePokemon(pokemonId)
override suspend fun savePokemon(pokemonId: String) = localBattleDataSource.savePokemon(pokemonId)

override suspend fun savePokemonWithSkill(
pokemonId: String,
skillId: String,
) = localBattleDataSource.savePokemonWithSkill(pokemonId, skillId)

override fun savedPokemonStream(): Flow<Pokemon?> =
localBattleDataSource.pokemonId().map { it?.let { pokemonRepository.pokemon(it) } }
override fun savedPokemonStream(): Flow<Pokemon?> = localBattleDataSource.pokemonId().map { it?.let { pokemonRepository.pokemon(it) } }

override fun savedPokemonWithSkillStream(): Flow<PokemonWithSkill?> =
localBattleDataSource.pokemonWithSkill().map {
Expand All @@ -60,8 +58,7 @@ class DefaultBattleRepository(
}
}

override suspend fun saveWeather(weatherId: String) =
localBattleDataSource.saveWeather(weatherId)
override suspend fun saveWeather(weatherId: String) = localBattleDataSource.saveWeather(weatherId)

override fun savedWeatherStream(): Flow<Weather?> =
localBattleDataSource.weatherId().map {
Expand Down

0 comments on commit bfa43f8

Please sign in to comment.