Android Open Source - android-weather-demo-application Result D T O






From Project

Back to project page android-weather-demo-application.

License

The source code is released under:

GNU General Public License

If you think the Android project android-weather-demo-application listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.openweathermap.dto;
//from  w  w w .j  av a2  s .  c o  m
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.openweathermap.dto.base.IDTO;

/**
 * NOTE: This class should be auto generated from a web service spec
 * @author samkirton
 */
public class ResultDTO implements IDTO {
  private String mCod;
  private String mMessage;
  private int mCount;
  private CityDTO mCity;
  private DayDTO[] mDayList;
  
  public String getCod() {
    return mCod;
  }
  
  public void setCod(String newVal) {
    mCod = newVal;
  }
  
  public String getMessage() {
    return mMessage;
  }
  
  public void setMessage(String newVal) {
    mMessage = newVal;
  }
  
  public int getCount() {
    return mCount;
  }
  
  public void setCount(int newVal) {
    mCount = newVal;
  }
  
  public CityDTO getCity() {
    return mCity;
  }
  
  public void setCity(CityDTO newVal) {
    mCity = newVal;
  }
  
  public DayDTO[] getDay() {
    return mDayList;
  }
  
  public void setDay(DayDTO[] newVal) {
    mDayList = newVal;
  }
  
  public ResultDTO() { }
  
  public ResultDTO(JSONObject jsonObject) throws JSONException {
    fromJson(jsonObject);
  }
  
  @Override
  public void fromJson(JSONObject jsonObject) throws JSONException {
    mCod = jsonObject.has("cod") ? jsonObject.getString("cod") : null;
    mMessage = jsonObject.has("message") ? jsonObject.getString("message") : null;
    mCount = jsonObject.has("cnt") ? jsonObject.getInt("cnt") : -1;
    
    if (jsonObject.has("city")) {
      JSONObject coordJSONObject = jsonObject.getJSONObject("city");
      CityDTO cityDTO = new CityDTO(coordJSONObject);
      mCity = cityDTO;
    }
    
    if (jsonObject.has("list")) {
      JSONArray jsonArrayDay = new JSONArray(jsonObject.getString("list"));
      mDayList = new DayDTO[jsonArrayDay.length()];
      for (int i = 0; i < jsonArrayDay.length(); i++) {
        DayDTO dayDTO = new DayDTO(jsonArrayDay.getJSONObject(i));
        this.mDayList[i] = dayDTO;
      }
    }
  }
}




Java Source Code List

org.openweathermap.WeatherApplication.java
org.openweathermap.activity.MainActivity.java
org.openweathermap.activity.base.BaseActivity.java
org.openweathermap.adapter.CityAdapter.java
org.openweathermap.adapter.ForecastAdapter.java
org.openweathermap.asynctask.GetCitiesAsyncTask.java
org.openweathermap.asynctask.GetLastCityAsyncTask.java
org.openweathermap.asynctask.SaveForecastAsyncTask.java
org.openweathermap.asynctask.SearchCitiesAsyncTask.java
org.openweathermap.asynctask.base.BaseAsyncTask.java
org.openweathermap.asynctask.base.BaseResponse.java
org.openweathermap.asynctask.base.IParam.java
org.openweathermap.asynctask.param.SaveForecastParam.java
org.openweathermap.asynctask.param.SearchCitiesParam.java
org.openweathermap.asynctask.response.GetCitiesResponse.java
org.openweathermap.asynctask.response.GetLastCityResponse.java
org.openweathermap.asynctask.response.SaveForecastResponse.java
org.openweathermap.dto.CityDTO.java
org.openweathermap.dto.CoordDTO.java
org.openweathermap.dto.DayDTO.java
org.openweathermap.dto.ResultDTO.java
org.openweathermap.dto.TempDTO.java
org.openweathermap.dto.WeatherDTO.java
org.openweathermap.dto.base.IDTO.java
org.openweathermap.fragment.ForecastFragment.java
org.openweathermap.fragment.ModalDialogFragment.java
org.openweathermap.fragment.SelectCountryFragment.java
org.openweathermap.sql.SQLInitProvider.java
org.openweathermap.sql.model.CityModel.java
org.openweathermap.sql.model.IconModel.java
org.openweathermap.sql.model.WeatherModel.java
org.openweathermap.utils.DateHelper.java
org.openweathermap.utils.RESTProvider.java
org.openweathermap.utils.ReflectionHelper.java
org.openweathermap.utils.ResourceHelper.java
org.openweathermap.utils.StringHelper.java
org.openweathermap.view.CityListItemView.java
org.openweathermap.view.DateDisplayView.java
org.openweathermap.view.ViewPagerFade.java
org.openweathermap.view.ViewPagerIndicatorView.java
org.openweathermap.view.WeatherDataRowView.java
org.openweathermap.volley.callback.VolleyResponseCallback.java
org.openweathermap.volley.provider.VolleyImageLoader.java
org.openweathermap.volley.provider.VolleyRequest.java