diff --git a/app/src/main/java/com/pranshulgg/weather_master_app/core/model/weather/WeatherCondition.kt b/app/src/main/java/com/pranshulgg/weather_master_app/core/model/weather/WeatherCondition.kt index 9098c9b89..db0d3c906 100644 --- a/app/src/main/java/com/pranshulgg/weather_master_app/core/model/weather/WeatherCondition.kt +++ b/app/src/main/java/com/pranshulgg/weather_master_app/core/model/weather/WeatherCondition.kt @@ -64,7 +64,6 @@ enum class WeatherCondition { // ------- MAP TO ICONS ------- fun WeatherCondition.toIcon(daily: WeatherDaily? = null, targetTimeMilli: Long): Int { - val isDay = if (daily != null) { targetTimeMilli in daily.sunrise..daily.sunset } else { diff --git a/app/src/main/java/com/pranshulgg/weather_master_app/core/utils/weather/computing/ComputeDailyWeatherCondition.kt b/app/src/main/java/com/pranshulgg/weather_master_app/core/utils/weather/computing/ComputeDailyWeatherCondition.kt index 0286d9a18..5be50f5e3 100644 --- a/app/src/main/java/com/pranshulgg/weather_master_app/core/utils/weather/computing/ComputeDailyWeatherCondition.kt +++ b/app/src/main/java/com/pranshulgg/weather_master_app/core/utils/weather/computing/ComputeDailyWeatherCondition.kt @@ -54,17 +54,31 @@ fun computeDailyWeatherCondition( .fold(0) { acc, w -> acc + weight(w) } // Pick the top 2, we keep the order as is so they don't flip, ignore weak stuff - val topTwo = counts +// val topTwo = counts +// .filter { it.value > 2 } +// .keys +// .sortedBy { weather -> +// dataNormalized.indexOf(weather) +// } +// .take(2) +// +// val topSecondary = counts.keys.sortedByDescending { it } + + // Pick the top primary, we keep the order as is so they don't flip, ignore weak stuff + val topPrimary = counts .filter { it.value > 2 } .keys .sortedBy { weather -> dataNormalized.indexOf(weather) } - .take(2) + .take(1) - val primary = topTwo.getOrNull(0) - val secondary = topTwo.getOrNull(1) + // Pick the dominant one for secondary + val topSecondary = counts.keys.sortedByDescending { it }.take(1) + + val primary = topPrimary.getOrNull(0) + val secondary = topSecondary.getOrNull(0) val primaryCount = primary?.let { counts[it] } ?: 0