Android获取天气预报Demo
程序员文章站
2022-05-29 21:34:48
...
近期在学习Android的时候,做了一个有关天气预报的任务,本文利用Gson解析Json的方式写一个Demo给有需要的朋友作为参考
天气预报来源:和风天气 https://www.heweather.com/documents/api/v5/weather
可以在百度上找到很多提供天气的api,大家只要注册拿到key即可。
在这里附上Demo地址:Demo地址
将Demo地址中的yourkey改成你自己的key即可简单测试
天气预报返回示例:
{
"HeWeather5": [
{
"alarms": [
{
"level": "蓝色",
"stat": "预警中",
"title": "山东省青岛市气象台发布大风蓝色预警",
"txt": "青岛市气象台2016年08月29日15时24分继续发布大风蓝色预警信号:预计今天下午到明天,我市北风风力海上6到7级阵风9级,陆地4到5阵风7级,请注意防范。",
"type": "大风"
}
],
"aqi": {
"city": {
"aqi": "60",
"co": "0",
"no2": "14",
"o3": "95",
"pm10": "67",
"pm25": "15",
"qlty": "良", //共六个级别,分别:优,良,轻度污染,中度污染,重度污染,严重污染
"so2": "10"
}
},
"basic": {
"city": "青岛",
"cnty": "中国",
"id": "CN101120201",
"lat": "36.088000",
"lon": "120.343000",
"prov": "山东" //城市所属省份(仅限国内城市)
"update": {
"loc": "2016-08-30 11:52",
"utc": "2016-08-30 03:52"
}
},
"daily_forecast": [
{
"astro": {
"mr": "03:09",
"ms": "17:06",
"sr": "05:28",
"ss": "18:29"
},
"cond": {
"code_d": "100",
"code_n": "100",
"txt_d": "晴",
"txt_n": "晴"
},
"date": "2016-08-30",
"hum": "45",
"pcpn": "0.0",
"pop": "8",
"pres": "1005",
"tmp": {
"max": "29",
"min": "22"
},
"vis": "10",
"wind": {
"deg": "339",
"dir": "北风",
"sc": "4-5",
"spd": "24"
}
}
],
"hourly_forecast": [
{
"cond": {
"code": "100",
"txt": "晴"
},
"date": "2016-08-30 12:00",
"hum": "47",
"pop": "0",
"pres": "1006",
"tmp": "29",
"wind": {
"deg": "335",
"dir": "西北风",
"sc": "4-5",
"spd": "36"
}
}
],
"now": {
"cond": {
"code": "100",
"txt": "晴"
},
"fl": "28",
"hum": "41",
"pcpn": "0",
"pres": "1005",
"tmp": "26",
"vis": "10",
"wind": {
"deg": "330",
"dir": "西北风",
"sc": "6-7",
"spd": "34"
}
},
"status": "ok",
"suggestion": {
"comf": {
"brf": "较舒适",
"txt": "白天天气晴好,您在这种天气条件下,会感觉早晚凉爽、舒适,午后偏热。"
},
"cw": {
"brf": "较不宜",
"txt": "较不宜洗车,未来一天无雨,风力较大,如果执意擦洗汽车,要做好蒙上污垢的心理准备。"
},
"drsg": {
"brf": "热",
"txt": "天气热,建议着短裙、短裤、短薄外套、T恤等夏季服装。"
},
"flu": {
"brf": "较易发",
"txt": "虽然温度适宜但风力较大,仍较易发生感冒,体质较弱的朋友请注意适当防护。"
},
"sport": {
"brf": "较适宜",
"txt": "天气较好,但风力较大,推荐您进行室内运动,若在户外运动请注意防风。"
},
"trav": {
"brf": "适宜",
"txt": "天气较好,风稍大,但温度适宜,是个好天气哦。适宜旅游,您可以尽情地享受大自然的无限风光。"
},
"uv": {
"brf": "强",
"txt": "紫外线辐射强,建议涂擦SPF20左右、PA++的防晒护肤品。避免在10点至14点暴露于日光下。"
}
}
}
]
}
那么我们先来获取一下天气预报:
因为利用get的请求方式,我们这里需要利用Volley框架
关于Volley有问题的大家也可以在度娘上找到
导包:
MainActivity.java
package com.example.champ.weatherdemo;
import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
import org.json.JSONObject;
public class MainActivity extends Activity {
RequestQueue queue = null;
EditText et_city;
Editable city;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
queue = Volley.newRequestQueue(this);
et_city = (EditText) findViewById(R.id.et_city);
}
public void weatherClick(View view){
city = et_city.getText();
String url = "https://free-api.heweather.com/v5/weather?city="+city+"&key=your key";
JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject jsonObject) {
System.out.println(jsonObject);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
System.out.println(volleyError);
}
});
queue.add(request);
}
}
上面的your key 就是你申请得到的key
<uses-permission android:name="android.permission.INTERNET" />
布局文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="@+id/et_city"
android:hint="请输入城市"
android:layout_width="160dp"
android:layout_height="wrap_content" />
<Button
android:id="@+id/button_click"
android:onClick="weatherClick"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="查询天气"/>
</LinearLayout>
</LinearLayout>
运行结果如下:
查看输出:
是一大串内容,但是已经能够获取到天气了。
那么,该怎样才能够将这一大串字符解析成我们想要的呢?
这里有个非常棒的插件——GsonFormat,可以帮我们直接将Json格式的字符串自动生成实体类参数
使用方法:
方法1:
方法2:
先去网上下载GsonFormat插件,然后本地安装
链接:点击打开链接
安装完毕之后
新建一个类:
如新建了一个WeatherBean类
然后:Code → Generate..。 → GsonFormat ,然后将刚刚得到的那一大串字符串粘贴进去即可
这样就自动拥有了各类实体类参数
里面对应的每个字段信息,不明白的可以在和风天气的官方api文档中查看
现在来得到一下:城市、日期、温度、天气情况、风向、空气质量这六个参数
得到实验结果:
Demo代码如下:
布局文件如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="@+id/et_city"
android:hint="请输入城市"
android:layout_width="160dp"
android:layout_height="wrap_content" />
<Button
android:id="@+id/button_click"
android:onClick="weatherClick"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="查询天气"/>
</LinearLayout>
<TextView
android:id="@+id/id_tv_city"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/id_tv_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/id_tv_temp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/id_tv_cond"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/id_tv_dir"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/id_tv_qlty"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
MainAcitvity.java
package com.example.champ.weatherdemo;
import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
import com.google.gson.Gson;
import org.json.JSONObject;
public class MainActivity extends Activity {
RequestQueue queue = null;
EditText et_city;
TextView tv_city,tv_date,tv_temp,tv_cond,tv_qlty,tv_dir;
Editable city;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
queue = Volley.newRequestQueue(this);
et_city = (EditText) findViewById(R.id.et_city);
tv_city = (TextView) findViewById(R.id.id_tv_city);
tv_date = (TextView) findViewById(R.id.id_tv_date);
tv_temp = (TextView) findViewById(R.id.id_tv_temp);
tv_cond = (TextView) findViewById(R.id.id_tv_cond);
tv_dir = (TextView) findViewById(R.id.id_tv_dir);
tv_qlty = (TextView) findViewById(R.id.id_tv_qlty);
}
public void weatherClick(View view){
city = et_city.getText();
String url = "https://free-api.heweather.com/v5/weather?city="+city+"&key=your key";
JsonObjectRequest request = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject jsonObject) {
System.out.println(jsonObject);
Gson gson =new Gson();
WeatherBean weatherBean = gson.fromJson(jsonObject.toString(),WeatherBean.class);
String cityName = weatherBean.getHeWeather5().get(0).getBasic().getCity();
String date = weatherBean.getHeWeather5().get(0).getDaily_forecast().get(0).getDate();
String temp = weatherBean.getHeWeather5().get(0).getNow().getTmp();
String cond = weatherBean.getHeWeather5().get(0).getNow().getCond().getTxt();
String dir = weatherBean.getHeWeather5().get(0).getNow().getWind().getDir();
String qlty = weatherBean.getHeWeather5().get(0).getAqi().getCity().getQlty();
tv_city.setText("城市:"+cityName);
tv_date.setText("日期:"+date);
tv_temp.setText("温度:"+temp);
tv_cond.setText("天气情况:"+cond);
tv_dir.setText("风向:"+dir);
tv_qlty.setText("空气质量:"+qlty);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError volleyError) {
System.out.println(volleyError);
}
});
queue.add(request);
}
}
WeatherBean.java
package com.example.champ.weatherdemo;
import java.util.List;
/**
* Created by champ on 2017/5/6.
*/
public class WeatherBean {
private List<HeWeather5Bean> HeWeather5;
public List<HeWeather5Bean> getHeWeather5() {
return HeWeather5;
}
public void setHeWeather5(List<HeWeather5Bean> HeWeather5) {
this.HeWeather5 = HeWeather5;
}
public static class HeWeather5Bean {
/**
* aqi : {"city":{"aqi":"72","co":"1","no2":"54","o3":"76","pm10":"92","pm25":"52","qlty":"良","so2":"12"}}
* basic : {"city":"杭州","cnty":"中国","id":"CN101210101","lat":"30.287459","lon":"120.153576","update":{"loc":"2017-05-06 22:51","utc":"2017-05-06 14:51"}}
* 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"}}]
* hourly_forecast : []
* now : {"cond":{"code":"101","txt":"多云"},"fl":"21","hum":"78","pcpn":"0","pres":"1019","tmp":"20","vis":"8","wind":{"deg":"120","dir":"东南风","sc":"微风","spd":"7"}}
* status : ok
* 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+的防晒护肤品。"}}
*/
private AqiBean aqi;
private BasicBean basic;
private NowBean now;
private String status;
private SuggestionBean suggestion;
private List<DailyForecastBean> daily_forecast;
private List<?> hourly_forecast;
public AqiBean getAqi() {
return aqi;
}
public void setAqi(AqiBean aqi) {
this.aqi = aqi;
}
public BasicBean getBasic() {
return basic;
}
public void setBasic(BasicBean basic) {
this.basic = basic;
}
public NowBean getNow() {
return now;
}
public void setNow(NowBean now) {
this.now = now;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public SuggestionBean getSuggestion() {
return suggestion;
}
public void setSuggestion(SuggestionBean suggestion) {
this.suggestion = suggestion;
}
public List<DailyForecastBean> getDaily_forecast() {
return daily_forecast;
}
public void setDaily_forecast(List<DailyForecastBean> daily_forecast) {
this.daily_forecast = daily_forecast;
}
public List<?> getHourly_forecast() {
return hourly_forecast;
}
public void setHourly_forecast(List<?> hourly_forecast) {
this.hourly_forecast = hourly_forecast;
}
public static class AqiBean {
/**
* city : {"aqi":"72","co":"1","no2":"54","o3":"76","pm10":"92","pm25":"52","qlty":"良","so2":"12"}
*/
private CityBean city;
public CityBean getCity() {
return city;
}
public void setCity(CityBean city) {
this.city = city;
}
public static class CityBean {
/**
* aqi : 72
* co : 1
* no2 : 54
* o3 : 76
* pm10 : 92
* pm25 : 52
* qlty : 良
* so2 : 12
*/
private String aqi;
private String co;
private String no2;
private String o3;
private String pm10;
private String pm25;
private String qlty;
private String so2;
public String getAqi() {
return aqi;
}
public void setAqi(String aqi) {
this.aqi = aqi;
}
public String getCo() {
return co;
}
public void setCo(String co) {
this.co = co;
}
public String getNo2() {
return no2;
}
public void setNo2(String no2) {
this.no2 = no2;
}
public String getO3() {
return o3;
}
public void setO3(String o3) {
this.o3 = o3;
}
public String getPm10() {
return pm10;
}
public void setPm10(String pm10) {
this.pm10 = pm10;
}
public String getPm25() {
return pm25;
}
public void setPm25(String pm25) {
this.pm25 = pm25;
}
public String getQlty() {
return qlty;
}
public void setQlty(String qlty) {
this.qlty = qlty;
}
public String getSo2() {
return so2;
}
public void setSo2(String so2) {
this.so2 = so2;
}
}
}
public static class BasicBean {
/**
* city : 杭州
* cnty : 中国
* id : CN101210101
* lat : 30.287459
* lon : 120.153576
* update : {"loc":"2017-05-06 22:51","utc":"2017-05-06 14:51"}
*/
private String city;
private String cnty;
private String id;
private String lat;
private String lon;
private UpdateBean update;
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getCnty() {
return cnty;
}
public void setCnty(String cnty) {
this.cnty = cnty;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getLat() {
return lat;
}
public void setLat(String lat) {
this.lat = lat;
}
public String getLon() {
return lon;
}
public void setLon(String lon) {
this.lon = lon;
}
public UpdateBean getUpdate() {
return update;
}
public void setUpdate(UpdateBean update) {
this.update = update;
}
public static class UpdateBean {
/**
* loc : 2017-05-06 22:51
* utc : 2017-05-06 14:51
*/
private String loc;
private String utc;
public String getLoc() {
return loc;
}
public void setLoc(String loc) {
this.loc = loc;
}
public String getUtc() {
return utc;
}
public void setUtc(String utc) {
this.utc = utc;
}
}
}
public static class NowBean {
/**
* cond : {"code":"101","txt":"多云"}
* fl : 21
* hum : 78
* pcpn : 0
* pres : 1019
* tmp : 20
* vis : 8
* wind : {"deg":"120","dir":"东南风","sc":"微风","spd":"7"}
*/
private CondBean cond;
private String fl;
private String hum;
private String pcpn;
private String pres;
private String tmp;
private String vis;
private WindBean wind;
public CondBean getCond() {
return cond;
}
public void setCond(CondBean cond) {
this.cond = cond;
}
public String getFl() {
return fl;
}
public void setFl(String fl) {
this.fl = fl;
}
public String getHum() {
return hum;
}
public void setHum(String hum) {
this.hum = hum;
}
public String getPcpn() {
return pcpn;
}
public void setPcpn(String pcpn) {
this.pcpn = pcpn;
}
public String getPres() {
return pres;
}
public void setPres(String pres) {
this.pres = pres;
}
public String getTmp() {
return tmp;
}
public void setTmp(String tmp) {
this.tmp = tmp;
}
public String getVis() {
return vis;
}
public void setVis(String vis) {
this.vis = vis;
}
public WindBean getWind() {
return wind;
}
public void setWind(WindBean wind) {
this.wind = wind;
}
public static class CondBean {
/**
* code : 101
* txt : 多云
*/
private String code;
private String txt;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getTxt() {
return txt;
}
public void setTxt(String txt) {
this.txt = txt;
}
}
public static class WindBean {
/**
* deg : 120
* dir : 东南风
* sc : 微风
* spd : 7
*/
private String deg;
private String dir;
private String sc;
private String spd;
public String getDeg() {
return deg;
}
public void setDeg(String deg) {
this.deg = deg;
}
public String getDir() {
return dir;
}
public void setDir(String dir) {
this.dir = dir;
}
public String getSc() {
return sc;
}
public void setSc(String sc) {
this.sc = sc;
}
public String getSpd() {
return spd;
}
public void setSpd(String spd) {
this.spd = spd;
}
}
}
public static class SuggestionBean {
/**
* 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+的防晒护肤品。"}
*/
private AirBean air;
private ComfBean comf;
private CwBean cw;
private DrsgBean drsg;
private FluBean flu;
private SportBean sport;
private TravBean trav;
private UvBean uv;
public AirBean getAir() {
return air;
}
public void setAir(AirBean air) {
this.air = air;
}
public ComfBean getComf() {
return comf;
}
public void setComf(ComfBean comf) {
this.comf = comf;
}
public CwBean getCw() {
return cw;
}
public void setCw(CwBean cw) {
this.cw = cw;
}
public DrsgBean getDrsg() {
return drsg;
}
public void setDrsg(DrsgBean drsg) {
this.drsg = drsg;
}
public FluBean getFlu() {
return flu;
}
public void setFlu(FluBean flu) {
this.flu = flu;
}
public SportBean getSport() {
return sport;
}
public void setSport(SportBean sport) {
this.sport = sport;
}
public TravBean getTrav() {
return trav;
}
public void setTrav(TravBean trav) {
this.trav = trav;
}
public UvBean getUv() {
return uv;
}
public void setUv(UvBean uv) {
this.uv = uv;
}
public static class AirBean {
/**
* brf : 中
* txt : 气象条件对空气污染物稀释、扩散和清除无明显影响,易感人群应适当减少室外活动时间。
*/
private String brf;
private String txt;
public String getBrf() {
return brf;
}
public void setBrf(String brf) {
this.brf = brf;
}
public String getTxt() {
return txt;
}
public void setTxt(String txt) {
this.txt = txt;
}
}
public static class ComfBean {
/**
* brf : 较舒适
* txt : 白天天气晴好,同时较大的空气湿度,会使您在午后略感闷热,但早晚仍很凉爽、舒适。
*/
private String brf;
private String txt;
public String getBrf() {
return brf;
}
public void setBrf(String brf) {
this.brf = brf;
}
public String getTxt() {
return txt;
}
public void setTxt(String txt) {
this.txt = txt;
}
}
public static class CwBean {
/**
* brf : 较适宜
* txt : 较适宜洗车,未来一天无雨,风力较小,擦洗一新的汽车至少能保持一天。
*/
private String brf;
private String txt;
public String getBrf() {
return brf;
}
public void setBrf(String brf) {
this.brf = brf;
}
public String getTxt() {
return txt;
}
public void setTxt(String txt) {
this.txt = txt;
}
}
public static class DrsgBean {
/**
* brf : 舒适
* txt : 建议着长袖T恤、衬衫加单裤等服装。年老体弱者宜着针织长袖衬衫、马甲和长裤。
*/
private String brf;
private String txt;
public String getBrf() {
return brf;
}
public void setBrf(String brf) {
this.brf = brf;
}
public String getTxt() {
return txt;
}
public void setTxt(String txt) {
this.txt = txt;
}
}
public static class FluBean {
/**
* brf : 较易发
* txt : 天气转凉,空气湿度较大,较易发生感冒,体质较弱的朋友请注意适当防护。
*/
private String brf;
private String txt;
public String getBrf() {
return brf;
}
public void setBrf(String brf) {
this.brf = brf;
}
public String getTxt() {
return txt;
}
public void setTxt(String txt) {
this.txt = txt;
}
}
public static class SportBean {
/**
* brf : 较不宜
* txt : 天气较好,但因风力较强,在户外要选择合适的运动;另外考虑到高温天气,建议停止高强度运动。
*/
private String brf;
private String txt;
public String getBrf() {
return brf;
}
public void setBrf(String brf) {
this.brf = brf;
}
public String getTxt() {
return txt;
}
public void setTxt(String txt) {
this.txt = txt;
}
}
public static class TravBean {
/**
* brf : 适宜
* txt : 天气较好,温度适宜,但风稍微有点大。这样的天气适宜旅游,您可以尽情地享受大自然的无限风光。
*/
private String brf;
private String txt;
public String getBrf() {
return brf;
}
public void setBrf(String brf) {
this.brf = brf;
}
public String getTxt() {
return txt;
}
public void setTxt(String txt) {
this.txt = txt;
}
}
public static class UvBean {
/**
* brf : 弱
* txt : 紫外线强度较弱,建议出门前涂擦SPF在12-15之间、PA+的防晒护肤品。
*/
private String brf;
private String txt;
public String getBrf() {
return brf;
}
public void setBrf(String brf) {
this.brf = brf;
}
public String getTxt() {
return txt;
}
public void setTxt(String txt) {
this.txt = txt;
}
}
}
public static class DailyForecastBean {
/**
* 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"}
*/
private AstroBean astro;
private CondBeanX cond;
private String date;
private String hum;
private String pcpn;
private String pop;
private String pres;
private TmpBean tmp;
private String uv;
private String vis;
private WindBeanX wind;
public AstroBean getAstro() {
return astro;
}
public void setAstro(AstroBean astro) {
this.astro = astro;
}
public CondBeanX getCond() {
return cond;
}
public void setCond(CondBeanX cond) {
this.cond = cond;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getHum() {
return hum;
}
public void setHum(String hum) {
this.hum = hum;
}
public String getPcpn() {
return pcpn;
}
public void setPcpn(String pcpn) {
this.pcpn = pcpn;
}
public String getPop() {
return pop;
}
public void setPop(String pop) {
this.pop = pop;
}
public String getPres() {
return pres;
}
public void setPres(String pres) {
this.pres = pres;
}
public TmpBean getTmp() {
return tmp;
}
public void setTmp(TmpBean tmp) {
this.tmp = tmp;
}
public String getUv() {
return uv;
}
public void setUv(String uv) {
this.uv = uv;
}
public String getVis() {
return vis;
}
public void setVis(String vis) {
this.vis = vis;
}
public WindBeanX getWind() {
return wind;
}
public void setWind(WindBeanX wind) {
this.wind = wind;
}
public static class AstroBean {
/**
* mr : 14:33
* ms : 02:34
* sr : 05:12
* ss : 18:40
*/
private String mr;
private String ms;
private String sr;
private String ss;
public String getMr() {
return mr;
}
public void setMr(String mr) {
this.mr = mr;
}
public String getMs() {
return ms;
}
public void setMs(String ms) {
this.ms = ms;
}
public String getSr() {
return sr;
}
public void setSr(String sr) {
this.sr = sr;
}
public String getSs() {
return ss;
}
public void setSs(String ss) {
this.ss = ss;
}
}
public static class CondBeanX {
/**
* code_d : 305
* code_n : 101
* txt_d : 小雨
* txt_n : 多云
*/
private String code_d;
private String code_n;
private String txt_d;
private String txt_n;
public String getCode_d() {
return code_d;
}
public void setCode_d(String code_d) {
this.code_d = code_d;
}
public String getCode_n() {
return code_n;
}
public void setCode_n(String code_n) {
this.code_n = code_n;
}
public String getTxt_d() {
return txt_d;
}
public void setTxt_d(String txt_d) {
this.txt_d = txt_d;
}
public String getTxt_n() {
return txt_n;
}
public void setTxt_n(String txt_n) {
this.txt_n = txt_n;
}
}
public static class TmpBean {
/**
* max : 26
* min : 16
*/
private String max;
private String min;
public String getMax() {
return max;
}
public void setMax(String max) {
this.max = max;
}
public String getMin() {
return min;
}
public void setMin(String min) {
this.min = min;
}
}
public static class WindBeanX {
/**
* deg : 99
* dir : 东北风
* sc : 3-4
* spd : 16
*/
private String deg;
private String dir;
private String sc;
private String spd;
public String getDeg() {
return deg;
}
public void setDeg(String deg) {
this.deg = deg;
}
public String getDir() {
return dir;
}
public void setDir(String dir) {
this.dir = dir;
}
public String getSc() {
return sc;
}
public void setSc(String sc) {
this.sc = sc;
}
public String getSpd() {
return spd;
}
public void setSpd(String spd) {
this.spd = spd;
}
}
}
}
}
上一篇: 中介者设计模式