Return empty list when no results are found instaid of crashing

This commit is contained in:
Joren 2024-04-30 12:17:17 +02:00
parent 9b8af28f47
commit 13dc50afe8
Signed by untrusted user who does not match committer: Joren
GPG Key ID: 280E33DFBC0F1B55

View File

@ -48,7 +48,7 @@ class PokeSearchViewModel(private val favouritesRepository: FavouritesRepository
val detailsList = mutableListOf<PokemonDetails>() val detailsList = mutableListOf<PokemonDetails>()
if (firstIndex != null && lastIndex != null) { if (firstIndex != null && lastIndex != null && firstIndex != -1 && lastIndex != -1) {
val endIndex = minOf(firstIndex + SHOW_LIMIT, lastIndex + 1) val endIndex = minOf(firstIndex + SHOW_LIMIT, lastIndex + 1)
val startIndex = maxOf(firstIndex, endIndex - SHOW_LIMIT) val startIndex = maxOf(firstIndex, endIndex - SHOW_LIMIT)