Loading app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherUpdateService.java +4 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ import android.util.Log; import androidx.annotation.Nullable; import foundation.e.blisslauncher.core.Preferences; import foundation.e.blisslauncher.features.weather.worker.ForceWeatherRequestWorker; import foundation.e.blisslauncher.features.weather.worker.OneShotWeatherRequestWorker; Loading @@ -34,6 +35,9 @@ public class WeatherUpdateService extends Service { mHandler = new Handler(mHandlerThread.getLooper()); executePeriodicRequest(); Preferences.setLastWeatherUpdateTimestamp(this, 0); Preferences.setLastWeatherUpdateTryTimestamp(this, 0); } @Override Loading app/src/main/java/foundation/e/blisslauncher/features/weather/worker/ForceWeatherRequestWorker.java +3 −1 Original line number Diff line number Diff line Loading @@ -80,8 +80,9 @@ public class ForceWeatherRequestWorker extends WeatherRequestWorker { mGpsLocation = location; } else if (location.getProvider().equals(LocationManager.NETWORK_PROVIDER)) { mNetworkLocation = location; requestWeatherUpdate(getApplicationContext(), getMostRecentLocation()); } requestWeatherUpdate(getApplicationContext(), getMostRecentLocation()); } private Location getMostRecentLocation() { Loading @@ -104,6 +105,7 @@ public class ForceWeatherRequestWorker extends WeatherRequestWorker { private static Boolean isWeatherForceRequestAllowed(Context context) { long elapsedTime = SystemClock.elapsedRealtime() - Preferences.lastWeatherUpdateTryTimestamp(context); Log.i(TAG, "elapstedTime=" + elapsedTime + " vs refreshPeriod=" + WEATHER_REQUEST_PERIOD_TRY_IN_MS); boolean isRequestAllowed = elapsedTime >= WEATHER_REQUEST_PERIOD_TRY_IN_MS; if (isRequestAllowed) { Loading app/src/main/java/foundation/e/blisslauncher/features/weather/worker/OneShotWeatherRequestWorker.java +8 −1 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ package foundation.e.blisslauncher.features.weather.worker; import android.annotation.SuppressLint; import android.content.Context; import android.os.SystemClock; import android.util.Log; import androidx.annotation.NonNull; import androidx.work.ExistingWorkPolicy; Loading Loading @@ -44,6 +45,12 @@ public class OneShotWeatherRequestWorker extends WeatherRequestWorker { long refreshPeriod = Preferences.weatherRefreshIntervalInMs(context); long elapsedTime = SystemClock.elapsedRealtime() - Preferences.lastWeatherUpdateTimestamp(context); return refreshPeriod != 0 && elapsedTime >= refreshPeriod; Log.i(TAG, "elapstedTime=" + elapsedTime + " vs refreshPeriod=" + refreshPeriod); boolean isRequestAllowed = refreshPeriod != 0 && elapsedTime >= refreshPeriod; if (isRequestAllowed) { Preferences.setLastWeatherUpdateTimestamp(context, SystemClock.elapsedRealtime()); } return isRequestAllowed; } } Loading
app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherUpdateService.java +4 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ import android.util.Log; import androidx.annotation.Nullable; import foundation.e.blisslauncher.core.Preferences; import foundation.e.blisslauncher.features.weather.worker.ForceWeatherRequestWorker; import foundation.e.blisslauncher.features.weather.worker.OneShotWeatherRequestWorker; Loading @@ -34,6 +35,9 @@ public class WeatherUpdateService extends Service { mHandler = new Handler(mHandlerThread.getLooper()); executePeriodicRequest(); Preferences.setLastWeatherUpdateTimestamp(this, 0); Preferences.setLastWeatherUpdateTryTimestamp(this, 0); } @Override Loading
app/src/main/java/foundation/e/blisslauncher/features/weather/worker/ForceWeatherRequestWorker.java +3 −1 Original line number Diff line number Diff line Loading @@ -80,8 +80,9 @@ public class ForceWeatherRequestWorker extends WeatherRequestWorker { mGpsLocation = location; } else if (location.getProvider().equals(LocationManager.NETWORK_PROVIDER)) { mNetworkLocation = location; requestWeatherUpdate(getApplicationContext(), getMostRecentLocation()); } requestWeatherUpdate(getApplicationContext(), getMostRecentLocation()); } private Location getMostRecentLocation() { Loading @@ -104,6 +105,7 @@ public class ForceWeatherRequestWorker extends WeatherRequestWorker { private static Boolean isWeatherForceRequestAllowed(Context context) { long elapsedTime = SystemClock.elapsedRealtime() - Preferences.lastWeatherUpdateTryTimestamp(context); Log.i(TAG, "elapstedTime=" + elapsedTime + " vs refreshPeriod=" + WEATHER_REQUEST_PERIOD_TRY_IN_MS); boolean isRequestAllowed = elapsedTime >= WEATHER_REQUEST_PERIOD_TRY_IN_MS; if (isRequestAllowed) { Loading
app/src/main/java/foundation/e/blisslauncher/features/weather/worker/OneShotWeatherRequestWorker.java +8 −1 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ package foundation.e.blisslauncher.features.weather.worker; import android.annotation.SuppressLint; import android.content.Context; import android.os.SystemClock; import android.util.Log; import androidx.annotation.NonNull; import androidx.work.ExistingWorkPolicy; Loading Loading @@ -44,6 +45,12 @@ public class OneShotWeatherRequestWorker extends WeatherRequestWorker { long refreshPeriod = Preferences.weatherRefreshIntervalInMs(context); long elapsedTime = SystemClock.elapsedRealtime() - Preferences.lastWeatherUpdateTimestamp(context); return refreshPeriod != 0 && elapsedTime >= refreshPeriod; Log.i(TAG, "elapstedTime=" + elapsedTime + " vs refreshPeriod=" + refreshPeriod); boolean isRequestAllowed = refreshPeriod != 0 && elapsedTime >= refreshPeriod; if (isRequestAllowed) { Preferences.setLastWeatherUpdateTimestamp(context, SystemClock.elapsedRealtime()); } return isRequestAllowed; } }