当前位置:   article > 正文

Android获取天气预报Demo

Android获取天气预报Demo

近期在学习Android的时候,做了一个有关天气预报的任务,本文利用Gson解析Json的方式写一个Demo给有需要的朋友作为参考

天气预报来源:和风天气 https://www.heweather.com/documents/api/v5/weather

可以在百度上找到很多提供天气的api,大家只要注册拿到key即可。

在这里附上Demo地址:Demo地址

将Demo地址中的yourkey改成你自己的key即可简单测试

天气预报返回示例:

  1. {
  2. "HeWeather5": [
  3. {
  4. "alarms": [
  5. {
  6. "level": "蓝色",
  7. "stat": "预警中",
  8. "title": "山东省青岛市气象台发布大风蓝色预警",
  9. "txt": "青岛市气象台2016年08月29日15时24分继续发布大风蓝色预警信号:预计今天下午到明天,我市北风风力海上6到7级阵风9级,陆地4到5阵风7级,请注意防范。",
  10. "type": "大风"
  11. }
  12. ],
  13. "aqi": {
  14. "city": {
  15. "aqi": "60",
  16. "co": "0",
  17. "no2": "14",
  18. "o3": "95",
  19. "pm10": "67",
  20. "pm25": "15",
  21. "qlty": "良", //共六个级别,分别:优,良,轻度污染,中度污染,重度污染,严重污染
  22. "so2": "10"
  23. }
  24. },
  25. "basic": {
  26. "city": "青岛",
  27. "cnty": "中国",
  28. "id": "CN101120201",
  29. "lat": "36.088000",
  30. "lon": "120.343000",
  31. "prov": "山东" //城市所属省份(仅限国内城市)
  32. "update": {
  33. "loc": "2016-08-30 11:52",
  34. "utc": "2016-08-30 03:52"
  35. }
  36. },
  37. "daily_forecast": [
  38. {
  39. "astro": {
  40. "mr": "03:09",
  41. "ms": "17:06",
  42. "sr": "05:28",
  43. "ss": "18:29"
  44. },
  45. "cond": {
  46. "code_d": "100",
  47. "code_n": "100",
  48. "txt_d": "晴",
  49. "txt_n": "晴"
  50. },
  51. "date": "2016-08-30",
  52. "hum": "45",
  53. "pcpn": "0.0",
  54. "pop": "8",
  55. "pres": "1005",
  56. "tmp": {
  57. "max": "29",
  58. "min": "22"
  59. },
  60. "vis": "10",
  61. "wind": {
  62. "deg": "339",
  63. "dir": "北风",
  64. "sc": "4-5",
  65. "spd": "24"
  66. }
  67. }
  68. ],
  69. "hourly_forecast": [
  70. {
  71. "cond": {
  72. "code": "100",
  73. "txt": "晴"
  74. },
  75. "date": "2016-08-30 12:00",
  76. "hum": "47",
  77. "pop": "0",
  78. "pres": "1006",
  79. "tmp": "29",
  80. "wind": {
  81. "deg": "335",
  82. "dir": "西北风",
  83. "sc": "4-5",
  84. "spd": "36"
  85. }
  86. }
  87. ],
  88. "now": {
  89. "cond": {
  90. "code": "100",
  91. "txt": "晴"
  92. },
  93. "fl": "28",
  94. "hum": "41",
  95. "pcpn": "0",
  96. "pres": "1005",
  97. "tmp": "26",
  98. "vis": "10",
  99. "wind": {
  100. "deg": "330",
  101. "dir": "西北风",
  102. "sc": "6-7",
  103. "spd": "34"
  104. }
  105. },
  106. "status": "ok",
  107. "suggestion": {
  108. "comf": {
  109. "brf": "较舒适",
  110. "txt": "白天天气晴好,您在这种天气条件下,会感觉早晚凉爽、舒适,午后偏热。"
  111. },
  112. "cw": {
  113. "brf": "较不宜",
  114. "txt": "较不宜洗车,未来一天无雨,风力较大,如果执意擦洗汽车,要做好蒙上污垢的心理准备。"
  115. },
  116. "drsg": {
  117. "brf": "热",
  118. "txt": "天气热,建议着短裙、短裤、短薄外套、T恤等夏季服装。"
  119. },
  120. "flu": {
  121. "brf": "较易发",
  122. "txt": "虽然温度适宜但风力较大,仍较易发生感冒,体质较弱的朋友请注意适当防护。"
  123. },
  124. "sport": {
  125. "brf": "较适宜",
  126. "txt": "天气较好,但风力较大,推荐您进行室内运动,若在户外运动请注意防风。"
  127. },
  128. "trav": {
  129. "brf": "适宜",
  130. "txt": "天气较好,风稍大,但温度适宜,是个好天气哦。适宜旅游,您可以尽情地享受大自然的无限风光。"
  131. },
  132. "uv": {
  133. "brf": "强",
  134. "txt": "紫外线辐射强,建议涂擦SPF20左右、PA++的防晒护肤品。避免在10点至14点暴露于日光下。"
  135. }
  136. }
  137. }
  138. ]
  139. }

