From cd40478b3f7e3cfe87303d3cf0ace1b7ba39dc36 Mon Sep 17 00:00:00 2001 From: TaaviE Date: Sun, 20 Jun 2021 14:57:22 +0300 Subject: [PATCH] Fixed a misspell and declared the conversion function as static --- .../LineageOsWeatherReceiver.java | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/LineageOsWeatherReceiver.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/LineageOsWeatherReceiver.java index ebecfbac8..991ca6da8 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/LineageOsWeatherReceiver.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/LineageOsWeatherReceiver.java @@ -16,6 +16,14 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.externalevents; +import static lineageos.providers.WeatherContract.WeatherColumns.TempUnit.FAHRENHEIT; +import static lineageos.providers.WeatherContract.WeatherColumns.WeatherCode.ISOLATED_THUNDERSHOWERS; +import static lineageos.providers.WeatherContract.WeatherColumns.WeatherCode.NOT_AVAILABLE; +import static lineageos.providers.WeatherContract.WeatherColumns.WeatherCode.SCATTERED_SNOW_SHOWERS; +import static lineageos.providers.WeatherContract.WeatherColumns.WeatherCode.SCATTERED_THUNDERSTORMS; +import static lineageos.providers.WeatherContract.WeatherColumns.WeatherCode.SHOWERS; +import static lineageos.providers.WeatherContract.WeatherColumns.WindSpeedUnit.MPH; + import android.app.AlarmManager; import android.app.PendingIntent; import android.content.BroadcastReceiver; @@ -43,14 +51,6 @@ import nodomain.freeyourgadget.gadgetbridge.model.Weather; import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec; import nodomain.freeyourgadget.gadgetbridge.util.Prefs; -import static lineageos.providers.WeatherContract.WeatherColumns.TempUnit.FAHRENHEIT; -import static lineageos.providers.WeatherContract.WeatherColumns.WeatherCode.ISOLATED_THUNDERSHOWERS; -import static lineageos.providers.WeatherContract.WeatherColumns.WeatherCode.NOT_AVAILABLE; -import static lineageos.providers.WeatherContract.WeatherColumns.WeatherCode.SCATTERED_SNOW_SHOWERS; -import static lineageos.providers.WeatherContract.WeatherColumns.WeatherCode.SCATTERED_THUNDERSTORMS; -import static lineageos.providers.WeatherContract.WeatherColumns.WeatherCode.SHOWERS; -import static lineageos.providers.WeatherContract.WeatherColumns.WindSpeedUnit.MPH; - @RequiresApi(api = Build.VERSION_CODES.M) public class LineageOsWeatherReceiver extends BroadcastReceiver implements LineageWeatherManager.WeatherUpdateRequestListener, LineageWeatherManager.LookupCityRequestListener { @@ -136,6 +136,26 @@ public class LineageOsWeatherReceiver extends BroadcastReceiver implements Linea } } + /** + * @param cmCondition LineageOS/CyanogenMod condition code + * @return Yahoo condition code + */ + private static int LineageOSToYahooCondition(int cmCondition) { + int yahooCondition; + if (cmCondition <= SHOWERS) { + yahooCondition = cmCondition; + } else if (cmCondition <= SCATTERED_THUNDERSTORMS) { + yahooCondition = cmCondition + 1; + } else if (cmCondition <= SCATTERED_SNOW_SHOWERS) { + yahooCondition = cmCondition + 2; + } else if (cmCondition <= ISOLATED_THUNDERSHOWERS) { + yahooCondition = cmCondition + 3; + } else { + yahooCondition = NOT_AVAILABLE; + } + return yahooCondition; + } + @Override public void onWeatherRequestCompleted(int status, WeatherInfo weatherInfo) { if (weatherInfo != null) { @@ -160,7 +180,7 @@ public class LineageOsWeatherReceiver extends BroadcastReceiver implements Linea } weatherSpec.windDirection = (int) weatherInfo.getWindDirection(); - weatherSpec.currentConditionCode = Weather.mapToOpenWeatherMapCondition(LineageOstoYahooCondintion(weatherInfo.getConditionCode())); + weatherSpec.currentConditionCode = Weather.mapToOpenWeatherMapCondition(LineageOSToYahooCondition(weatherInfo.getConditionCode())); weatherSpec.currentCondition = Weather.getConditionString(weatherSpec.currentConditionCode); weatherSpec.currentHumidity = (int) weatherInfo.getHumidity(); @@ -176,7 +196,7 @@ public class LineageOsWeatherReceiver extends BroadcastReceiver implements Linea gbForecast.maxTemp = (int) cmForecast.getHigh() + 273; gbForecast.minTemp = (int) cmForecast.getLow() + 273; } - gbForecast.conditionCode = Weather.mapToOpenWeatherMapCondition(LineageOstoYahooCondintion(cmForecast.getConditionCode())); + gbForecast.conditionCode = Weather.mapToOpenWeatherMapCondition(LineageOSToYahooCondition(cmForecast.getConditionCode())); weatherSpec.forecasts.add(gbForecast); } Weather.getInstance().setWeatherSpec(weatherSpec); @@ -186,26 +206,6 @@ public class LineageOsWeatherReceiver extends BroadcastReceiver implements Linea } } - /** - * @param cmCondition - * @return - */ - private int LineageOstoYahooCondintion(int cmCondition) { - int yahooCondition; - if (cmCondition <= SHOWERS) { - yahooCondition = cmCondition; - } else if (cmCondition <= SCATTERED_THUNDERSTORMS) { - yahooCondition = cmCondition + 1; - } else if (cmCondition <= SCATTERED_SNOW_SHOWERS) { - yahooCondition = cmCondition + 2; - } else if (cmCondition <= ISOLATED_THUNDERSHOWERS) { - yahooCondition = cmCondition + 3; - } else { - yahooCondition = NOT_AVAILABLE; - } - return yahooCondition; - } - @Override public void onLookupCityRequestCompleted(int result, List list) { if (list != null) {