summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdnan Begovic <adnan@cyngn.com>2016-05-06 06:35:32 (GMT)
committerAdnan Begovic <adnan@cyngn.com>2016-05-06 06:35:32 (GMT)
commita8980dbe7bc9cc3718ed04b452e14fce7105f7df (patch)
tree6ebfc1e6e686b3008cd696136c72c9ad8c412da4
parent636b71ae9019e04e4f77fc0714c603bd3ae0f5a2 (diff)
downloadandroid_packages_apps_YahooWeatherProvider-a8980dbe7bc9cc3718ed04b452e14fce7105f7df.zip
android_packages_apps_YahooWeatherProvider-a8980dbe7bc9cc3718ed04b452e14fce7105f7df.tar.gz
android_packages_apps_YahooWeatherProvider-a8980dbe7bc9cc3718ed04b452e14fce7105f7df.tar.bz2
YahooCM: Hardcode forecast day count.
Add todo for future user configuration. Change-Id: I20690e9771448635766e84d591047217b94b64e4
-rw-r--r--app/src/main/java/org/cyanogenmod/yahooweatherprovider/ConverterUtils.java8
-rw-r--r--app/src/main/java/org/cyanogenmod/yahooweatherprovider/YahooWeatherProviderService.java5
2 files changed, 11 insertions, 2 deletions
diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/ConverterUtils.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/ConverterUtils.java
index 53b2158..635b5b7 100644
--- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/ConverterUtils.java
+++ b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/ConverterUtils.java
@@ -38,15 +38,21 @@ import static cyanogenmod.providers.WeatherContract.WeatherColumns.WeatherCode.S
public class ConverterUtils {
- public static ArrayList<WeatherInfo.DayForecast> convertForecastsToDayForecasts(List<Forecast> forecasts) {
+ public static ArrayList<WeatherInfo.DayForecast> convertForecastsToDayForecasts(
+ List<Forecast> forecasts, int max) {
ArrayList<WeatherInfo.DayForecast> ret = new ArrayList<>();
+ int i = 0;
for (Forecast forecast : forecasts) {
+ if (i > max) {
+ break;
+ }
WeatherInfo.DayForecast dayForecast = new WeatherInfo.DayForecast.Builder(offset(
Integer.parseInt(forecast.getCode())))
.setHigh(Double.parseDouble(forecast.getHigh()))
.setLow(Double.parseDouble(forecast.getLow()))
.build();
ret.add(dayForecast);
+ i++;
}
return ret;
}
diff --git a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/YahooWeatherProviderService.java b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/YahooWeatherProviderService.java
index e3fd365..63c0f96 100644
--- a/app/src/main/java/org/cyanogenmod/yahooweatherprovider/YahooWeatherProviderService.java
+++ b/app/src/main/java/org/cyanogenmod/yahooweatherprovider/YahooWeatherProviderService.java
@@ -64,6 +64,9 @@ public class YahooWeatherProviderService extends WeatherProviderService
private static final int SERVICE_REQUEST_CANCELLED = -1;
private static final int SERVICE_REQUEST_SUBMITTED = 0;
+ //TODO, add a setting for this
+ private static final int MAX_FORECAST_DAYS = 5;
+
@Inject
public YahooWeatherServiceManager mYahooWeatherServiceManager;
@@ -265,7 +268,7 @@ public class YahooWeatherProviderService extends WeatherProviderService
ArrayList<WeatherInfo.DayForecast> forecastList =
ConverterUtils.convertForecastsToDayForecasts(
- Arrays.asList(forecasts));
+ Arrays.asList(forecasts), MAX_FORECAST_DAYS);
// Remove today
forecastList.remove(0);