那么我们先来获取一下天气预报:

因为利用get的请求方式,我们这里需要利用Volley框架

关于Volley有问题的大家也可以在度娘上找到

导包:

MainActivity.java

  1. package com.example.champ.weatherdemo;
  2. import android.app.Activity;
  3. import android.support.v7.app.AppCompatActivity;
  4. import android.os.Bundle;
  5. import android.text.Editable;
  6. import android.view.View;
  7. import android.widget.EditText;
  8. import android.widget.TextView;
  9. import com.android.volley.Request;
  10. import com.android.volley.RequestQueue;
  11. import com.android.volley.Response;
  12. import com.android.volley.VolleyError;
  13. import com.android.volley.toolbox.JsonObjectRequest;
  14. import com.android.volley.toolbox.Volley;
  15. import org.json.JSONObject;
  16. public class MainActivity extends Activity {
  17. RequestQueue queue = null;
  18. EditText et_city;
  19. Editable city;
  20. @Override
  21. protected void onCreate(Bundle savedInstanceState) {
  22. super.onCreate(savedInstanceState);
  23. setContentView(R.layout.activity_main);
  24. queue = Volley.newRequestQueue(this);
  25. et_city = (EditText) findViewById(R.id.et_city);
  26. }
  27. public void weatherClick(View view){
  28. city = et_city.getText();
  29. String url = "https://free-api.heweather.com/v5/weather?city="+city+"&key=your key";
  30. JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
  31. @Override
  32. public void onResponse(JSONObject jsonObject) {
  33. System.out.println(jsonObject);
  34. }
  35. }, new Response.ErrorListener() {
  36. @Override
  37. public void onErrorResponse(VolleyError volleyError) {
  38. System.out.println(volleyError);
  39. }
  40. });
  41. queue.add(request);
  42. }
  43. }


上面的your key 就是你申请得到的key


在AndroidManifest中添加权限:
<uses-permission android:name="android.permission.INTERNET" />
布局文件:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout
  3. xmlns:android="http://schemas.android.com/apk/res/android"
  4. android:layout_width="match_parent"
  5. android:layout_height="match_parent"
  6. android:orientation="vertical"
  7. >
  8. <LinearLayout
  9. android:layout_width="wrap_content"
  10. android:layout_height="wrap_content"
  11. android:orientation="horizontal">
  12. <EditText
  13. android:id="@+id/et_city"
  14. android:hint="请输入城市"
  15. android:layout_width="160dp"
  16. android:layout_height="wrap_content" />
  17. <Button
  18. android:id="@+id/button_click"
  19. android:onClick="weatherClick"
  20. android:layout_width="wrap_content"
  21. android:layout_height="wrap_content"
  22. android:text="查询天气"/>
  23. </LinearLayout>
  24. </LinearLayout>


运行结果如下:

查看输出:


是一大串内容,但是已经能够获取到天气了。

那么,该怎样才能够将这一大串字符解析成我们想要的呢?

这里有个非常棒的插件——GsonFormat,可以帮我们直接将Json格式的字符串自动生成实体类参数

使用方法:
方法1:








方法2:
先去网上下载GsonFormat插件,然后本地安装


安装完毕之后

新建一个类:

如新建了一个WeatherBean类

然后:Code → Generate..。 → GsonFormat ,然后将刚刚得到的那一大串字符串粘贴进去即可


这样就自动拥有了各类实体类参数


里面对应的每个字段信息,不明白的可以在和风天气的官方api文档中查看

现在来得到一下:城市、日期、温度、天气情况、风向、空气质量这六个参数

得到实验结果:


Demo代码如下:

布局文件如下:

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <LinearLayout
  3. xmlns:android="http://schemas.android.com/apk/res/android"
  4. android:layout_width="match_parent"
  5. android:layout_height="match_parent"
  6. android:orientation="vertical"
  7. >
  8. <LinearLayout
  9. android:layout_width="wrap_content"
  10. android:layout_height="wrap_content"
  11. android:orientation="horizontal">
  12. <EditText
  13. android:id="@+id/et_city"
  14. android:hint="请输入城市"
  15. android:layout_width="160dp"
  16. android:layout_height="wrap_content" />
  17. <Button
  18. android:id="@+id/button_click"
  19. android:onClick="weatherClick"
  20. android:layout_width="wrap_content"
  21. android:layout_height="wrap_content"
  22. android:text="查询天气"/>
  23. </LinearLayout>
  24. <TextView
  25. android:id="@+id/id_tv_city"
  26. android:layout_width="wrap_content"
  27. android:layout_height="wrap_content" />
  28. <TextView
  29. android:id="@+id/id_tv_date"
  30. android:layout_width="wrap_content"
  31. android:layout_height="wrap_content" />
  32. <TextView
  33. android:id="@+id/id_tv_temp"
  34. android:layout_width="wrap_content"
  35. android:layout_height="wrap_content" />
  36. <TextView
  37. android:id="@+id/id_tv_cond"
  38. android:layout_width="wrap_content"
  39. android:layout_height="wrap_content" />
  40. <TextView
  41. android:id="@+id/id_tv_dir"
  42. android:layout_width="wrap_content"
  43. android:layout_height="wrap_content" />
  44. <TextView
  45. android:id="@+id/id_tv_qlty"
  46. android:layout_width="wrap_content"
  47. android:layout_height="wrap_content" />
  48. </LinearLayout>

