Loading app/src/apiOreo/java/foundation/e/blisslauncher/features/weather/worker/ForceWeatherRequestWorker.java +1 −6 Original line number Diff line number Diff line Loading @@ -75,16 +75,11 @@ public class ForceWeatherRequestWorker extends WeatherRequestWorker { mGpsLocation = location; } else if (location.getProvider().equals("network")) { mNetworkLocation = location; } try { requestWeatherUpdate(getApplicationContext(), getMostRecentLocation()); } catch (IllegalStateException exception) { Log.e(TAG, "Illegal state has been faced. Could not update location."); } } private Location getMostRecentLocation() throws IllegalStateException { private Location getMostRecentLocation() { if (mNetworkLocation == null && mGpsLocation == null) { throw new IllegalStateException(); } Loading app/src/apiOreo/java/foundation/e/blisslauncher/features/weather/worker/WeatherRequestWorker.java +5 −3 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ import android.location.Location; import android.location.LocationManager; import android.os.SystemClock; import android.util.Log; import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; Loading Loading @@ -39,17 +40,18 @@ public abstract class WeatherRequestWorker extends Worker { protected static void requestWeatherUpdate(Context context, Location location) { Log.i(TAG, "Requesting weather info for location: " + location); LineageWeatherManager weatherManager = LineageWeatherManager.getInstance(context); weatherManager.requestWeatherUpdate(location, (info, weatherInfo) -> notifyUi(context, weatherInfo)); weatherManager.requestWeatherUpdate(location, (info, weatherInfo) -> notifyUi(context, weatherInfo, info)); } protected static void requestCustomWeatherUpdate(Context context, WeatherLocation location) { Log.i(TAG, "Requesting weather info for location: " + location); LineageWeatherManager weatherManager = LineageWeatherManager.getInstance(context); weatherManager.requestWeatherUpdate(location, (info, weatherInfo) -> notifyUi(context, weatherInfo)); weatherManager.requestWeatherUpdate(location, (info, weatherInfo) -> notifyUi(context, weatherInfo, info)); } protected static void notifyUi(@NonNull Context context, @Nullable WeatherInfo weatherInfo) { protected static void notifyUi(@NonNull Context context, @Nullable WeatherInfo weatherInfo, int info) { if (weatherInfo == null) { Toast.makeText(context, "Weather API returned an error: " + info, Toast.LENGTH_SHORT).show(); return; } Loading Loading
app/src/apiOreo/java/foundation/e/blisslauncher/features/weather/worker/ForceWeatherRequestWorker.java +1 −6 Original line number Diff line number Diff line Loading @@ -75,16 +75,11 @@ public class ForceWeatherRequestWorker extends WeatherRequestWorker { mGpsLocation = location; } else if (location.getProvider().equals("network")) { mNetworkLocation = location; } try { requestWeatherUpdate(getApplicationContext(), getMostRecentLocation()); } catch (IllegalStateException exception) { Log.e(TAG, "Illegal state has been faced. Could not update location."); } } private Location getMostRecentLocation() throws IllegalStateException { private Location getMostRecentLocation() { if (mNetworkLocation == null && mGpsLocation == null) { throw new IllegalStateException(); } Loading
app/src/apiOreo/java/foundation/e/blisslauncher/features/weather/worker/WeatherRequestWorker.java +5 −3 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ import android.location.Location; import android.location.LocationManager; import android.os.SystemClock; import android.util.Log; import android.widget.Toast; import androidx.annotation.NonNull; import androidx.annotation.Nullable; Loading Loading @@ -39,17 +40,18 @@ public abstract class WeatherRequestWorker extends Worker { protected static void requestWeatherUpdate(Context context, Location location) { Log.i(TAG, "Requesting weather info for location: " + location); LineageWeatherManager weatherManager = LineageWeatherManager.getInstance(context); weatherManager.requestWeatherUpdate(location, (info, weatherInfo) -> notifyUi(context, weatherInfo)); weatherManager.requestWeatherUpdate(location, (info, weatherInfo) -> notifyUi(context, weatherInfo, info)); } protected static void requestCustomWeatherUpdate(Context context, WeatherLocation location) { Log.i(TAG, "Requesting weather info for location: " + location); LineageWeatherManager weatherManager = LineageWeatherManager.getInstance(context); weatherManager.requestWeatherUpdate(location, (info, weatherInfo) -> notifyUi(context, weatherInfo)); weatherManager.requestWeatherUpdate(location, (info, weatherInfo) -> notifyUi(context, weatherInfo, info)); } protected static void notifyUi(@NonNull Context context, @Nullable WeatherInfo weatherInfo) { protected static void notifyUi(@NonNull Context context, @Nullable WeatherInfo weatherInfo, int info) { if (weatherInfo == null) { Toast.makeText(context, "Weather API returned an error: " + info, Toast.LENGTH_SHORT).show(); return; } Loading