Esempio n. 1
0
  private Current getCurrentDetails(String jsonData) throws JSONException {
    JSONObject forecast = new JSONObject(jsonData);
    String timezone = forecast.getString("timezone");
    Log.i(TAG, "From JSON: " + timezone);

    JSONObject currently = forecast.getJSONObject("currently");

    Current current = new Current();

    current.setHumidity(currently.getDouble("humidity"));
    current.setTime(currently.getLong("time"));
    current.setIcon(currently.getString("icon"));
    current.setPrecipChance(currently.getDouble("precipProbability"));
    current.setSummary(currently.getString("summary"));
    current.setTemperature(currently.getDouble("temperature"));
    current.setTimeZone(timezone);

    Log.d(TAG, current.getFormattedTime());

    return current;
  }
Esempio n. 2
0
 private void updateDisplay() {
   Current current = mForecast.getCurrent();
   mLocationLabel.setText(LOCATION_NAME);
   mTemperatureLabel.setText(current.getTemperature() + "");
   mTimeLabel.setText("At " + current.getFormattedTime() + " it will be");
   mHumidityValue.setText(current.getHumidity() + "");
   mPrecipValue.setText(current.getPrecipChance() + "%");
   mSummaryLabel.setText(current.getSummary());
   Drawable drawable = getResources().getDrawable(mForecast.getCurrent().getIconId());
   mIconImageView.setImageDrawable(drawable);
 }