private void updateDisplay() { CurrentWeather mCurrentWeather = mForecast.getCurrentWeather(); mTimeLabel.setText("At " + mCurrentWeather.getFormattedTime() + " it will be"); mTempratureLabel.setText(mCurrentWeather.getTempInCelcius() + ""); mHumidityValue.setText(mCurrentWeather.getHumidity() + ""); mPrecipValue.setText(mCurrentWeather.getChanceOfRain() + "%"); mSummary.setText("The weather is " + mCurrentWeather.getSummary()); Drawable drawable = getResources().getDrawable(mCurrentWeather.getIconId()); mIconImage.setImageDrawable(drawable); }
private CurrentWeather getCurrentData(String jsonData) throws JSONException { CurrentWeather currentWeather = new CurrentWeather(); JSONObject forecastJson = new JSONObject(jsonData); currentWeather.setTimeZone(forecastJson.getString("timezone")); JSONObject currentlyJson = forecastJson.getJSONObject("currently"); currentWeather.setTime(currentlyJson.getLong("time")); currentWeather.setChanceOfRain(currentlyJson.getLong("precipProbability")); currentWeather.setHumidity(currentlyJson.getLong("humidity")); currentWeather.setTemprature(currentlyJson.getLong("temperature")); currentWeather.setSummary(currentlyJson.getString("summary")); currentWeather.setIcon(currentlyJson.getString("icon")); Log.d(TAG, "Formatted Date Time: " + currentWeather.getFormattedTime()); return currentWeather; }