MainAcitvity.java

  1. package com.example.champ.weatherdemo;
  2. import android.app.Activity;
  3. import android.support.v7.app.AppCompatActivity;
  4. import android.os.Bundle;
  5. import android.text.Editable;
  6. import android.view.View;
  7. import android.widget.EditText;
  8. import android.widget.TextView;
  9. import com.android.volley.Request;
  10. import com.android.volley.RequestQueue;
  11. import com.android.volley.Response;
  12. import com.android.volley.VolleyError;
  13. import com.android.volley.toolbox.JsonObjectRequest;
  14. import com.android.volley.toolbox.Volley;
  15. import com.google.gson.Gson;
  16. import org.json.JSONObject;
  17. public class MainActivity extends Activity {
  18. RequestQueue queue = null;
  19. EditText et_city;
  20. TextView tv_city,tv_date,tv_temp,tv_cond,tv_qlty,tv_dir;
  21. Editable city;
  22. @Override
  23. protected void onCreate(Bundle savedInstanceState) {
  24. super.onCreate(savedInstanceState);
  25. setContentView(R.layout.activity_main);
  26. queue = Volley.newRequestQueue(this);
  27. et_city = (EditText) findViewById(R.id.et_city);
  28. tv_city = (TextView) findViewById(R.id.id_tv_city);
  29. tv_date = (TextView) findViewById(R.id.id_tv_date);
  30. tv_temp = (TextView) findViewById(R.id.id_tv_temp);
  31. tv_cond = (TextView) findViewById(R.id.id_tv_cond);
  32. tv_dir = (TextView) findViewById(R.id.id_tv_dir);
  33. tv_qlty = (TextView) findViewById(R.id.id_tv_qlty);
  34. }
  35. public void weatherClick(View view){
  36. city = et_city.getText();
  37. String url = "https://free-api.heweather.com/v5/weather?city="+city+"&key=your key";
  38. JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
  39. @Override
  40. public void onResponse(JSONObject jsonObject) {
  41. System.out.println(jsonObject);
  42. Gson gson =new Gson();
  43. WeatherBean weatherBean = gson.fromJson(jsonObject.toString(),WeatherBean.class);
  44. String cityName = weatherBean.getHeWeather5().get(0).getBasic().getCity();
  45. String date = weatherBean.getHeWeather5().get(0).getDaily_forecast().get(0).getDate();
  46. String temp = weatherBean.getHeWeather5().get(0).getNow().getTmp();
  47. String cond = weatherBean.getHeWeather5().get(0).getNow().getCond().getTxt();
  48. String dir = weatherBean.getHeWeather5().get(0).getNow().getWind().getDir();
  49. String qlty = weatherBean.getHeWeather5().get(0).getAqi().getCity().getQlty();
  50. tv_city.setText("城市:"+cityName);
  51. tv_date.setText("日期:"+date);
  52. tv_temp.setText("温度:"+temp);
  53. tv_cond.setText("天气情况:"+cond);
  54. tv_dir.setText("风向:"+dir);
  55. tv_qlty.setText("空气质量:"+qlty);
  56. }
  57. }, new Response.ErrorListener() {
  58. @Override
  59. public void onErrorResponse(VolleyError volleyError) {
  60. System.out.println(volleyError);
  61. }
  62. });
  63. queue.add(request);
  64. }
  65. }
