I've followed https://github.com/googlecodelabs/android-build-an-app-architecture-components.
I want to be able to fetch weather data by city name.
I've created the required method in the DAO class.
I've changed my code in the Repository class to:
public LiveData<List<ListWeatherEntry>> getCurrentWeatherForecasts(String cityName) {
initializeData();
Date today = SunshineDateUtils.getNormalizedUtcDateForToday();
return mWeatherDao.getCurrentWeatherForecasts(today,cityName);
}
But in my ViewModel class when I'm trying to use this function in the Transformation.switchMap, Im getting compile time error that the method getCurrentWeatherForecasts(String ) cannot be applied to getCurrentWeatherForecasts().
Here's my code in ViewModel class:
private final SunshineRepository mRepository;
public LiveData<List<ListWeatherEntry>> mForecast;
private final MutableLiveData<String> cityName = new MutableLiveData();
public MainActivityViewModel(SunshineRepository repository) {
this.mRepository = repository;
mForecast = Transformations.switchMap(this.cityName,(city)->
mRepository.getCurrentWeatherForecasts(city));
}
I've read Android's Transformations.switchMap docs, but I couldn't figure out what am I doing wrong.
Can anyone explain me what's wrong with my code.