Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wxNow = (Complications.getComplication(wxId)).value;
- if (wxNow == null && hasWx) {
- var tempTemp = Weather.getCurrentConditions();
- if (tempTemp != null) {
- wxNow = tempTemp.temperature;
- }
- if (wxNow != null) {
- // not sure why -99.0 is used as an indicator of an invalid value when null
- // would work just as well
- //
- // it just makes your code more complex tbh, as all
- // future code which handles wxNow will have to
- // look out for this special "magic number",
- // especially code which displays wxNow.
- // (unless it's intended to display -99.0 when
- // the temperature is unavailable)
- wxNow = -99.0;
- }
- }
- // since it's possible for wxNow to be a Number,
- // ensure it's a Float. this not only solves the issue
- // with the following conversion to fahrenheit (although that
- // could've been easily solved by changing 9 to 9.0 or
- // 5 to 5.0), but it also ensures
- // whatever code handles/displays wxNow later will
- // always see a consistent type (Float rather than Number)
- wxNow = wxNow.toFloat();
- if ((ForC != System.UNIT_METRIC) && (wxNow != -99.0)) {
- wxNow = (wxNow * 9 / 5 + 32);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement