Loading app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherUpdater.java +7 −10 Original line number Diff line number Diff line Loading @@ -55,8 +55,6 @@ public class WeatherUpdater { long refreshPeriod = Preferences.weatherRefreshIntervalInMs(context); long elapsedTime = Math.abs(SystemClock.elapsedRealtime() - Preferences.lastWeatherUpdateTimestamp(context)); Log.i(TAG, "elapsedTime=" + elapsedTime + " vs refreshPeriod=" + refreshPeriod); boolean isPeriodicRequestAllowed = refreshPeriod != 0 && elapsedTime >= refreshPeriod; if (isPeriodicRequestAllowed) { forceWeatherRequest(); Loading @@ -72,14 +70,13 @@ public class WeatherUpdater { private boolean canForceWeatherRequest() { Context context = mWeakContext.get(); long elapsedTime = Math.abs(SystemClock.elapsedRealtime() - Preferences.getForceRequestLastTry(context)); boolean isRequestAllowed = elapsedTime >= mForceRequestPeriodInMs || mForceRequestPeriodInMs == Preferences.weatherRefreshIntervalInMs(context); boolean isRequestAllowed = elapsedTime >= mForceRequestPeriodInMs; if (isRequestAllowed) { Preferences.setForceRequestLastTry(context, SystemClock.elapsedRealtime()); } else { Log.w(TAG, "Cannot force weather update too frequently. Period is " + mForceRequestPeriodInMs + "ms."); } return isRequestAllowed; Loading @@ -98,10 +95,9 @@ public class WeatherUpdater { private void increaseForceRequestPeriod() { mForceRequestPeriodInMs = mForceRequestPeriodInMs * 2; long requestPeriod = Preferences.weatherRefreshIntervalInMs(mWeakContext.get()); if (mForceRequestPeriodInMs > requestPeriod) { mForceRequestPeriodInMs = requestPeriod; if (mForceRequestPeriodInMs > Preferences.weatherRefreshIntervalInMs(mWeakContext.get())) { mForceRequestPeriodInMs = DEFAULT_FORCE_REQUEST_PERIOD_IN_MS; } } Loading Loading @@ -144,6 +140,7 @@ public class WeatherUpdater { private synchronized void onNewLocationFetched(@Nullable Location location) { if (location == null) { Log.w(TAG, "Could not fetch any location"); return; } Loading @@ -158,7 +155,7 @@ public class WeatherUpdater { requestWeatherUpdate(getMostRecentLocation()); } protected void notifyUi(@NonNull Context context, @Nullable WeatherInfo weatherInfo, int status) { private void notifyUi(@NonNull Context context, @Nullable WeatherInfo weatherInfo, int status) { if (weatherInfo == null) { Log.i(TAG, "WeatherInfo is null. Status reported: " + status); Loading Loading
app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherUpdater.java +7 −10 Original line number Diff line number Diff line Loading @@ -55,8 +55,6 @@ public class WeatherUpdater { long refreshPeriod = Preferences.weatherRefreshIntervalInMs(context); long elapsedTime = Math.abs(SystemClock.elapsedRealtime() - Preferences.lastWeatherUpdateTimestamp(context)); Log.i(TAG, "elapsedTime=" + elapsedTime + " vs refreshPeriod=" + refreshPeriod); boolean isPeriodicRequestAllowed = refreshPeriod != 0 && elapsedTime >= refreshPeriod; if (isPeriodicRequestAllowed) { forceWeatherRequest(); Loading @@ -72,14 +70,13 @@ public class WeatherUpdater { private boolean canForceWeatherRequest() { Context context = mWeakContext.get(); long elapsedTime = Math.abs(SystemClock.elapsedRealtime() - Preferences.getForceRequestLastTry(context)); boolean isRequestAllowed = elapsedTime >= mForceRequestPeriodInMs || mForceRequestPeriodInMs == Preferences.weatherRefreshIntervalInMs(context); boolean isRequestAllowed = elapsedTime >= mForceRequestPeriodInMs; if (isRequestAllowed) { Preferences.setForceRequestLastTry(context, SystemClock.elapsedRealtime()); } else { Log.w(TAG, "Cannot force weather update too frequently. Period is " + mForceRequestPeriodInMs + "ms."); } return isRequestAllowed; Loading @@ -98,10 +95,9 @@ public class WeatherUpdater { private void increaseForceRequestPeriod() { mForceRequestPeriodInMs = mForceRequestPeriodInMs * 2; long requestPeriod = Preferences.weatherRefreshIntervalInMs(mWeakContext.get()); if (mForceRequestPeriodInMs > requestPeriod) { mForceRequestPeriodInMs = requestPeriod; if (mForceRequestPeriodInMs > Preferences.weatherRefreshIntervalInMs(mWeakContext.get())) { mForceRequestPeriodInMs = DEFAULT_FORCE_REQUEST_PERIOD_IN_MS; } } Loading Loading @@ -144,6 +140,7 @@ public class WeatherUpdater { private synchronized void onNewLocationFetched(@Nullable Location location) { if (location == null) { Log.w(TAG, "Could not fetch any location"); return; } Loading @@ -158,7 +155,7 @@ public class WeatherUpdater { requestWeatherUpdate(getMostRecentLocation()); } protected void notifyUi(@NonNull Context context, @Nullable WeatherInfo weatherInfo, int status) { private void notifyUi(@NonNull Context context, @Nullable WeatherInfo weatherInfo, int status) { if (weatherInfo == null) { Log.i(TAG, "WeatherInfo is null. Status reported: " + status); Loading