Skip to content

Commit

Permalink
"ylw has stopped" during phone call #6 - fix weather update check
Browse files Browse the repository at this point in the history
  • Loading branch information
thuryn authored and thuryn committed Jan 19, 2018
1 parent f8de643 commit fed58b4
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,16 @@ public void onAccuracyChanged(Sensor sensor, int i) {
public void onReceive(Context context, Intent intent) {
appendLog(context, TAG, "receive intent: " + intent);

long storedWeatherTime = PreferenceManager.getDefaultSharedPreferences(getBaseContext()).getLong(Constants.LAST_WEATHER_UPDATE_TIME_IN_MS, 0);
long storedWeatherTime = getBaseContext()
.getSharedPreferences(Constants.APP_SETTINGS_NAME, Context.MODE_PRIVATE).getLong(Constants.LAST_WEATHER_UPDATE_TIME_IN_MS, 0);
long now = Calendar.getInstance().getTimeInMillis();
appendLog(context, TAG, "SCREEN_ON called, lastUpdate=" +
lastUpdatedWeather +
", now=" +
now +
", storedWeatherTime=" +
storedWeatherTime);
if (now < (storedWeatherTime + UPDATE_WEATHER_ONLY_TIMEOUT) || (now < (lastUpdatedWeather + REQUEST_UPDATE_WEATHER_ONLY_TIMEOUT))) {
if ((now < (storedWeatherTime + UPDATE_WEATHER_ONLY_TIMEOUT)) || (now < (lastUpdatedWeather + REQUEST_UPDATE_WEATHER_ONLY_TIMEOUT))) {
timerScreenOnHandler.postDelayed(timerScreenOnRunnable, UPDATE_WEATHER_ONLY_TIMEOUT - (now - storedWeatherTime));
return;
}
Expand Down Expand Up @@ -140,7 +141,8 @@ public void run() {
if (!powerManager.isScreenOn()) {
return;
}
long storedWeatherTime = PreferenceManager.getDefaultSharedPreferences(getBaseContext()).getLong(Constants.LAST_WEATHER_UPDATE_TIME_IN_MS, 0);
long storedWeatherTime = getBaseContext()
.getSharedPreferences(Constants.APP_SETTINGS_NAME, Context.MODE_PRIVATE).getLong(Constants.LAST_WEATHER_UPDATE_TIME_IN_MS, 0);
long now = Calendar.getInstance().getTimeInMillis();
appendLog(getBaseContext(), TAG, "SCREEN_ON called, lastUpdate=" +
lastUpdatedWeather +
Expand All @@ -149,7 +151,7 @@ public void run() {
", storedWeatherTime=" +
storedWeatherTime);

if (now < (storedWeatherTime + UPDATE_WEATHER_ONLY_TIMEOUT) || (now < (lastUpdatedWeather + REQUEST_UPDATE_WEATHER_ONLY_TIMEOUT))) {
if ((now < (storedWeatherTime + UPDATE_WEATHER_ONLY_TIMEOUT)) || (now < (lastUpdatedWeather + REQUEST_UPDATE_WEATHER_ONLY_TIMEOUT))) {
timerScreenOnHandler.postDelayed(timerScreenOnRunnable, REQUEST_UPDATE_WEATHER_ONLY_TIMEOUT);
return;
}
Expand Down

0 comments on commit fed58b4

Please sign in to comment.