WeatherBean.java

  1. package com.example.champ.weatherdemo;
  2. import java.util.List;
  3. /**
  4. * Created by champ on 2017/5/6.
  5. */
  6. public class WeatherBean {
  7. private List<HeWeather5Bean> HeWeather5;
  8. public List<HeWeather5Bean> getHeWeather5() {
  9. return HeWeather5;
  10. }
  11. public void setHeWeather5(List<HeWeather5Bean> HeWeather5) {
  12. this.HeWeather5 = HeWeather5;
  13. }
  14. public static class HeWeather5Bean {
  15. /**
  16. * aqi : {"city":{"aqi":"72","co":"1","no2":"54","o3":"76","pm10":"92","pm25":"52","qlty":"良","so2":"12"}}
  17. * basic : {"city":"杭州","cnty":"中国","id":"CN101210101","lat":"30.287459","lon":"120.153576","update":{"loc":"2017-05-06 22:51","utc":"2017-05-06 14:51"}}
  18. * daily_forecast : [{"astro":{"mr":"14:33","ms":"02:34","sr":"05:12","ss":"18:40"},"cond":{"code_d":"305","code_n":"101","txt_d":"小雨","txt_n":"多云"},"date":"2017-05-06","hum":"74","pcpn":"0.2","pop":"88","pres":"1019","tmp":{"max":"26","min":"16"},"uv":"10","vis":"13","wind":{"deg":"99","dir":"东北风","sc":"3-4","spd":"16"}},{"astro":{"mr":"15:28","ms":"03:10","sr":"05:11","ss":"18:40"},"cond":{"code_d":"104","code_n":"300","txt_d":"阴","txt_n":"阵雨"},"date":"2017-05-07","hum":"65","pcpn":"1.0","pop":"65","pres":"1017","tmp":{"max":"26","min":"16"},"uv":"11","vis":"18","wind":{"deg":"79","dir":"东风","sc":"微风","spd":"8"}},{"astro":{"mr":"16:22","ms":"03:44","sr":"05:10","ss":"18:41"},"cond":{"code_d":"306","code_n":"300","txt_d":"中雨","txt_n":"阵雨"},"date":"2017-05-08","hum":"78","pcpn":"14.6","pop":"100","pres":"1011","tmp":{"max":"20","min":"18"},"uv":"8","vis":"16","wind":{"deg":"178","dir":"西南风","sc":"微风","spd":"6"}}]
  19. * hourly_forecast : []
  20. * now : {"cond":{"code":"101","txt":"多云"},"fl":"21","hum":"78","pcpn":"0","pres":"1019","tmp":"20","vis":"8","wind":{"deg":"120","dir":"东南风","sc":"微风","spd":"7"}}
  21. * status : ok
  22. * suggestion : {"air":{"brf":"中","txt":"气象条件对空气污染物稀释、扩散和清除无明显影响,易感人群应适当减少室外活动时间。"},"comf":{"brf":"较舒适","txt":"白天天气晴好,同时较大的空气湿度,会使您在午后略感闷热,但早晚仍很凉爽、舒适。"},"cw":{"brf":"较适宜","txt":"较适宜洗车,未来一天无雨,风力较小,擦洗一新的汽车至少能保持一天。"},"drsg":{"brf":"舒适","txt":"建议着长袖T恤、衬衫加单裤等服装。年老体弱者宜着针织长袖衬衫、马甲和长裤。"},"flu":{"brf":"较易发","txt":"天气转凉,空气湿度较大,较易发生感冒,体质较弱的朋友请注意适当防护。"},"sport":{"brf":"较不宜","txt":"天气较好,但因风力较强,在户外要选择合适的运动;另外考虑到高温天气,建议停止高强度运动。"},"trav":{"brf":"适宜","txt":"天气较好,温度适宜,但风稍微有点大。这样的天气适宜旅游,您可以尽情地享受大自然的无限风光。"},"uv":{"brf":"弱","txt":"紫外线强度较弱,建议出门前涂擦SPF在12-15之间、PA+的防晒护肤品。"}}
  23. */
  24. private AqiBean aqi;
  25. private BasicBean basic;
  26. private NowBean now;
  27. private String status;
  28. private SuggestionBean suggestion;
  29. private List<DailyForecastBean> daily_forecast;
  30. private List<?> hourly_forecast;
  31. public AqiBean getAqi() {
  32. return aqi;
  33. }
  34. public void setAqi(AqiBean aqi) {
  35. this.aqi = aqi;
  36. }
  37. public BasicBean getBasic() {
  38. return basic;
  39. }
  40. public void setBasic(BasicBean basic) {
  41. this.basic = basic;
  42. }
  43. public NowBean getNow() {
  44. return now;
  45. }
  46. public void setNow(NowBean now) {
  47. this.now = now;
  48. }
  49. public String getStatus() {
  50. return status;
  51. }
  52. public void setStatus(String status) {
  53. this.status = status;
  54. }
  55. public SuggestionBean getSuggestion() {
  56. return suggestion;
  57. }
  58. public void setSuggestion(SuggestionBean suggestion) {
  59. this.suggestion = suggestion;
  60. }
  61. public List<DailyForecastBean> getDaily_forecast() {
  62. return daily_forecast;
  63. }
  64. public void setDaily_forecast(List<DailyForecastBean> daily_forecast) {
  65. this.daily_forecast = daily_forecast;
  66. }
  67. public List<?> getHourly_forecast() {
  68. return hourly_forecast;
  69. }
  70. public void setHourly_forecast(List<?> hourly_forecast) {
  71. this.hourly_forecast = hourly_forecast;
  72. }
  73. public static class AqiBean {
  74. /**
  75. * city : {"aqi":"72","co":"1","no2":"54","o3":"76","pm10":"92","pm25":"52","qlty":"良","so2":"12"}
  76. */
  77. private CityBean city;
  78. public CityBean getCity() {
  79. return city;
  80. }
  81. public void setCity(CityBean city) {
  82. this.city = city;
  83. }
  84. public static class CityBean {
  85. /**
  86. * aqi : 72
  87. * co : 1
  88. * no2 : 54
  89. * o3 : 76
  90. * pm10 : 92
  91. * pm25 : 52
  92. * qlty : 良
  93. * so2 : 12
  94. */
  95. private String aqi;
  96. private String co;
  97. private String no2;
  98. private String o3;
  99. private String pm10;
  100. private String pm25;
  101. private String qlty;
  102. private String so2;
  103. public String getAqi() {
  104. return aqi;
  105. }
  106. public void setAqi(String aqi) {
  107. this.aqi = aqi;
  108. }
  109. public String getCo() {
  110. return co;
  111. }
  112. public void setCo(String co) {
  113. this.co = co;
  114. }
  115. public String getNo2() {
  116. return no2;
  117. }
  118. public void setNo2(String no2) {
  119. this.no2 = no2;
  120. }
  121. public String getO3() {
  122. return o3;
  123. }
  124. public void setO3(String o3) {
  125. this.o3 = o3;
  126. }
  127. public String getPm10() {
  128. return pm10;
  129. }
  130. public void setPm10(String pm10) {
  131. this.pm10 = pm10;
  132. }
  133. public String getPm25() {
  134. return pm25;
  135. }
  136. public void setPm25(String pm25) {
  137. this.pm25 = pm25;
  138. }
  139. public String getQlty() {
  140. return qlty;
  141. }
  142. public void setQlty(String qlty) {
  143. this.qlty = qlty;
  144. }
  145. public String getSo2() {
  146. return so2;
  147. }
  148. public void setSo2(String so2) {
  149. this.so2 = so2;
  150. }
  151. }
  152. }
  153. public static class BasicBean {
  154. /**
  155. * city : 杭州
  156. * cnty : 中国
  157. * id : CN101210101
  158. * lat : 30.287459
  159. * lon : 120.153576
  160. * update : {"loc":"2017-05-06 22:51","utc":"2017-05-06 14:51"}
  161. */
  162. private String city;
  163. private String cnty;
  164. private String id;
  165. private String lat;
  166. private String lon;
  167. private UpdateBean update;
  168. public String getCity() {
  169. return city;
  170. }
  171. public void setCity(String city) {
  172. this.city = city;
  173. }
  174. public String getCnty() {
  175. return cnty;
  176. }
  177. public void setCnty(String cnty) {
  178. this.cnty = cnty;
  179. }
  180. public String getId() {
  181. return id;
  182. }
  183. public void setId(String id) {
  184. this.id = id;
  185. }
  186. public String getLat() {
  187. return lat;
  188. }
  189. public void setLat(String lat) {
  190. this.lat = lat;
  191. }
  192. public String getLon() {
  193. return lon;
  194. }
  195. public void setLon(String lon) {
  196. this.lon = lon;
  197. }
  198. public UpdateBean getUpdate() {
  199. return update;
  200. }
  201. public void setUpdate(UpdateBean update) {
  202. this.update = update;
  203. }
  204. public static class UpdateBean {
  205. /**
  206. * loc : 2017-05-06 22:51
  207. * utc : 2017-05-06 14:51
  208. */
  209. private String loc;
  210. private String utc;
  211. public String getLoc() {
  212. return loc;
  213. }
  214. public void setLoc(String loc) {
  215. this.loc = loc;
  216. }
  217. public String getUtc() {
  218. return utc;
  219. }
  220. public void setUtc(String utc) {
  221. this.utc = utc;
  222. }
  223. }
  224. }
  225. public static class NowBean {
  226. /**
  227. * cond : {"code":"101","txt":"多云"}
  228. * fl : 21
  229. * hum : 78
  230. * pcpn : 0
  231. * pres : 1019
  232. * tmp : 20
  233. * vis : 8
  234. * wind : {"deg":"120","dir":"东南风","sc":"微风","spd":"7"}
  235. */
  236. private CondBean cond;
  237. private String fl;
  238. private String hum;
  239. private String pcpn;
  240. private String pres;
  241. private String tmp;
  242. private String vis;
  243. private WindBean wind;
  244. public CondBean getCond() {
  245. return cond;
  246. }
  247. public void setCond(CondBean cond) {
  248. this.cond = cond;
  249. }
  250. public String getFl() {
  251. return fl;
  252. }
  253. public void setFl(String fl) {
  254. this.fl = fl;
  255. }
  256. public String getHum() {
  257. return hum;
  258. }
  259. public void setHum(String hum) {
  260. this.hum = hum;
  261. }
  262. public String getPcpn() {
  263. return pcpn;
  264. }
  265. public void setPcpn(String pcpn) {
  266. this.pcpn = pcpn;
  267. }
  268. public String getPres() {
  269. return pres;
  270. }
  271. public void setPres(String pres) {
  272. this.pres = pres;
  273. }
  274. public String getTmp() {
  275. return tmp;
  276. }
  277. public void setTmp(String tmp) {
  278. this.tmp = tmp;
  279. }
  280. public String getVis() {
  281. return vis;
  282. }
  283. public void setVis(String vis) {
  284. this.vis = vis;
  285. }
  286. public WindBean getWind() {
  287. return wind;
  288. }
  289. public void setWind(WindBean wind) {
  290. this.wind = wind;
  291. }
  292. public static class CondBean {
  293. /**
  294. * code : 101
  295. * txt : 多云
  296. */
  297. private String code;
  298. private String txt;
  299. public String getCode() {
  300. return code;
  301. }
  302. public void setCode(String code) {
  303. this.code = code;
  304. }
  305. public String getTxt() {
  306. return txt;
  307. }
  308. public void setTxt(String txt) {
  309. this.txt = txt;
  310. }
  311. }
  312. public static class WindBean {
  313. /**
  314. * deg : 120
  315. * dir : 东南风
  316. * sc : 微风
  317. * spd : 7
  318. */
  319. private String deg;
  320. private String dir;
  321. private String sc;
  322. private String spd;
  323. public String getDeg() {
  324. return deg;
  325. }
  326. public void setDeg(String deg) {
  327. this.deg = deg;
  328. }
  329. public String getDir() {
  330. return dir;
  331. }
  332. public void setDir(String dir) {
  333. this.dir = dir;
  334. }
  335. public String getSc() {
  336. return sc;
  337. }
  338. public void setSc(String sc) {
  339. this.sc = sc;
  340. }
  341. public String getSpd() {
  342. return spd;
  343. }
  344. public void setSpd(String spd) {
  345. this.spd = spd;
  346. }
  347. }
  348. }
  349. public static class SuggestionBean {
  350. /**
  351. * air : {"brf":"中","txt":"气象条件对空气污染物稀释、扩散和清除无明显影响,易感人群应适当减少室外活动时间。"}
  352. * comf : {"brf":"较舒适","txt":"白天天气晴好,同时较大的空气湿度,会使您在午后略感闷热,但早晚仍很凉爽、舒适。"}
  353. * cw : {"brf":"较适宜","txt":"较适宜洗车,未来一天无雨,风力较小,擦洗一新的汽车至少能保持一天。"}
  354. * drsg : {"brf":"舒适","txt":"建议着长袖T恤、衬衫加单裤等服装。年老体弱者宜着针织长袖衬衫、马甲和长裤。"}
  355. * flu : {"brf":"较易发","txt":"天气转凉,空气湿度较大,较易发生感冒,体质较弱的朋友请注意适当防护。"}
  356. * sport : {"brf":"较不宜","txt":"天气较好,但因风力较强,在户外要选择合适的运动;另外考虑到高温天气,建议停止高强度运动。"}
  357. * trav : {"brf":"适宜","txt":"天气较好,温度适宜,但风稍微有点大。这样的天气适宜旅游,您可以尽情地享受大自然的无限风光。"}
  358. * uv : {"brf":"弱","txt":"紫外线强度较弱,建议出门前涂擦SPF在12-15之间、PA+的防晒护肤品。"}
  359. */
  360. private AirBean air;
  361. private ComfBean comf;
  362. private CwBean cw;
  363. private DrsgBean drsg;
  364. private FluBean flu;
  365. private SportBean sport;
  366. private TravBean trav;
  367. private UvBean uv;
  368. public AirBean getAir() {
  369. return air;
  370. }
  371. public void setAir(AirBean air) {
  372. this.air = air;
  373. }
  374. public ComfBean getComf() {
  375. return comf;
  376. }
  377. public void setComf(ComfBean comf) {
  378. this.comf = comf;
  379. }
  380. public CwBean getCw() {
  381. return cw;
  382. }
  383. public void setCw(CwBean cw) {
  384. this.cw = cw;
  385. }
  386. public DrsgBean getDrsg() {
  387. return drsg;
  388. }
  389. public void setDrsg(DrsgBean drsg) {
  390. this.drsg = drsg;
  391. }
  392. public FluBean getFlu() {
  393. return flu;
  394. }
  395. public void setFlu(FluBean flu) {
  396. this.flu = flu;
  397. }
  398. public SportBean getSport() {
  399. return sport;
  400. }
  401. public void setSport(SportBean sport) {
  402. this.sport = sport;
  403. }
  404. public TravBean getTrav() {
  405. return trav;
  406. }
  407. public void setTrav(TravBean trav) {
  408. this.trav = trav;
  409. }
  410. public UvBean getUv() {
  411. return uv;
  412. }
  413. public void setUv(UvBean uv) {
  414. this.uv = uv;
  415. }
  416. public static class AirBean {
  417. /**
  418. * brf : 中
  419. * txt : 气象条件对空气污染物稀释、扩散和清除无明显影响,易感人群应适当减少室外活动时间。
  420. */
  421. private String brf;
  422. private String txt;
  423. public String getBrf() {
  424. return brf;
  425. }
  426. public void setBrf(String brf) {
  427. this.brf = brf;
  428. }
  429. public String getTxt() {
  430. return txt;
  431. }
  432. public void setTxt(String txt) {
  433. this.txt = txt;
  434. }
  435. }
  436. public static class ComfBean {
  437. /**
  438. * brf : 较舒适
  439. * txt : 白天天气晴好,同时较大的空气湿度,会使您在午后略感闷热,但早晚仍很凉爽、舒适。
  440. */
  441. private String brf;
  442. private String txt;
  443. public String getBrf() {
  444. return brf;
  445. }
  446. public void setBrf(String brf) {
  447. this.brf = brf;
  448. }
  449. public String getTxt() {
  450. return txt;
  451. }
  452. public void setTxt(String txt) {
  453. this.txt = txt;
  454. }
  455. }
  456. public static class CwBean {
  457. /**
  458. * brf : 较适宜
  459. * txt : 较适宜洗车,未来一天无雨,风力较小,擦洗一新的汽车至少能保持一天。
  460. */
  461. private String brf;
  462. private String txt;
  463. public String getBrf() {
  464. return brf;
  465. }
  466. public void setBrf(String brf) {
  467. this.brf = brf;
  468. }
  469. public String getTxt() {
  470. return txt;
  471. }
  472. public void setTxt(String txt) {
  473. this.txt = txt;
  474. }
  475. }
  476. public static class DrsgBean {
  477. /**
  478. * brf : 舒适
  479. * txt : 建议着长袖T恤、衬衫加单裤等服装。年老体弱者宜着针织长袖衬衫、马甲和长裤。
  480. */
  481. private String brf;
  482. private String txt;
  483. public String getBrf() {
  484. return brf;
  485. }
  486. public void setBrf(String brf) {
  487. this.brf = brf;
  488. }
  489. public String getTxt() {
  490. return txt;
  491. }
  492. public void setTxt(String txt) {
  493. this.txt = txt;
  494. }
  495. }
  496. public static class FluBean {
  497. /**
  498. * brf : 较易发
  499. * txt : 天气转凉,空气湿度较大,较易发生感冒,体质较弱的朋友请注意适当防护。
  500. */
  501. private String brf;
  502. private String txt;
  503. public String getBrf() {
  504. return brf;
  505. }
  506. public void setBrf(String brf) {
  507. this.brf = brf;
  508. }
  509. public String getTxt() {
  510. return txt;
  511. }
  512. public void setTxt(String txt) {
  513. this.txt = txt;
  514. }
  515. }
  516. public static class SportBean {
  517. /**
  518. * brf : 较不宜
  519. * txt : 天气较好,但因风力较强,在户外要选择合适的运动;另外考虑到高温天气,建议停止高强度运动。
  520. */
  521. private String brf;
  522. private String txt;
  523. public String getBrf() {
  524. return brf;
  525. }
  526. public void setBrf(String brf) {
  527. this.brf = brf;
  528. }
  529. public String getTxt() {
  530. return txt;
  531. }
  532. public void setTxt(String txt) {
  533. this.txt = txt;
  534. }
  535. }
  536. public static class TravBean {
  537. /**
  538. * brf : 适宜
  539. * txt : 天气较好,温度适宜,但风稍微有点大。这样的天气适宜旅游,您可以尽情地享受大自然的无限风光。
  540. */
  541. private String brf;
  542. private String txt;
  543. public String getBrf() {
  544. return brf;
  545. }
  546. public void setBrf(String brf) {
  547. this.brf = brf;
  548. }
  549. public String getTxt() {
  550. return txt;
  551. }
  552. public void setTxt(String txt) {
  553. this.txt = txt;
  554. }
  555. }
  556. public static class UvBean {
  557. /**
  558. * brf : 弱
  559. * txt : 紫外线强度较弱,建议出门前涂擦SPF在12-15之间、PA+的防晒护肤品。
  560. */
  561. private String brf;
  562. private String txt;
  563. public String getBrf() {
  564. return brf;
  565. }
  566. public void setBrf(String brf) {
  567. this.brf = brf;
  568. }
  569. public String getTxt() {
  570. return txt;
  571. }
  572. public void setTxt(String txt) {
  573. this.txt = txt;
  574. }
  575. }
  576. }
  577. public static class DailyForecastBean {
  578. /**
  579. * astro : {"mr":"14:33","ms":"02:34","sr":"05:12","ss":"18:40"}
  580. * cond : {"code_d":"305","code_n":"101","txt_d":"小雨","txt_n":"多云"}
  581. * date : 2017-05-06
  582. * hum : 74
  583. * pcpn : 0.2
  584. * pop : 88
  585. * pres : 1019
  586. * tmp : {"max":"26","min":"16"}
  587. * uv : 10
  588. * vis : 13
  589. * wind : {"deg":"99","dir":"东北风","sc":"3-4","spd":"16"}
  590. */
  591. private AstroBean astro;
  592. private CondBeanX cond;
  593. private String date;
  594. private String hum;
  595. private String pcpn;
  596. private String pop;
  597. private String pres;
  598. private TmpBean tmp;
  599. private String uv;
  600. private String vis;
  601. private WindBeanX wind;
  602. public AstroBean getAstro() {
  603. return astro;
  604. }
  605. public void setAstro(AstroBean astro) {
  606. this.astro = astro;
  607. }
  608. public CondBeanX getCond() {
  609. return cond;
  610. }
  611. public void setCond(CondBeanX cond) {
  612. this.cond = cond;
  613. }
  614. public String getDate() {
  615. return date;
  616. }
  617. public void setDate(String date) {
  618. this.date = date;
  619. }
  620. public String getHum() {
  621. return hum;
  622. }
  623. public void setHum(String hum) {
  624. this.hum = hum;
  625. }
  626. public String getPcpn() {
  627. return pcpn;
  628. }
  629. public void setPcpn(String pcpn) {
  630. this.pcpn = pcpn;
  631. }
  632. public String getPop() {
  633. return pop;
  634. }
  635. public void setPop(String pop) {
  636. this.pop = pop;
  637. }
  638. public String getPres() {
  639. return pres;
  640. }
  641. public void setPres(String pres) {
  642. this.pres = pres;
  643. }
  644. public TmpBean getTmp() {
  645. return tmp;
  646. }
  647. public void setTmp(TmpBean tmp) {
  648. this.tmp = tmp;
  649. }
  650. public String getUv() {
  651. return uv;
  652. }
  653. public void setUv(String uv) {
  654. this.uv = uv;
  655. }
  656. public String getVis() {
  657. return vis;
  658. }
  659. public void setVis(String vis) {
  660. this.vis = vis;
  661. }
  662. public WindBeanX getWind() {
  663. return wind;
  664. }
  665. public void setWind(WindBeanX wind) {
  666. this.wind = wind;
  667. }
  668. public static class AstroBean {
  669. /**
  670. * mr : 14:33
  671. * ms : 02:34
  672. * sr : 05:12
  673. * ss : 18:40
  674. */
  675. private String mr;
  676. private String ms;
  677. private String sr;
  678. private String ss;
  679. public String getMr() {
  680. return mr;
  681. }
  682. public void setMr(String mr) {
  683. this.mr = mr;
  684. }
  685. public String getMs() {
  686. return ms;
  687. }
  688. public void setMs(String ms) {
  689. this.ms = ms;
  690. }
  691. public String getSr() {
  692. return sr;
  693. }
  694. public void setSr(String sr) {
  695. this.sr = sr;
  696. }
  697. public String getSs() {
  698. return ss;
  699. }
  700. public void setSs(String ss) {
  701. this.ss = ss;
  702. }
  703. }
  704. public static class CondBeanX {
  705. /**
  706. * code_d : 305
  707. * code_n : 101
  708. * txt_d : 小雨
  709. * txt_n : 多云
  710. */
  711. private String code_d;
  712. private String code_n;
  713. private String txt_d;
  714. private String txt_n;
  715. public String getCode_d() {
  716. return code_d;
  717. }
  718. public void setCode_d(String code_d) {
  719. this.code_d = code_d;
  720. }
  721. public String getCode_n() {
  722. return code_n;
  723. }
  724. public void setCode_n(String code_n) {
  725. this.code_n = code_n;
  726. }
  727. public String getTxt_d() {
  728. return txt_d;
  729. }
  730. public void setTxt_d(String txt_d) {
  731. this.txt_d = txt_d;
  732. }
  733. public String getTxt_n() {
  734. return txt_n;
  735. }
  736. public void setTxt_n(String txt_n) {
  737. this.txt_n = txt_n;
  738. }
  739. }
  740. public static class TmpBean {
  741. /**
  742. * max : 26
  743. * min : 16
  744. */
  745. private String max;
  746. private String min;
  747. public String getMax() {
  748. return max;
  749. }
  750. public void setMax(String max) {
  751. this.max = max;
  752. }
  753. public String getMin() {
  754. return min;
  755. }
  756. public void setMin(String min) {
  757. this.min = min;
  758. }
  759. }
  760. public static class WindBeanX {
  761. /**
  762. * deg : 99
  763. * dir : 东北风
  764. * sc : 3-4
  765. * spd : 16
  766. */
  767. private String deg;
  768. private String dir;
  769. private String sc;
  770. private String spd;
  771. public String getDeg() {
  772. return deg;
  773. }
  774. public void setDeg(String deg) {
  775. this.deg = deg;
  776. }
  777. public String getDir() {
  778. return dir;
  779. }
  780. public void setDir(String dir) {
  781. this.dir = dir;
  782. }
  783. public String getSc() {
  784. return sc;
  785. }
  786. public void setSc(String sc) {
  787. this.sc = sc;
  788. }
  789. public String getSpd() {
  790. return spd;
  791. }
  792. public void setSpd(String spd) {
  793. this.spd = spd;
  794. }
  795. }
  796. }
  797. }
  798. }





声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/468012
推荐阅读
相关标签
  

闽ICP备14008679号