-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
75cd7e2
commit f848b65
Showing
19 changed files
with
730 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,241 @@ | ||
package com.youth.xf.data; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* 实体类和json对应 | ||
*/ | ||
public class Weather { | ||
|
||
/** | ||
* data : {"yesterday":{"date":"11日星期日","high":"高温 31℃","fx":"南风","low":"低温 18℃","fl":"微风","type":"阴"},"city":"北京","aqi":"71","forecast":[{"date":"12日星期一","high":"高温 27℃","fengli":"微风级","low":"低温 18℃","fengxiang":"南风","type":"阵雨"},{"date":"13日星期二","high":"高温 29℃","fengli":"微风级","low":"低温 17℃","fengxiang":"南风","type":"多云"},{"date":"14日星期三","high":"高温 34℃","fengli":"微风级","low":"低温 23℃","fengxiang":"南风","type":"晴"},{"date":"15日星期四","high":"高温 36℃","fengli":"微风级","low":"低温 24℃","fengxiang":"南风","type":"晴"},{"date":"16日星期五","high":"高温 34℃","fengli":"3-4级","low":"低温 23℃","fengxiang":"南风","type":"阴"}],"ganmao":"相对今天出现了较大幅度降温,较易发生感冒,体质较弱的朋友请注意适当防护。","wendu":"26"} | ||
* status : 1000 | ||
* desc : OK | ||
*/ | ||
|
||
private DataBean data; | ||
private int status; | ||
private String desc; | ||
|
||
public DataBean getData() { | ||
return data; | ||
} | ||
|
||
public void setData(DataBean data) { | ||
this.data = data; | ||
} | ||
|
||
public int getStatus() { | ||
return status; | ||
} | ||
|
||
public void setStatus(int status) { | ||
this.status = status; | ||
} | ||
|
||
public String getDesc() { | ||
return desc; | ||
} | ||
|
||
public void setDesc(String desc) { | ||
this.desc = desc; | ||
} | ||
|
||
public static class DataBean { | ||
/** | ||
* yesterday : {"date":"11日星期日","high":"高温 31℃","fx":"南风","low":"低温 18℃","fl":"微风","type":"阴"} | ||
* city : 北京 | ||
* aqi : 71 | ||
* forecast : [{"date":"12日星期一","high":"高温 27℃","fengli":"微风级","low":"低温 18℃","fengxiang":"南风","type":"阵雨"},{"date":"13日星期二","high":"高温 29℃","fengli":"微风级","low":"低温 17℃","fengxiang":"南风","type":"多云"},{"date":"14日星期三","high":"高温 34℃","fengli":"微风级","low":"低温 23℃","fengxiang":"南风","type":"晴"},{"date":"15日星期四","high":"高温 36℃","fengli":"微风级","low":"低温 24℃","fengxiang":"南风","type":"晴"},{"date":"16日星期五","high":"高温 34℃","fengli":"3-4级","low":"低温 23℃","fengxiang":"南风","type":"阴"}] | ||
* ganmao : 相对今天出现了较大幅度降温,较易发生感冒,体质较弱的朋友请注意适当防护。 | ||
* wendu : 26 | ||
*/ | ||
|
||
private YesterdayBean yesterday; | ||
private String city; | ||
private String aqi; | ||
private String ganmao; | ||
private String wendu; | ||
private List<ForecastBean> forecast; | ||
|
||
public YesterdayBean getYesterday() { | ||
return yesterday; | ||
} | ||
|
||
public void setYesterday(YesterdayBean yesterday) { | ||
this.yesterday = yesterday; | ||
} | ||
|
||
public String getCity() { | ||
return city; | ||
} | ||
|
||
public void setCity(String city) { | ||
this.city = city; | ||
} | ||
|
||
public String getAqi() { | ||
return aqi; | ||
} | ||
|
||
public void setAqi(String aqi) { | ||
this.aqi = aqi; | ||
} | ||
|
||
public String getGanmao() { | ||
return ganmao; | ||
} | ||
|
||
public void setGanmao(String ganmao) { | ||
this.ganmao = ganmao; | ||
} | ||
|
||
public String getWendu() { | ||
return wendu; | ||
} | ||
|
||
public void setWendu(String wendu) { | ||
this.wendu = wendu; | ||
} | ||
|
||
public List<ForecastBean> getForecast() { | ||
return forecast; | ||
} | ||
|
||
public void setForecast(List<ForecastBean> forecast) { | ||
this.forecast = forecast; | ||
} | ||
|
||
public static class YesterdayBean { | ||
/** | ||
* date : 11日星期日 | ||
* high : 高温 31℃ | ||
* fx : 南风 | ||
* low : 低温 18℃ | ||
* fl : 微风 | ||
* type : 阴 | ||
*/ | ||
|
||
private String date; | ||
private String high; | ||
private String fx; | ||
private String low; | ||
private String fl; | ||
private String type; | ||
|
||
public String getDate() { | ||
return date; | ||
} | ||
|
||
public void setDate(String date) { | ||
this.date = date; | ||
} | ||
|
||
public String getHigh() { | ||
return high; | ||
} | ||
|
||
public void setHigh(String high) { | ||
this.high = high; | ||
} | ||
|
||
public String getFx() { | ||
return fx; | ||
} | ||
|
||
public void setFx(String fx) { | ||
this.fx = fx; | ||
} | ||
|
||
public String getLow() { | ||
return low; | ||
} | ||
|
||
public void setLow(String low) { | ||
this.low = low; | ||
} | ||
|
||
public String getFl() { | ||
return fl; | ||
} | ||
|
||
public void setFl(String fl) { | ||
this.fl = fl; | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public void setType(String type) { | ||
this.type = type; | ||
} | ||
} | ||
|
||
public static class ForecastBean { | ||
/** | ||
* date : 12日星期一 | ||
* high : 高温 27℃ | ||
* fengli : 微风级 | ||
* low : 低温 18℃ | ||
* fengxiang : 南风 | ||
* type : 阵雨 | ||
*/ | ||
|
||
private String date; | ||
private String high; | ||
private String fengli; | ||
private String low; | ||
private String fengxiang; | ||
private String type; | ||
|
||
public String getDate() { | ||
return date; | ||
} | ||
|
||
public void setDate(String date) { | ||
this.date = date; | ||
} | ||
|
||
public String getHigh() { | ||
return high; | ||
} | ||
|
||
public void setHigh(String high) { | ||
this.high = high; | ||
} | ||
|
||
public String getFengli() { | ||
return fengli; | ||
} | ||
|
||
public void setFengli(String fengli) { | ||
this.fengli = fengli; | ||
} | ||
|
||
public String getLow() { | ||
return low; | ||
} | ||
|
||
public void setLow(String low) { | ||
this.low = low; | ||
} | ||
|
||
public String getFengxiang() { | ||
return fengxiang; | ||
} | ||
|
||
public void setFengxiang(String fengxiang) { | ||
this.fengxiang = fengxiang; | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public void setType(String type) { | ||
this.type = type; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package com.youth.xf.http; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import com.loopj.android.http.AsyncHttpClient; | ||
import com.loopj.android.http.AsyncHttpResponseHandler; | ||
import com.loopj.android.http.RequestParams; | ||
import com.youth.xframe.utils.http.HttpCallBack; | ||
import com.youth.xframe.utils.http.IHttpEngine; | ||
import com.youth.xframe.utils.http.XHttp; | ||
|
||
|
||
import java.util.Map; | ||
|
||
import cz.msebera.android.httpclient.Header; | ||
|
||
/** | ||
* AsyncHttp简单实现,你可修改,这只是案例 | ||
*/ | ||
public class AsyncHttpEngine implements IHttpEngine { | ||
private AsyncHttpClient client; | ||
|
||
public AsyncHttpEngine() { | ||
client = new AsyncHttpClient(); | ||
} | ||
|
||
@Override | ||
public void get(String url, Map<String, Object> params, final HttpCallBack callBack) { | ||
RequestParams requestParams = new RequestParams(); | ||
if(null!=params) { | ||
for (String key : params.keySet()) { | ||
requestParams.put(key, params.get(key)); | ||
} | ||
} | ||
client.get(url, requestParams, new AsyncHttpResponseHandler() { | ||
@Override | ||
public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { | ||
String result=new String(responseBody); | ||
Class<?> cls= XHttp.analysisClassInfo(callBack); | ||
//我这里使用的是fastjson,你也可以用gson,jackjson等 | ||
callBack.onSuccess(JSON.parseObject(result,cls)); | ||
} | ||
|
||
@Override | ||
public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) { | ||
callBack.onFailed(error.toString()); | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public void post(String url, Map<String, Object> params, final HttpCallBack callBack) { | ||
RequestParams requestParams = new RequestParams(); | ||
if(null!=params) { | ||
for (String key : params.keySet()) { | ||
requestParams.put(key, params.get(key)); | ||
} | ||
} | ||
client.post(url, requestParams, new AsyncHttpResponseHandler() { | ||
@Override | ||
public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) { | ||
String result=new String(responseBody); | ||
Class<?> cls= XHttp.analysisClassInfo(callBack); | ||
//我这里使用的是fastjson,你也可以用gson,jackjson等 | ||
callBack.onSuccess(JSON.parseObject(result,cls)); | ||
} | ||
|
||
@Override | ||
public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) { | ||
callBack.onFailed(error.toString()); | ||
} | ||
}); | ||
} | ||
} |
Oops, something went wrong.