diff --git a/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherUpdater.java b/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherUpdater.java index caa76ee31fec00d9a8d3f473586d1407557970bb..d689506dc72581a94ec455ddf87c5009acd40b66 100644 --- a/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherUpdater.java +++ b/app/src/main/java/foundation/e/blisslauncher/features/weather/WeatherUpdater.java @@ -17,6 +17,7 @@ import androidx.core.location.LocationManagerCompat; import androidx.localbroadcastmanager.content.LocalBroadcastManager; import com.google.gson.JsonArray; +import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.JsonSyntaxException; @@ -243,10 +244,20 @@ public class WeatherUpdater { String countryCode = Locale.getDefault().getCountry().toLowerCase(Locale.ROOT); if (!locales.has(countryCode)) { - countryCode = locales.get("en").getAsString(); + final JsonElement jsonElement = locales.get("en"); + if (jsonElement == null) { + return; + } + + countryCode = jsonElement.getAsString(); + } + + final JsonElement jsonElement = locales.get(countryCode); + if (jsonElement == null) { + return; } - final String city = locales.get(countryCode).getAsString(); + final String city = jsonElement.getAsString(); notifyUi(city); }