Loading app/src/main/java/foundation/e/blisslauncher/core/Preferences.java +0 −8 Original line number Diff line number Diff line Loading @@ -244,14 +244,6 @@ public class Preferences { getPrefs(context).edit().putLong(Constants.WEATHER_LAST_UPDATE, timestamp).apply(); } public static long lastWeatherUpdateTryTimestamp(Context context) { return getPrefs(context).getLong(Constants.WEATHER_LAST_TRY, 0); } public static void setLastWeatherUpdateTryTimestamp(Context context, long timestamp) { getPrefs(context).edit().putLong(Constants.WEATHER_LAST_TRY, timestamp).apply(); } public static WeatherInfo getCachedWeatherInfo(Context context) { final String cachedInfo = getPrefs(context).getString(Constants.WEATHER_DATA, null); Loading app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherUpdateService.java +0 −4 Original line number Diff line number Diff line Loading @@ -10,7 +10,6 @@ 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 @@ -35,9 +34,6 @@ 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 +1 −17 Original line number Diff line number Diff line Loading @@ -4,7 +4,6 @@ import android.annotation.SuppressLint; import android.content.Context; import android.location.Location; import android.location.LocationManager; import android.os.SystemClock; import android.util.Log; import androidx.annotation.NonNull; Loading @@ -22,7 +21,7 @@ public class ForceWeatherRequestWorker extends WeatherRequestWorker { private static final String TAG = "ForceWeatherRequestWorker"; private static final int WEATHER_REQUEST_PERIOD_TRY_IN_MS = 60000; public static final int WEATHER_REQUEST_PERIOD_TRY_IN_MS = 60000; private Location mGpsLocation; private Location mNetworkLocation; Loading @@ -42,9 +41,6 @@ public class ForceWeatherRequestWorker extends WeatherRequestWorker { @Override public Result doWork() { Context context = getApplicationContext(); if (!isWeatherForceRequestAllowed(context)) { return Result.failure(); } if (Preferences.useCustomWeatherLocation(context)) { requestCustomWeatherUpdate(context, Preferences.getCustomWeatherLocation(context)); Loading Loading @@ -102,16 +98,4 @@ public class ForceWeatherRequestWorker extends WeatherRequestWorker { long networkTime = mNetworkLocation.getTime(); return gpsTime >= networkTime ? mGpsLocation : mNetworkLocation; } 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) { Preferences.setLastWeatherUpdateTryTimestamp(context, SystemClock.elapsedRealtime()); } return isRequestAllowed; } } app/src/main/java/foundation/e/blisslauncher/features/weather/worker/OneShotWeatherRequestWorker.java +2 −2 Original line number Diff line number Diff line Loading @@ -43,9 +43,9 @@ public class OneShotWeatherRequestWorker extends WeatherRequestWorker { private static Boolean isWeatherRequestAllowed(Context context) { long refreshPeriod = Preferences.weatherRefreshIntervalInMs(context); long elapsedTime = SystemClock.elapsedRealtime() - Preferences.lastWeatherUpdateTimestamp(context); long elapsedTime = Math.abs(SystemClock.elapsedRealtime() - Preferences.lastWeatherUpdateTimestamp(context)); Log.i(TAG, "elapstedTime=" + elapsedTime + " vs refreshPeriod=" + refreshPeriod); Log.i(TAG, "elapsedTime=" + elapsedTime + " vs refreshPeriod=" + refreshPeriod); boolean isRequestAllowed = refreshPeriod != 0 && elapsedTime >= refreshPeriod; if (isRequestAllowed) { Preferences.setLastWeatherUpdateTimestamp(context, SystemClock.elapsedRealtime()); Loading Loading
app/src/main/java/foundation/e/blisslauncher/core/Preferences.java +0 −8 Original line number Diff line number Diff line Loading @@ -244,14 +244,6 @@ public class Preferences { getPrefs(context).edit().putLong(Constants.WEATHER_LAST_UPDATE, timestamp).apply(); } public static long lastWeatherUpdateTryTimestamp(Context context) { return getPrefs(context).getLong(Constants.WEATHER_LAST_TRY, 0); } public static void setLastWeatherUpdateTryTimestamp(Context context, long timestamp) { getPrefs(context).edit().putLong(Constants.WEATHER_LAST_TRY, timestamp).apply(); } public static WeatherInfo getCachedWeatherInfo(Context context) { final String cachedInfo = getPrefs(context).getString(Constants.WEATHER_DATA, null); Loading
app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherUpdateService.java +0 −4 Original line number Diff line number Diff line Loading @@ -10,7 +10,6 @@ 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 @@ -35,9 +34,6 @@ 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 +1 −17 Original line number Diff line number Diff line Loading @@ -4,7 +4,6 @@ import android.annotation.SuppressLint; import android.content.Context; import android.location.Location; import android.location.LocationManager; import android.os.SystemClock; import android.util.Log; import androidx.annotation.NonNull; Loading @@ -22,7 +21,7 @@ public class ForceWeatherRequestWorker extends WeatherRequestWorker { private static final String TAG = "ForceWeatherRequestWorker"; private static final int WEATHER_REQUEST_PERIOD_TRY_IN_MS = 60000; public static final int WEATHER_REQUEST_PERIOD_TRY_IN_MS = 60000; private Location mGpsLocation; private Location mNetworkLocation; Loading @@ -42,9 +41,6 @@ public class ForceWeatherRequestWorker extends WeatherRequestWorker { @Override public Result doWork() { Context context = getApplicationContext(); if (!isWeatherForceRequestAllowed(context)) { return Result.failure(); } if (Preferences.useCustomWeatherLocation(context)) { requestCustomWeatherUpdate(context, Preferences.getCustomWeatherLocation(context)); Loading Loading @@ -102,16 +98,4 @@ public class ForceWeatherRequestWorker extends WeatherRequestWorker { long networkTime = mNetworkLocation.getTime(); return gpsTime >= networkTime ? mGpsLocation : mNetworkLocation; } 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) { Preferences.setLastWeatherUpdateTryTimestamp(context, SystemClock.elapsedRealtime()); } return isRequestAllowed; } }
app/src/main/java/foundation/e/blisslauncher/features/weather/worker/OneShotWeatherRequestWorker.java +2 −2 Original line number Diff line number Diff line Loading @@ -43,9 +43,9 @@ public class OneShotWeatherRequestWorker extends WeatherRequestWorker { private static Boolean isWeatherRequestAllowed(Context context) { long refreshPeriod = Preferences.weatherRefreshIntervalInMs(context); long elapsedTime = SystemClock.elapsedRealtime() - Preferences.lastWeatherUpdateTimestamp(context); long elapsedTime = Math.abs(SystemClock.elapsedRealtime() - Preferences.lastWeatherUpdateTimestamp(context)); Log.i(TAG, "elapstedTime=" + elapsedTime + " vs refreshPeriod=" + refreshPeriod); Log.i(TAG, "elapsedTime=" + elapsedTime + " vs refreshPeriod=" + refreshPeriod); boolean isRequestAllowed = refreshPeriod != 0 && elapsedTime >= refreshPeriod; if (isRequestAllowed) { Preferences.setLastWeatherUpdateTimestamp(context, SystemClock.elapsedRealtime()); Loading