Skip to content

Commit

Permalink
Fix storing of weather forecast
Browse files Browse the repository at this point in the history
  • Loading branch information
thuryn committed Jun 15, 2024
1 parent 1fc6e3b commit 580f8e8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 18 deletions.
9 changes: 7 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,15 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

packagingOptions {
exclude 'META-INF/*'
jniLibs {
excludes += ['META-INF/*']
}
resources {
excludes += ['META-INF/*']
}
}

namespace 'org.thosp.yourlocalweather'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ public void startWeatherUpdate() {
"currentLocation is null");
return;
}
final String locale = currentLocation.getLocaleAbbrev();
appendLog(context,
TAG,
"weather get params: latitude:",
Expand Down Expand Up @@ -387,7 +386,7 @@ public void onSuccess(int statusCode, Header[] headers, byte[] response) {
Weather weather = WeatherJSONParser.getWeather(weatherData, locale);
saveWeatherAndSendResult(context, weather, currentLocation, updateType);
CompleteWeatherForecast completeWeatherForecast = WeatherJSONParser.getWeatherForecast(context, weatherData);
saveWeatherAndSendResult(context, completeWeatherForecast, WEATHER_FORECAST_TYPE, START_WEATHER_FORECAST_UPDATE);
saveWeatherAndSendResult(context, currentLocation, completeWeatherForecast, WEATHER_FORECAST_TYPE, START_WEATHER_FORECAST_UPDATE);
} else {
sendResult(ACTION_WEATHER_UPDATE_FAIL, context, currentLocation.getId(), updateType);
}
Expand Down Expand Up @@ -552,22 +551,14 @@ private void saveWeatherAndSendResult(Context context, Weather weather, Location
sendResult(ACTION_WEATHER_UPDATE_OK, context, location.getId(), updateType);
}

private void saveWeatherAndSendResult(Context context, CompleteWeatherForecast completeWeatherForecast, int forecastType, int updateType) {
private void saveWeatherAndSendResult(Context context, Location location, CompleteWeatherForecast completeWeatherForecast, int forecastType, int updateType) {
WeatherForecastDbHelper weatherForecastDbHelper = WeatherForecastDbHelper.getInstance(context);
long lastUpdate = System.currentTimeMillis();
WeatherRequestDataHolder updateRequest = updateWeatherUpdateMessages.peek();
if (updateRequest == null) {
appendLog(context,
TAG,
"Update request is null");
gettingWeatherStarted = false;
return;
}
appendLog(context,
TAG,
"Going to store forecast for locationId: ",
updateRequest.getLocationId());
weatherForecastDbHelper.saveWeatherForecast(updateRequest.getLocationId(),
location.getId());
weatherForecastDbHelper.saveWeatherForecast(location.getId(),
forecastType,
lastUpdate,
lastUpdate + MIN_WEATHER_UPDATE_TIME_IN_MS,
Expand All @@ -579,7 +570,7 @@ private void saveWeatherAndSendResult(Context context, CompleteWeatherForecast c
appendLog(context,
TAG,
"Graphs invalidated");
sendResult(ACTION_WEATHER_UPDATE_OK, context, updateRequest.getLocationId(), updateType);
sendResult(ACTION_WEATHER_UPDATE_OK, context, location.getId(), updateType);

appendLog(context,
TAG,
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
maven { url "https://jitpack.io" }
}
dependencies {
classpath 'com.android.tools.build:gradle:8.3.2'
classpath 'com.android.tools.build:gradle:8.5.0'
classpath 'com.github.triplet.gradle:play-publisher:1.2.2'

// NOTE: Do not place your application dependencies here; they belong
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit 580f8e8

Please sign in to comment.