diff options
Diffstat (limited to 'app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/ConverterUtils.java')
-rw-r--r-- | app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/ConverterUtils.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/ConverterUtils.java b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/ConverterUtils.java index 41ea613..cb13588 100644 --- a/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/ConverterUtils.java +++ b/app/src/main/java/org/cyanogenmod/wundergroundcmweatherprovider/wunderground/ConverterUtils.java @@ -16,6 +16,7 @@ package org.cyanogenmod.wundergroundcmweatherprovider.wunderground; +import org.cyanogenmod.wundergroundcmweatherprovider.wunderground.responses.citylookup.CityDisambiguationResponse; import org.cyanogenmod.wundergroundcmweatherprovider.wunderground.responses.forecast.ForecastDayResponse; import java.util.ArrayList; @@ -23,6 +24,7 @@ import java.util.List; import cyanogenmod.providers.WeatherContract; import cyanogenmod.weather.WeatherInfo; +import cyanogenmod.weather.WeatherLocation; public class ConverterUtils { @@ -42,4 +44,18 @@ public class ConverterUtils { } return dayForecasts; } + + public static ArrayList<WeatherLocation> convertDisambiguationsToWeatherLocations( + List<CityDisambiguationResponse> cityDisambiguationResponses) { + ArrayList<WeatherLocation> weatherLocations = new ArrayList<>(); + for (CityDisambiguationResponse cityDisambiguationResponse : cityDisambiguationResponses) { + WeatherLocation weatherLocation = new WeatherLocation.Builder( + cityDisambiguationResponse.getCity(), cityDisambiguationResponse.getCity()) + .setCountry(cityDisambiguationResponse.getCountry(), + cityDisambiguationResponse.getCountry()) + .build(); + weatherLocations.add(weatherLocation); + } + return weatherLocations; + } } |