Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a507b841 authored by Danesh M's avatar Danesh M
Browse files

WeatherInfo : Catch NumberFormatException

Catch the exceptions incase of empty/invalid data.

Change-Id: I243a14ccbee53034dd39a1d79a6ab79eff4bd263
parent d83449d2
Loading
Loading
Loading
Loading
+27 −19
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ public class WeatherInfo {
    }

    private String calcDirection(Context context, String degrees) {
        try {
            int deg = Integer.parseInt(degrees);
            if (deg >= 338 || deg <= 22)
                return context.getResources().getString(R.string.weather_N);
@@ -99,9 +100,16 @@ public class WeatherInfo {
                return context.getResources().getString(R.string.weather_NW);
            else
                return "";
        } catch (NumberFormatException e) {
            return "";
        }
    }

    private String trimSpeed(String speed) {
        try {
            return String.valueOf(Math.round(Float.parseFloat(speed)));
        } catch (NumberFormatException e) {
            return "";
        }
    }
}