Skip to content

Commit

Permalink
Updated DB versions
Browse files Browse the repository at this point in the history
  • Loading branch information
thuryn committed Mar 6, 2021
1 parent 8b43ceb commit acc0a5c
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 43 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v5.7.1
Updated DB versions

v5.7.1
Set the new API key

Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ android {
applicationId "org.thosp.yourlocalweather"
minSdkVersion 14
targetSdkVersion 29
versionCode 140
versionName "5.7.1"
versionCode 141
versionName "5.7.2"
vectorDrawables.useSupportLibrary true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
playAccountConfig = playAccountConfigs.defaultAccountConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

public class CurrentWeatherDbHelper extends SQLiteOpenHelper {

public static final int DATABASE_VERSION = 1;
public static final int DATABASE_VERSION = 2;
public static final String DATABASE_NAME = "CurrentWeather.db";
private static int GET_READABLE_DATABASE_RETRIES = 3;
private static int GET_READABLE_DATABASE_WAIT_TIME_MS = 500;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class WeatherForecastDbHelper extends SQLiteOpenHelper {

private static final String TAG = "WeatherForecastDbHelper";

public static final int DATABASE_VERSION = 2;
public static final int DATABASE_VERSION = 3;
public static final String DATABASE_NAME = "WeatherForecast.db";
private static WeatherForecastDbHelper instance;
private Context context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,47 +232,45 @@ public void startWeatherUpdate() {
CurrentWeatherDbHelper.WeatherRecord weatherRecord = currentWeatherDbHelper.getWeather(locationToCheck.getId());
long nextAllowedAttemptToUpdateTime = (weatherRecord != null)?weatherRecord.getNextAllowedAttemptToUpdateTime():0;

if (now > nextAllowedAttemptToUpdateTime) {
if (isCurrentWeather(updateType)) {
long lastUpdateTimeInMilis = (weatherRecord != null) ? weatherRecord.getLastUpdatedTime() : 0;
long updatePeriodForLocation;
if (locationToCheck.getOrderId() == 0) {
String updateAutoPeriodStr = AppPreference.getLocationAutoUpdatePeriod(this);
updatePeriodForLocation = Utils.intervalMillisForAlarm(updateAutoPeriodStr);
} else {
String updatePeriodStr = AppPreference.getLocationUpdatePeriod(this);
updatePeriodForLocation = Utils.intervalMillisForAlarm(updatePeriodStr);
}

appendLog(this.getBaseContext(), TAG,
"Current weather requested for location.orderId=",
locationToCheck.getOrderId(),
", updatePeriodForLocation=",
updatePeriodForLocation,
", now=",
now,
", lastUpdateTimeInMilis=",
lastUpdateTimeInMilis,
", nextAllowedAttemptToUpdateTime=",
nextAllowedAttemptToUpdateTime);
readyForUpdate = (now > (lastUpdateTimeInMilis + updatePeriodForLocation)) && (now > nextAllowedAttemptToUpdateTime);
if (isCurrentWeather(updateType)) {
long lastUpdateTimeInMilis = (weatherRecord != null) ? weatherRecord.getLastUpdatedTime() : 0;
long updatePeriodForLocation;
if (locationToCheck.getOrderId() == 0) {
String updateAutoPeriodStr = AppPreference.getLocationAutoUpdatePeriod(this);
updatePeriodForLocation = Utils.intervalMillisForAlarm(updateAutoPeriodStr);
} else {
appendLog(getBaseContext(),
TAG,
"checkWeatherForecastUpdate locationToCheck.getId():",
locationToCheck.getId());
boolean longForecast = isLongWeatherForecast(updateRequest.getUpdateType());
appendLog(getBaseContext(),
TAG,
"checkWeatherForecastUpdate longForecast:",
longForecast);
readyForUpdate = ForecastUtil.shouldUpdateForecast(this, locationToCheck.getId(),
longForecast ? UpdateWeatherService.LONG_WEATHER_FORECAST_TYPE : UpdateWeatherService.WEATHER_FORECAST_TYPE);
appendLog(getBaseContext(),
TAG,
"checkWeatherForecastUpdate readyForUpdate:",
readyForUpdate);
String updatePeriodStr = AppPreference.getLocationUpdatePeriod(this);
updatePeriodForLocation = Utils.intervalMillisForAlarm(updatePeriodStr);
}

appendLog(this.getBaseContext(), TAG,
"Current weather requested for location.orderId=",
locationToCheck.getOrderId(),
", updatePeriodForLocation=",
updatePeriodForLocation,
", now=",
now,
", lastUpdateTimeInMilis=",
lastUpdateTimeInMilis,
", nextAllowedAttemptToUpdateTime=",
nextAllowedAttemptToUpdateTime);
readyForUpdate = (now > (lastUpdateTimeInMilis + updatePeriodForLocation)) && (now > nextAllowedAttemptToUpdateTime);
} else {
appendLog(getBaseContext(),
TAG,
"checkWeatherForecastUpdate locationToCheck.getId():",
locationToCheck.getId());
boolean longForecast = isLongWeatherForecast(updateRequest.getUpdateType());
appendLog(getBaseContext(),
TAG,
"checkWeatherForecastUpdate longForecast:",
longForecast);
readyForUpdate = ForecastUtil.shouldUpdateForecast(this, locationToCheck.getId(),
longForecast ? UpdateWeatherService.LONG_WEATHER_FORECAST_TYPE : UpdateWeatherService.WEATHER_FORECAST_TYPE);
appendLog(getBaseContext(),
TAG,
"checkWeatherForecastUpdate readyForUpdate:",
readyForUpdate);
}

if (!readyForUpdate) {
Expand Down

0 comments on commit acc0a5c

Please sign in to comment.