So this is my Java code that works
if (currentForecastJava.getCurrentObservation().getTempF() >= 60) {
mCurrentWeatherBox.setBackgroundColor(getResources().getColor(R.color.weather_warm));
mToolbar.setBackgroundColor(getResources().getColor(R.color.weather_warm));
} else {
mCurrentWeatherBox.setBackgroundColor(getResources().getColor(R.color.weather_cool));
mToolbar.setBackgroundColor(getResources().getColor(R.color.weather_cool));
}
What I am trying to do is write this in Kotlin(know AS has the converter but does not change anything)
if (currentObservationKotlin.tempF.compareTo() >=)
currentWeatherBox.setBackgroundColor(resources.getColor(R.color.weather_warm))
toolbar.setBackgroundColor(resources.getColor(R.color.weather_warm))
else currentWeatherBox.setBackgroundColor(resources.getColor(R.color.weather_cool))
toolbar.setBackgroundColor(resources.getColor(R.color.weather_cool))
I know I need a value in the compareTo() and after but I am not really sure what to place as I want to compare TempF to 60 as I want the color to change based on the TempF value from data class. I do not have another object to compare it to.
I can write this in Java and it works with the rest of the Kotlin code but trying to see if Kotlin can make the Java if/else similar and quicker to write.