新的开始
改变人生,没有什么捷径可言,这条路需要自己亲自去走一走,只有深入思考,不断反思总结,保持学习的热情,一步一步构建自己完整的知识体系,才是最终的制胜之道,也是程序员应该承担的使命。
《系列学习视频》
《系列学习文档》
《我的大厂面试之旅》
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
}
public void setDaily(List daily) {
this.daily = daily;
}
public static class ReferBean {
private List sources;
private List license;
public List getSources() {
return sources;
}
public void setSources(List sources) {
this.sources = sources;
}
public List getLicense() {
return license;
}
public void setLicense(List license) {
this.license = license;
}
}
public static class DailyBean {
/**
-
fxDate : 2020-07-15
-
sunrise : 04:59
-
sunset : 19:41
-
moonrise : 00:44
-
moonset : 14:35
-
moonPhase : 残月
-
tempMax : 32
-
tempMin : 22
-
iconDay : 101
-
textDay : 多云
-
iconNight : 150
-
textNight : 晴
-
wind360Day : 242
-
windDirDay : 西南风
-
windScaleDay : 1-2
-
windSpeedDay : 9
-
wind360Night : 202
-
windDirNight : 西南风
-
windScaleNight : 1-2
-
windSpeedNight : 4
-
humidity : 49
-
precip : 0.0
-
pressure : 996
-
vis : 25
-
cloud : 25
-
uvIndex : 11
*/
private String fxDate;
private String sunrise;
private String sunset;
private String moonrise;
private String moonset;
private String moonPhase;
private String tempMax;
private String tempMin;
private String iconDay;
private String textDay;
private String iconNight;
private String textNight;
private String wind360Day;
private String windDirDay;
private String windScaleDay;
private String windSpeedDay;
private String wind360Night;
private String windDirNight;
private String windScaleNight;
private String windSpeedNight;
private String humidity;
private String precip;
private String pressure;
private String vis;
private String cloud;
private String uvIndex;
public String getFxDate() {
return fxDate;
}
public void setFxDate(String fxDate) {
this.fxDate = fxDate;
}
public String getSunrise() {
return sunrise;
}
public void setSunrise(String sunrise) {
this.sunrise = sunrise;
}
public String getSunset() {
return sunset;
}
public void setSunset(String sunset) {
this.sunset = sunset;
}
public String getMoonrise() {
return moonrise;
}
public void setMoonrise(String moonrise) {
this.moonrise = moonrise;
}
public String getMoonset() {
return moonset;
}
public void setMoonset(String moonset) {
this.moonset = moonset;
}
public String getMoonPhase() {
return moonPhase;
}
public void setMoonPhase(String moonPhase) {
this.moonPhase = moonPhase;
}
public String getTempMax() {
return tempMax;
}
public void setTempMax(String tempMax) {
this.tempMax = tempMax;
}
public String getTempMin() {
return tempMin;
}
public void setTempMin(String tempMin) {
this.tempMin = tempMin;
}
public String getIconDay() {
return iconDay;
}
public void setIconDay(String iconDay) {
this.iconDay = iconDay;
}
public String getTextDay() {
return textDay;
}
public void setTextDay(String textDay) {
this.textDay = textDay;
}
public String getIconNight() {
return iconNight;
}
public void setIconNight(String iconNight) {
this.iconNight = iconNight;
}
public String getTextNight() {
return textNight;
}
public void setTextNight(String textNight) {
this.textNight = textNight;
}
public String getWind360Day() {
return wind360Day;
}
public void setWind360Day(String wind360Day) {
this.wind360Day = wind360Day;
}
public String getWindDirDay() {
return windDirDay;
}
public void setWindDirDay(String windDirDay) {
this.windDirDay = windDirDay;
}
public String getWindScaleDay() {
return windScaleDay;
}
public void setWindScaleDay(String windScaleDay) {
this.windScaleDay = windScaleDay;
}
public String getWindSpeedDay() {
return windSpeedDay;
}
public void setWindSpeedDay(String windSpeedDay) {
this.windSpeedDay = windSpeedDay;
}
public String getWind360Night() {
return wind360Night;
}
public void setWind360Night(String wind360Night) {
this.wind360Night = wind360Night;
}
public String getWindDirNight() {
return windDirNight;
}
public void setWindDirNight(String windDirNight) {
this.windDirNight = windDirNight;
}
public String getWindScaleNight() {
return windScaleNight;
}
public void setWindScaleNight(String windScaleNight) {
this.windScaleNight = windScaleNight;
}
public String getWindSpeedNight() {
return windSpeedNight;
}
public void setWindSpeedNight(String windSpeedNight) {
this.windSpeedNight = windSpeedNight;
}
public String getHumidity() {
return humidity;
}
public void setHumidity(String humidity) {
this.humidity = humidity;
}
public String getPrecip() {
return precip;
}
public void setPrecip(String precip) {
this.precip = precip;
}
public String getPressure() {
return pressure;
}
public void setPressure(String pressure) {
this.pressure = pressure;
}
public String getVis() {
return vis;
}
public void setVis(String vis) {
this.vis = vis;
}
public String getCloud() {
return cloud;
}
public void setCloud(String cloud) {
this.cloud = cloud;
}
public String getUvIndex() {
return uvIndex;
}
public void setUvIndex(String uvIndex) {
this.uvIndex = uvIndex;
}
}
}
3. 逐小时预报API
/**
-
逐小时预报(未来24小时)之前是逐三小时预报
-
@param location 城市名
-
@return 返回逐小时数据
*/
@GET(“/v7/weather/24h?key=3086e91d66c04ce588a7f538f917c7f4”)
Call hourlyWeather(@Query(“location”) String location);
HourlyResponse.java代码如下:
package com.llw.goodweather.bean;
import java.util.List;
/**
- 逐小时天气数据实体
*/
public class HourlyResponse {
/**
-
code : 200
-
updateTime : 2020-07-15T08:57+08:00
-
fxLink : http://hfx.link/2ax1
-
hourly : [{“fxTime”:“2020-07-15T10:00+08:00”,“temp”:“28”,“icon”:“100”,“text”:“晴”,“wind360”:“194”,“windDir”:“西南风”,“windScale”:“1-2”,“windSpeed”:“10”,“humidity”:“40”,“pop”:“0”,“precip”:“0.0”,“pressure”:“995”,“cloud”:“0”,“dew”:“19”},{“fxTime”:“2020-07-15T11:00+08:00”,“temp”:“29”,“icon”:“100”,“text”:“晴”,“wind360”:“195”,“windDir”:“西南风”,“windScale”:“1-2”,“windSpeed”:“6”,“humidity”:“35”,“pop”:“0”,“precip”:“0.0”,“pressure”:“995”,“cloud”:“1”,“dew”:“19”},{“fxTime”:“2020-07-15T12:00+08:00”,“temp”:“30”,“icon”:“100”,“text”:“晴”,“wind360”:“199”,“windDir”:“西南风”,“windScale”:“1-2”,“windSpeed”:“8”,“humidity”:“33”,“pop”:“0”,“precip”:“0.0”,“pressure”:“995”,“cloud”:“1”,“dew”:“19”},{“fxTime”:“2020-07-15T13:00+08:00”,“temp”:“31”,“icon”:“100”,“text”:“晴”,“wind360”:“203”,“windDir”:“西南风”,“windScale”:“1-2”,“windSpeed”:“7”,“humidity”:“31”,“pop”:“0”,“precip”:“0.0”,“pressure”:“996”,“cloud”:“2”,“dew”:“19”},{“fxTime”:“2020-07-15T14:00+08:00”,“temp”:“31”,“icon”:“100”,“text”:“晴”,“wind360”:“257”,“windDir”:“西南风”,“windScale”:“1-2”,“windSpeed”:“6”,“humidity”:“29”,“pop”:“0”,“precip”:“0.0”,“pressure”:“997”,“cloud”:“2”,“dew”:“19”},{“fxTime”:“2020-07-15T15:00+08:00”,“temp”:“31”,“icon”:“100”,“text”:“晴”,“wind360”:“245”,“windDir”:“西南风”,“windScale”:“1-2”,“windSpeed”:“2”,“humidity”:“31”,“pop”:“0”,“precip”:“0.0”,“pressure”:“997”,“cloud”:“7”,“dew”:“19”},{“fxTime”:“2020-07-15T16:00+08:00”,“temp”:“31”,“icon”:“100”,“text”:“晴”,“wind360”:“199”,“windDir”:“西南风”,“windScale”:“1-2”,“windSpeed”:“2”,“humidity”:“32”,“pop”:“0”,“precip”:“0.0”,“pressure”:“997”,“cloud”:“13”,“dew”:“19”},{“fxTime”:“2020-07-15T17:00+08:00”,“temp”:“31”,“icon”:“101”,“text”:“多云”,“wind360”:“231”,“windDir”:“西南风”,“windScale”:“1-2”,“windSpeed”:“7”,“humidity”:“33”,“pop”:“0”,“precip”:“0.0”,“pressure”:“997”,“cloud”:“18”,“dew”:“18”},{“fxTime”:“2020-07-15T18:00+08:00”,“temp”:“30”,“icon”:“100”,“text”:“晴”,“wind360”:“249”,“windDir”:“西南风”,“windScale”:“1-2”,“windSpeed”:“10”,“humidity”:“38”,“pop”:“0”,“precip”:“0.0”,“pressure”:“996”,“cloud”:“18”,“dew”:“19”},{“fxTime”:“2020-07-15T19:00+08:00”,“temp”:“28”,“icon”:“100”,“text”:“晴”,“wind360”:“234”,“windDir”:“西南风”,“windScale”:“1-2”,“windSpeed”:“5”,“humidity”:“43”,“pop”:“0”,“precip”:“0.0”,“pressure”:“996”,“cloud”:“18”,“dew”:“20”},{“fxTime”:“2020-07-15T20:00+08:00”,“temp”:“27”,“icon”:“100”,“text”:“晴”,“wind360”:“206”,“windDir”:“西南风”,“windScale”:“1-2”,“windSpeed”:“9”,“humidity”:“47”,“pop”:“0”,“precip”:“0.0”,“pressure”:“997”,“cloud”:“18”,“dew”:“20”},{“fxTime”:“2020-07-15T21:00+08:00”,“temp”:“26”,“icon”:“100”,“text”:“晴”,“wind360”:“198”,“windDir”:“西南风”,“windScale”:“1-2”,“windSpeed”:“6”,“humidity”:“51”,“pop”:“0”,“precip”:“0.0”,“pressure”:“997”,“cloud”:“12”,“dew”:“20”},{“fxTime”:“2020-07-15T22:00+08:00”,“temp”:“26”,“icon”:“100”,“text”:“晴”,“wind360”:“249”,“windDir”:“西南风”,“windScale”:“1-2”,“windSpeed”:“5”,“humidity”:“54”,“pop”:“0”,“precip”:“0.0”,“pressure”:“997”,“cloud”:“6”,“dew”:“20”},{“fxTime”:“2020-07-15T23:00+08:00”,“temp”:“25”,“icon”:“100”,“text”:“晴”,“wind360”:“248”,“windDir”:“西南风”,“windScale”:“1-2”,“windSpeed”:“4”,“humidity”:“58”,“pop”:“0”,“precip”:“0.0”,“pressure”:“997”,“cloud”:“0”,“dew”:“20”},{“fxTime”:“2020-07-16T00:00+08:00”,“temp”:“24”,“icon”:“100”,“text”:“晴”,“wind360”:“230”,“windDir”:“西南风”,“windScale”:“1-2”,“windSpeed”:“6”,“humidity”:“60”,“pop”:“0”,“precip”:“0.0”,“pressure”:“997”,“cloud”:“1”,“dew”:“19”},{“fxTime”:“2020-07-16T01:00+08:00”,“temp”:“24”,“icon”:“100”,“text”:“晴”,“wind360”:“255”,“windDir”:“西南风”,“windScale”:“1-2”,“windSpeed”:“4”,“humidity”:“62”,“pop”:“0”,“precip”:“0.0”,“pressure”:“997”,“cloud”:“3”,“dew”:“19”},{“fxTime”:“2020-07-16T02:00+08:00”,“temp”:“23”,“icon”:“100”,“text”:“晴”,“wind360”:“230”,“windDir”:“西南风”,“windScale”:“1-2”,“windSpeed”:“7”,“humidity”:“63”,“pop”:“0”,“precip”:“0.0”,“pressure”:“997”,“cloud”:“4”,“dew”:“20”},{“fxTime”:“2020-07-16T03:00+08:00”,“temp”:“23”,“icon”:“100”,“text”:“晴”,“wind360”:“209”,“windDir”:“西南风”,“windScale”:“1-2”,“windSpeed”:“1”,“humidity”:“65”,“pop”:“0”,“precip”:“0.0”,“pressure”:“997”,“cloud”:“4”,“dew”:“20”},{“fxTime”:“2020-07-16T04:00+08:00”,“temp”:“23”,“icon”:“100”,“text”:“晴”,“wind360”:“213”,“windDir”:“西南风”,“windScale”:“1-2”,“windSpeed”:“8”,“humidity”:“66”,“pop”:“0”,“precip”:“0.0”,“pressure”:“996”,“cloud”:“4”,“dew”:“20”},{“fxTime”:“2020-07-16T05:00+08:00”,“temp”:“22”,“icon”:“100”,“text”:“晴”,“wind360”:“193”,“windDir”:“西南风”,“windScale”:“1-2”,“windSpeed”:“7”,“humidity”:“67”,“pop”:“0”,“precip”:“0.0”,“pressure”:“995”,“cloud”:“3”,“dew”:“20”},{“fxTime”:“2020-07-16T06:00+08:00”,“temp”:“23”,“icon”:“101”,“text”:“多云”,“wind360”:“216”,“windDir”:“西南风”,“windScale”:“1-2”,“windSpeed”:“11”,“humidity”:“70”,“pop”:“0”,“precip”:“0.0”,“pressure”:“994”,“cloud”:“20”,“dew”:“21”},{“fxTime”:“2020-07-16T07:00+08:00”,“temp”:“25”,“icon”:“101”,“text”:“多云”,“wind360”:“229”,“windDir”:“西南风”,“windScale”:“1-2”,“windSpeed”:“11”,“humidity”:“73”,“pop”:“0”,“precip”:“0.0”,“pressure”:“994”,“cloud”:“37”,“dew”:“21”},{“fxTime”:“2020-07-16T08:00+08:00”,“temp”:“26”,“icon”:“101”,“text”:“多云”,“wind360”:“200”,“windDir”:“西南风”,“windScale”:“1-2”,“windSpeed”:“4”,“humidity”:“77”,“pop”:“0”,“precip”:“0.0”,“pressure”:“993”,“cloud”:“54”,“dew”:“21”},{“fxTime”:“2020-07-16T09:00+08:00”,“temp”:“28”,“icon”:“101”,“text”:“多云”,“wind360”:“200”,“windDir”:“西南风”,“windScale”:“1-2”,“windSpeed”:“4”,“humidity”:“65”,“pop”:“0”,“precip”:“0.0”,“pressure”:“993”,“cloud”:“53”,“dew”:“21”}]
-
refer : {“sources”:[“Weather China”],“license”:[“no commercial use”]}
*/
private String code;
private String updateTime;
private String fxLink;
private ReferBean refer;
private List hourly;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getUpdateTime() {
return updateTime;
}
public void setUpdateTime(String updateTime) {
this.updateTime = updateTime;
}
public String getFxLink() {
return fxLink;
}
public void setFxLink(String fxLink) {
this.fxLink = fxLink;
}
public ReferBean getRefer() {
return refer;
}
public void setRefer(ReferBean refer) {
this.refer = refer;
}
public List getHourly() {
return hourly;
}
public void setHourly(List hourly) {
this.hourly = hourly;
}
public static class ReferBean {
private List sources;
private List license;
public List getSources() {
return sources;
}
public void setSources(List sources) {
this.sources = sources;
}
public List getLicense() {
return license;
}
public void setLicense(List license) {
this.license = license;
}
}
public static class HourlyBean {
/**
-
fxTime : 2020-07-15T10:00+08:00
-
temp : 28
-
icon : 100
-
text : 晴
-
wind360 : 194
-
windDir : 西南风
-
windScale : 1-2
-
windSpeed : 10
-
humidity : 40
-
pop : 0
-
precip : 0.0
-
pressure : 995
-
cloud : 0
-
dew : 19
*/
private String fxTime;
private String temp;
private String icon;
private String text;
private String wind360;
private String windDir;
private String windScale;
private String windSpeed;
private String humidity;
private String pop;
private String precip;
private String pressure;
private String cloud;
private String dew;
public String getFxTime() {
return fxTime;
}
public void setFxTime(String fxTime) {
this.fxTime = fxTime;
}
public String getTemp() {
return temp;
}
public void setTemp(String temp) {
this.temp = temp;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public String getWind360() {
return wind360;
}
public void setWind360(String wind360) {
this.wind360 = wind360;
}
public String getWindDir() {
return windDir;
}
public void setWindDir(String windDir) {
this.windDir = windDir;
}
public String getWindScale() {
return windScale;
}
public void setWindScale(String windScale) {
this.windScale = windScale;
}
public String getWindSpeed() {
return windSpeed;
}
public void setWindSpeed(String windSpeed) {
this.windSpeed = windSpeed;
}
public String getHumidity() {
return humidity;
}
public void setHumidity(String humidity) {
this.humidity = humidity;
}
public String getPop() {
return pop;
}
public void setPop(String pop) {
this.pop = pop;
}
public String getPrecip() {
return precip;
}
public void setPrecip(String precip) {
this.precip = precip;
}
public String getPressure() {
return pressure;
}
public void setPressure(String pressure) {
this.pressure = pressure;
}
public String getCloud() {
return cloud;
}
public void setCloud(String cloud) {
this.cloud = cloud;
}
public String getDew() {
return dew;
}
public void setDew(String dew) {
this.dew = dew;
}
}
}
4. 空气质量API
/**
-
当天空气质量
-
@param location 城市名
-
@return 返回当天空气质量数据
*/
@GET(“/v7/air/now?key=3086e91d66c04ce588a7f538f917c7f4”)
Call airNowWeather(@Query(“location”) String location);
AirNowResponse.java代码如下:
package com.llw.goodweather.bean;
import java.util.List;
/**
- 当天空气质量数据实体
*/
public class AirNowResponse {
/**
-
code : 200
-
updateTime : 2020-07-15T09:34+08:00
-
fxLink : http://hfx.link/2ax4
-
now : {“pubTime”:“2020-07-15T09:00+08:00”,“aqi”:“49”,“category”:“优”,“primary”:“NA”,“pm10”:“49”,“pm2p5”:“29”,“no2”:“20”,“so2”:“3”,“co”:“0.6”,“o3”:“84”}
-
station : [{“pubTime”:“2020-07-15T09:00+08:00”,“name”:“万寿西宫”,“id”:“CNA1001”,“aqi”:“68”,“level”:“2”,“category”:“良”,“primary”:“PM2.5”,“pm10”:“66”,“pm2p5”:“49”,“no2”:“29”,“so2”:“3”,“co”:“0.7”,“o3”:“81”},{“pubTime”:“2020-07-15T09:00+08:00”,“name”:“定陵”,“id”:“CNA1002”,“aqi”:“36”,“level”:“1”,“category”:“优”,“primary”:“NA”,“pm10”:“36”,“pm2p5”:“15”,“no2”:“11”,“so2”:“3”,“co”:“0.4”,“o3”:“84”},{“pubTime”:“2020-07-15T09:00+08:00”,“name”:“东四”,“id”:“CNA1003”,“aqi”:“46”,“level”:“1”,“category”:“优”,“primary”:“NA”,“pm10”:“44”,“pm2p5”:“32”,“no2”:“21”,“so2”:“3”,“co”:“0.9”,“o3”:“95”},{“pubTime”:“2020-07-15T09:00+08:00”,“name”:“天坛”,“id”:“CNA1004”,“aqi”:“57”,“level”:“2”,“category”:“良”,“primary”:“PM2.5”,“pm10”:“56”,“pm2p5”:“40”,“no2”:“18”,“so2”:“1”,“co”:“0.7”,“o3”:“96”},{“pubTime”:“2020-07-15T09:00+08:00”,“name”:“农展馆”,“id”:“CNA1005”,“aqi”:“55”,“level”:“2”,“category”:“良”,“primary”:“PM10”,“pm10”:“59”,“pm2p5”:“35”,“no2”:“26”,“so2”:“3”,“co”:“0.7”,“o3”:“79”},{“pubTime”:“2020-07-15T09:00+08:00”,“name”:“官园”,“id”:“CNA1006”,“aqi”:“53”,“level”:“2”,“category”:“良”,“primary”:“PM2.5”,“pm10”:“52”,“pm2p5”:“37”,“no2”:“24”,“so2”:“1”,“co”:“0.6”,“o3”:“91”},{“pubTime”:“2020-07-15T09:00+08:00”,“name”:“海淀区万柳”,“id”:“CNA1007”,“aqi”:“48”,“level”:“1”,“category”:“优”,“primary”:“NA”,“pm10”:“48”,“pm2p5”:“28”,“no2”:“28”,“so2”:“1”,“co”:“0.6”,“o3”:“79”},{“pubTime”:“2020-07-15T09:00+08:00”,“name”:“顺义新城”,“id”:“CNA1008”,“aqi”:“46”,“level”:“1”,“category”:“优”,“primary”:“NA”,“pm10”:“46”,“pm2p5”:“22”,“no2”:“15”,“so2”:“3”,“co”:“0.5”,“o3”:“85”},{“pubTime”:“2020-07-15T09:00+08:00”,“name”:“怀柔镇”,“id”:“CNA1009”,“aqi”:“43”,“level”:“1”,“category”:“优”,“primary”:“NA”,“pm10”:“43”,“pm2p5”:“22”,“no2”:“18”,“so2”:“3”,“co”:“0.5”,“o3”:“78”},{“pubTime”:“2020-07-15T09:00+08:00”,“name”:“昌平镇”,“id”:“CNA1010”,“aqi”:“53”,“level”:“2”,“category”:“良”,“primary”:“PM10”,“pm10”:“56”,“pm2p5”:“23”,“no2”:“21”,“so2”:“1”,“co”:“0.5”,“o3”:“68”},{“pubTime”:“2020-07-15T09:00+08:00”,“name”:“奥体中心”,“id”:“CNA1011”,“aqi”:“44”,“level”:“1”,“category”:“优”,“primary”:“NA”,“pm10”:“44”,“pm2p5”:“22”,“no2”:“17”,“so2”:“3”,“co”:“0.5”,“o3”:“89”},{“pubTime”:“2020-07-15T09:00+08:00”,“name”:“古城”,“id”:“CNA1012”,“aqi”:“32”,“level”:“1”,“category”:“优”,“primary”:“NA”,“pm10”:“28”,“pm2p5”:“22”,“no2”:“11”,“so2”:“3”,“co”:“0.5”,“o3”:“80”}]
-
refer : {“sources”:[“cnemc”],“license”:[“no commercial use”]}
*/
private String code;
private String updateTime;
private String fxLink;
private NowBean now;
private ReferBean refer;
private List station;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getUpdateTime() {
return updateTime;
}
public void setUpdateTime(String updateTime) {
this.updateTime = updateTime;
}
public String getFxLink() {
return fxLink;
}
public void setFxLink(String fxLink) {
this.fxLink = fxLink;
}
public NowBean getNow() {
return now;
}
public void setNow(NowBean now) {
this.now = now;
}
public ReferBean getRefer() {
return refer;
}
public void setRefer(ReferBean refer) {
this.refer = refer;
}
public List getStation() {
return station;
}
public void setStation(List station) {
this.station = station;
}
public static class NowBean {
/**
-
pubTime : 2020-07-15T09:00+08:00
-
aqi : 49
-
category : 优
-
primary : NA
-
pm10 : 49
-
pm2p5 : 29
-
no2 : 20
-
so2 : 3
-
co : 0.6
-
o3 : 84
*/
private String pubTime;
private String aqi;
private String category;
private String primary;
private String pm10;
private String pm2p5;
private String no2;
private String so2;
private String co;
private String o3;
public String getPubTime() {
return pubTime;
}
public void setPubTime(String pubTime) {
this.pubTime = pubTime;
}
public String getAqi() {
return aqi;
}
public void setAqi(String aqi) {
this.aqi = aqi;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getPrimary() {
return primary;
}
public void setPrimary(String primary) {
this.primary = primary;
}
public String getPm10() {
return pm10;
}
public void setPm10(String pm10) {
this.pm10 = pm10;
}
public String getPm2p5() {
return pm2p5;
}
public void setPm2p5(String pm2p5) {
this.pm2p5 = pm2p5;
}
public String getNo2() {
return no2;
}
public void setNo2(String no2) {
this.no2 = no2;
}
public String getSo2() {
return so2;
}
public void setSo2(String so2) {
this.so2 = so2;
}
public String getCo() {
return co;
}
public void setCo(String co) {
this.co = co;
}
public String getO3() {
return o3;
}
public void setO3(String o3) {
this.o3 = o3;
}
}
public static class ReferBean {
private List sources;
private List license;
public List getSources() {
return sources;
}
public void setSources(List sources) {
this.sources = sources;
}
public List getLicense() {
return license;
}
public void setLicense(List license) {
this.license = license;
}
}
public static class StationBean {
/**
-
pubTime : 2020-07-15T09:00+08:00
-
name : 万寿西宫
-
id : CNA1001
-
aqi : 68
-
level : 2
-
category : 良
-
primary : PM2.5
-
pm10 : 66
-
pm2p5 : 49
-
no2 : 29
-
so2 : 3
-
co : 0.7
-
o3 : 81
*/
private String pubTime;
private String name;
private String id;
private String aqi;
private String level;
private String category;
private String primary;
private String pm10;
private String pm2p5;
private String no2;
private String so2;
private String co;
private String o3;
public String getPubTime() {
return pubTime;
}
public void setPubTime(String pubTime) {
this.pubTime = pubTime;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getAqi() {
return aqi;
}
public void setAqi(String aqi) {
this.aqi = aqi;
}
public String getLevel() {
return level;
}
public void setLevel(String level) {
this.level = level;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getPrimary() {
return primary;
}
public void setPrimary(String primary) {
this.primary = primary;
}
public String getPm10() {
return pm10;
}
public void setPm10(String pm10) {
this.pm10 = pm10;
}
public String getPm2p5() {
return pm2p5;
}
public void setPm2p5(String pm2p5) {
this.pm2p5 = pm2p5;
}
public String getNo2() {
return no2;
}
public void setNo2(String no2) {
this.no2 = no2;
}
public String getSo2() {
return so2;
}
public void setSo2(String so2) {
this.so2 = so2;
}
public String getCo() {
return co;
}
public void setCo(String co) {
this.co = co;
}
public String getO3() {
return o3;
}
public void setO3(String o3) {
this.o3 = o3;
}
}
}
5. 生活指数API
/**
-
生活指数
-
@param type 可以控制定向获取那几项数据 全部数据 0, 运动指数 1 ,洗车指数 2 ,穿衣指数 3 ,
-
钓鱼指数 4 ,紫外线指数 5 ,旅游指数 6,花粉过敏指数 7,舒适度指数 8,
-
感冒指数 9 ,空气污染扩散条件指数 10 ,空调开启指数 11 ,太阳镜指数 12 ,
-
化妆指数 13 ,晾晒指数 14 ,交通指数 15 ,防晒指数 16
-
@param location 城市名
-
@return 返回当前生活指数数据
-
@return
*/
@GET(“/v7/indices/1d?key=3086e91d66c04ce588a7f538f917c7f4”)
Call Lifestyle(@Query(“type”) String type,
@Query(“location”) String location);
LifestyleResponse.java代码如下:
package com.llw.goodweather.bean;
import java.util.List;
/**
- 生活指数
*/
public class LifestyleResponse {
/**
-
code : 200
-
updateTime : 2020-07-15T09:10+08:00
-
fxLink : http://hfx.link/2ax2
-
daily : [{“date”:“2020-07-15”,“type”:“13”,“name”:“化妆指数”,“level”:“4”,“category”:“防脱水防晒”,“text”:“天气炎热,用防脱水防晒指数高的化妆品,少用粉底,常补粉。”},{“date”:“2020-07-15”,“type”:“6”,“name”:“旅游指数”,“level”:“1”,“category”:“适宜”,“text”:“天气较好,但丝毫不会影响您的心情。微风,虽天气稍热,却仍适宜旅游,不要错过机会呦!”},{“date”:“2020-07-15”,“type”:“14”,“name”:“晾晒指数”,“level”:“2”,“category”:“适宜”,“text”:“天气不错,适宜晾晒。赶紧把久未见阳光的衣物搬出来吸收一下太阳的味道吧!”},{“date”:“2020-07-15”,“type”:“15”,“name”:“交通指数”,“level”:“1”,“category”:“良好”,“text”:“天气较好,路面干燥,交通气象条件良好,车辆可以正常行驶。”},{“date”:“2020-07-15”,“type”:“10”,“name”:“空气污染扩散条件指数”,“level”:“2”,“category”:“中”,“text”:“气象条件对空气污染物稀释、扩散和清除无明显影响。”},{“date”:“2020-07-15”,“type”:“3”,“name”:“穿衣指数”,“level”:“7”,“category”:“炎热”,“text”:“天气炎热,建议着短衫、短裙、短裤、薄型T恤衫等清凉夏季服装。”},{“date”:“2020-07-15”,“type”:“16”,“name”:“防晒指数”,“level”:“2”,“category”:“极强”,“text”:“紫外辐射极强,应特别加强防护,建议涂擦SPF20以上,PA++的防晒护肤品,并随时补涂。”},{“date”:“2020-07-15”,“type”:“4”,“name”:“钓鱼指数”,“level”:“2”,“category”:“较适宜”,“text”:“较适合垂钓,但风力稍大,会对垂钓产生一定的影响。”},{“date”:“2020-07-15”,“type”:“5”,“name”:“紫外线指数”,“level”:“5”,“category”:“很强”,“text”:“紫外线辐射极强,建议涂擦SPF20以上、PA++的防晒护肤品,尽量避免暴露于日光下。”},{“date”:“2020-07-15”,“type”:“11”,“name”:“空调开启指数”,“level”:“2”,“category”:“部分时间开启”,“text”:“天气热,到中午的时候您将会感到有点热,因此建议在午后较热时开启制冷空调。”},{“date”:“2020-07-15”,“type”:“12”,“name”:“太阳镜指数”,“level”:“4”,“category”:“很必要”,“text”:“白天虽有白云遮挡,但太阳辐射仍很强,建议佩戴透射比2级且标注UV400的遮阳镜”},{“date”:“2020-07-15”,“type”:“7”,“name”:“过敏指数”,“level”:“2”,“category”:“不易发”,“text”:“天气条件不易诱发过敏,除特殊体质外,无需担心过敏问题。”},{“date”:“2020-07-15”,“type”:“8”,“name”:“舒适度指数”,“level”:“3”,“category”:“较不舒适”,“text”:“白天天气多云,同时会感到有些热,不很舒适。”},{“date”:“2020-07-15”,“type”:“9”,“name”:“感冒指数”,“level”:“1”,“category”:“少发”,“text”:“各项气象条件适宜,发生感冒机率较低。但请避免长期处于空调房间中,以防感冒。”},{“date”:“2020-07-15”,“type”:“2”,“name”:“洗车指数”,“level”:“2”,“category”:“较适宜”,“text”:“较适宜洗车,未来一天无雨,风力较小,擦洗一新的汽车至少能保持一天。”},{“date”:“2020-07-15”,“type”:“1”,“name”:“运动指数”,“level”:“2”,“category”:“较适宜”,“text”:“天气较好,较适宜进行各种运动,但因天气热,请适当减少运动时间,降低运动强度。”}]
-
refer : {“sources”:[“Weather China”],“license”:[“no commercial use”]}
*/
private String code;
private String updateTime;
private String fxLink;
private ReferBean refer;
private List daily;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getUpdateTime() {
return updateTime;
}
public void setUpdateTime(String updateTime) {
this.updateTime = updateTime;
}
public String getFxLink() {
return fxLink;
}
public void setFxLink(String fxLink) {
this.fxLink = fxLink;
}
public ReferBean getRefer() {
return refer;
}
public void setRefer(ReferBean refer) {
this.refer = refer;
}
public List getDaily() {
return daily;
}
public void setDaily(List daily) {
this.daily = daily;
}
public static class ReferBean {
private List sources;
private List license;
public List getSources() {
return sources;
}
public void setSources(List sources) {
this.sources = sources;
}
public List getLicense() {
return license;
}
public void setLicense(List license) {
this.license = license;
}
}
public static class DailyBean {
/**
-
date : 2020-07-15
-
type : 13
-
name : 化妆指数
-
level : 4
-
category : 防脱水防晒
-
text : 天气炎热,用防脱水防晒指数高的化妆品,少用粉底,常补粉。
*/
private String date;
private String type;
private String name;
private String level;
private String category;
private String text;
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getLevel() {
return level;
}
public void setLevel(String level) {
this.level = level;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
}
}
6. 搜索城市API
/**
-
搜索城市 V7版本 模糊搜索,国内范围 返回10条数据
-
@param location 城市名
-
@param mode exact 精准搜索 fuzzy 模糊搜索
-
@return
*/
@GET(“/v2/city/lookup?key=3086e91d66c04ce588a7f538f917c7f4&range=cn”)
Call newSearchCity(@Query(“location”) String location,
@Query(“mode”) String mode);
NewSearchCityResponse.java代码如下:
package com.llw.goodweather.bean;
import java.util.List;
public class NewSearchCityResponse {
/**
-
status : 200
-
location : [{“name”:“北京”,“id”:“101010100”,“lat”:“39.90498”,“lon”:“116.40528”,“adm2”:“北京”,“adm1”:“北京”,“country”:“中国”,“tz”:“Asia/Shanghai”,“utcOffset”:“+08:00”,“isDst”:“0”,“type”:“city”,“rank”:“10”,“fxLink”:“http://hfx.link/2ax1”},{“name”:“朝阳”,“id”:“101010300”,“lat”:“39.92148”,“lon”:“116.48641”,“adm2”:“北京”,“adm1”:“北京”,“country”:“中国”,“tz”:“Asia/Shanghai”,“utcOffset”:“+08:00”,“isDst”:“0”,“type”:“city”,“rank”:“15”,“fxLink”:“http://hfx.link/2az1”},{“name”:“海淀”,“id”:“101010200”,“lat”:“39.95607”,“lon”:“116.31031”,“adm2”:“北京”,“adm1”:“北京”,“country”:“中国”,“tz”:“Asia/Shanghai”,“utcOffset”:“+08:00”,“isDst”:“0”,“type”:“city”,“rank”:“15”,“fxLink”:“http://hfx.link/2ay1”},{“name”:“丰台”,“id”:“101010900”,“lat”:“39.86364”,“lon”:“116.28696”,“adm2”:“北京”,“adm1”:“北京”,“country”:“中国”,“tz”:“Asia/Shanghai”,“utcOffset”:“+08:00”,“isDst”:“0”,“type”:“city”,“rank”:“25”,“fxLink”:“http://hfx.link/2b51”},{“name”:“大兴”,“id”:“101011100”,“lat”:“39.72890”,“lon”:“116.33803”,“adm2”:“北京”,“adm1”:“北京”,“country”:“中国”,“tz”:“Asia/Shanghai”,“utcOffset”:“+08:00”,“isDst”:“0”,“type”:“city”,“rank”:“25”,“fxLink”:“http://hfx.link/2b71”},{“name”:“房山”,“id”:“101011200”,“lat”:“39.73553”,“lon”:“116.13916”,“adm2”:“北京”,“adm1”:“北京”,“country”:“中国”,“tz”:“Asia/Shanghai”,“utcOffset”:“+08:00”,“isDst”:“0”,“type”:“city”,“rank”:“23”,“fxLink”:“http://hfx.link/2b81”},{“name”:“通州”,“id”:“101010600”,“lat”:“39.90248”,“lon”:“116.65859”,“adm2”:“北京”,“adm1”:“北京”,“country”:“中国”,“tz”:“Asia/Shanghai”,“utcOffset”:“+08:00”,“isDst”:“0”,“type”:“city”,“rank”:“23”,“fxLink”:“http://hfx.link/2b21”},{“name”:“石景山”,“id”:“101011000”,“lat”:“39.91460”,“lon”:“116.19544”,“adm2”:“北京”,“adm1”:“北京”,“country”:“中国”,“tz”:“Asia/Shanghai”,“utcOffset”:“+08:00”,“isDst”:“0”,“type”:“city”,“rank”:“35”,“fxLink”:“http://hfx.link/2b61”},{“name”:“昌平”,“id”:“101010700”,“lat”:“40.21808”,“lon”:“116.23590”,“adm2”:“北京”,“adm1”:“北京”,“country”:“中国”,“tz”:“Asia/Shanghai”,“utcOffset”:“+08:00”,“isDst”:“0”,“type”:“city”,“rank”:“23”,“fxLink”:“http://hfx.link/2b31”},{“name”:“顺义”,“id”:“101010400”,“lat”:“40.12893”,“lon”:“116.65352”,“adm2”:“北京”,“adm1”:“北京”,“country”:“中国”,“tz”:“Asia/Shanghai”,“utcOffset”:“+08:00”,“isDst”:“0”,“type”:“city”,“rank”:“33”,“fxLink”:“http://hfx.link/2b01”}]
-
refer : {“sources”:[“heweather.com”],“license”:[“commercial license”]}
*/
private String status;
private ReferBean refer;
private List location;
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public ReferBean getRefer() {
return refer;
}
public void setRefer(ReferBean refer) {
this.refer = refer;
}
public List getLocation() {
return location;
}
public void setLocation(List location) {
this.location = location;
}
public static class ReferBean {
private List sources;
private List license;
public List getSources() {
return sources;
}
public void setSources(List sources) {
this.sources = sources;
}
public List getLicense() {
return license;
}
public void setLicense(List license) {
this.license = license;
}
}
public static class LocationBean {
/**
-
name : 北京
-
id : 101010100
-
lat : 39.90498
-
lon : 116.40528
-
adm2 : 北京
-
adm1 : 北京
-
country : 中国
-
tz : Asia/Shanghai
-
utcOffset : +08:00
-
isDst : 0
-
type : city
-
rank : 10
-
fxLink : http://hfx.link/2ax1
*/
private String name;
private String id;
private String lat;
private String lon;
private String adm2;
private String adm1;
private String country;
private String tz;
private String utcOffset;
private String isDst;
private String type;
private String rank;
private String fxLink;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
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 String getAdm2() {
return adm2;
}
public void setAdm2(String adm2) {
this.adm2 = adm2;
}
public String getAdm1() {
return adm1;
}
public void setAdm1(String adm1) {
this.adm1 = adm1;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getTz() {
return tz;
}
public void setTz(String tz) {
this.tz = tz;
}
public String getUtcOffset() {
return utcOffset;
}
public void setUtcOffset(String utcOffset) {
this.utcOffset = utcOffset;
}
public String getIsDst() {
return isDst;
}
public void setIsDst(String isDst) {
this.isDst = isDst;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getRank() {
return rank;
}
public void setRank(String rank) {
this.rank = rank;
}
public String getFxLink() {
return fxLink;
}
public void setFxLink(String fxLink) {
this.fxLink = fxLink;
}
}
}
没有的实体你创建一个就好了,然后将代码复制进去即可。API写好之后,就可以来一个一个的改代码了。这里我没有写上热门城市的API,是因为我打算给这个里面整体改头换面一下,以适应新的V7API的使用。
③ 修改订阅器
1. 修改WeatherContract
首先当然是主页面的订阅器啦,打开WeatherContract.java
可以到看里面目前是三个方法,
除了必应的壁纸请求,其他两个就负责主页面的数据请求,这个两个方法你可以先注释掉或者删掉了。
现在增加S7版本的方法,这里面增加了六个方法
/**
-
搜索城市 V7版本中 需要把定位城市的id查询出来,然后通过这个id来查询详细的数据
-
@param location 城市名
*/
public void newSearchCity(String location) {//注意这里的4表示新的搜索城市地址接口
ApiService service = ServiceGenerator.createService(ApiService.class, 4);//指明访问的地址
service.newSearchCity(location,“exact”).enqueue(new NetCallBack() {
@Override
public void onSuccess(Call call, Response response) {
if(getView() != null){
getView().getNewSearchCityResult(response);
}
}
@Override
public void onFailed() {
if(getView() != null){
getView().getDataFailed();
}
}
});
}
/**
-
实况天气 V7版本
-
@param location 城市名
*/
public void nowWeather(String location){//这个3 表示使用新的V7API访问地址
ApiService service = ServiceGenerator.createService(ApiService.class,3);
service.nowWeather(location).enqueue(new NetCallBack() {
@Override
public void onSuccess(Call call, Response response) {
if(getView() != null){
getView().getNowResult(response);
}
}
@Override
public void onFailed() {
if(getView() != null){
getView().getWeatherDataFailed();
}
}
});
}
/**
-
天气预报 V7版本 7d 表示天气的数据 为了和之前看上去差别小一些,这里先用七天的
-
@param location 城市名
*/
public void dailyWeather(String location){//这个3 表示使用新的V7API访问地址
ApiService service = ServiceGenerator.createService(ApiService.class,3);
service.dailyWeather(“7d”,location).enqueue(new NetCallBack() {
@Override
public void onSuccess(Call call, Response response) {
if(getView() != null){
getView().getDailyResult(response);
}
}
@Override
public void onFailed() {
if(getView() != null){
getView().getWeatherDataFailed();
}
}
});
}
/**
-
逐小时预报(未来24小时)
-
@param location 城市名
*/
public void hourlyWeather(String location){
ApiService service = ServiceGenerator.createService(ApiService.class,3);
service.hourlyWeather(location).enqueue(new NetCallBack() {
@Override
public void onSuccess(Call call, Response response) {
if(getView() != null){
getView().getHourlyResult(response);
}
}
@Override
public void onFailed() {
if(getView() != null){
getView().getWeatherDataFailed();
}
}
});
}
/**
-
当天空气质量
-
@param location 城市名
*/
public void airNowWeather(String location){
ApiService service = ServiceGenerator.createService(ApiService.class,3);
service.airNowWeather(location).enqueue(new NetCallBack() {
@Override
public void onSuccess(Call call, Response response) {
if(getView() != null){
getView().getAirNowResult(response);
}
}
@Override
public void onFailed() {
if(getView() != null){
getView().getWeatherDataFailed();
}
}
});
}
/**
-
生活指数
-
@param location 城市名 type中的"1,2,3,5,6,8,9,10",表示只获取这8种类型的指数信息,同样是为了对应之前的界面UI
*/
public void lifestyle(String location){
ApiService service = ServiceGenerator.createService(ApiService.class,3);
service.lifestyle(“1,2,3,5,6,8,9,10”,location).enqueue(new NetCallBack() {
@Override
public void onSuccess(Call call, Response response) {
if(getView() != null){
getView().getLifestyleResult(response);
}
}
@Override
public void onFailed() {
if(getView() != null){
getView().getWeatherDataFailed();
}
}
});
}
代码如下:
/* 以下为V7版本新增 */
//搜索城市返回城市id 通过id才能查下面的数据,否则会提示400 V7
void getNewSearchCityResult(Response response);
//实况天气
void getNowResult(Response response);
//天气预报 7天
void getDailyResult(Response response);
//逐小时天气预报
void getHourlyResult(Response response);
//空气质量
void getAirNowResult(Response response);
//生活指数
void getLifestyleResult(Response response);
看我的博客你甚至都不用写代码,粘贴复制就可以了,但我还是你能自己写一下。这个时候,如果你打开MainActivity肯定是会报错的,不过不用担心,这是因为刚才新增的没有在MainActivity中实现,后面再一起实现它们,订阅器可不止一个,
2. 修改SearchCityContract
现在打开SearchCityContract.java,新增如下代码:
/**
-
搜索城市 V7版本中 模糊搜索 返回10条相关数据
-
@param location 城市名
*/
public void newSearchCity(String location) {//注意这里的4表示新的搜索城市地址接口
ApiService service = ServiceGenerator.createService(ApiService.class, 4);//指明访问的地址
service.newSearchCity(location,“fuzzy”).enqueue(new NetCallBack() {
@Override
public void onSuccess(Call call, Response response) {
if(getView() != null){
getView().getNewSearchCityResult(response);
}
}
@Override
public void onFailed() {
if(getView() != null){
getView().getDataFailed();
}
}
});
}
接口中
//搜索城市返回数据 V7
void getNewSearchCityResult(Response response);
最终如下图所示
OK,现在订阅器都改好了,可以到Activity里面做修改了。
④ 修改Activity
1. 修改MainActivity
打开MainActivity,首先找到
刚才在订阅器里面已经注释掉或者删除了,所以这里没有找到对应方法,这两个你可以删除或者注释,我是删除了。
同样你还需要将
这两个请求在页面上有五件,我建议先注释掉,现在找到报错这一行。
然后会出现一个弹窗,里面会选中6个方法,点击OK就会导入进来,这个时候你的页面就不会再有报错的了。
现在可以在各个方法返回中写入数据了,一个一个来吧。首先是getNewSearchCityResult
在写之前,要做一些简单的代码改动,
打开CodeToStringUtils,增加返回状态码的判断处理,S6和V7是不一样的。所以要增加V7的。
增加的代码如下:
//新增V7版本下的状态码判断
case “204”:
codeInfo = “你查询的地区暂时没有你需要的数据”;
break;
case “400”:
codeInfo = “请求错误,可能包含错误的请求参数或缺少必选的请求参数”;
break;
case “401”:
codeInfo = “认证失败,可能使用了错误的KEY、数字签名错误、KEY的类型错误”;
break;
case “402”:
最后
一线互联网Android面试题含详解(初级到高级专题)
这些题目是今年群友去腾讯、百度、小米、乐视、美团、58、猎豹、360、新浪、搜狐等一线互联网公司面试被问到的题目。并且大多数都整理了答案,熟悉这些知识点会大大增加通过前两轮技术面试的几率
如果设置门槛,很多开发者朋友会因此错过这套高级架构资料,错过提升成为架构师的可能。这就失去了我们的初衷;让更多人都能通过高效高质量的学习,提升自己的技术和格局,升职加薪。
最后送给大家一句话,望共勉,永远不要放弃自己的梦想和追求;
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
Activity中实现,后面再一起实现它们,订阅器可不止一个,
2. 修改SearchCityContract
现在打开SearchCityContract.java,新增如下代码:
/**
-
搜索城市 V7版本中 模糊搜索 返回10条相关数据
-
@param location 城市名
*/
public void newSearchCity(String location) {//注意这里的4表示新的搜索城市地址接口
ApiService service = ServiceGenerator.createService(ApiService.class, 4);//指明访问的地址
service.newSearchCity(location,“fuzzy”).enqueue(new NetCallBack() {
@Override
public void onSuccess(Call call, Response response) {
if(getView() != null){
getView().getNewSearchCityResult(response);
}
}
@Override
public void onFailed() {
if(getView() != null){
getView().getDataFailed();
}
}
});
}
接口中
//搜索城市返回数据 V7
void getNewSearchCityResult(Response response);
最终如下图所示
OK,现在订阅器都改好了,可以到Activity里面做修改了。
④ 修改Activity
1. 修改MainActivity
打开MainActivity,首先找到
刚才在订阅器里面已经注释掉或者删除了,所以这里没有找到对应方法,这两个你可以删除或者注释,我是删除了。
同样你还需要将
这两个请求在页面上有五件,我建议先注释掉,现在找到报错这一行。
然后会出现一个弹窗,里面会选中6个方法,点击OK就会导入进来,这个时候你的页面就不会再有报错的了。
现在可以在各个方法返回中写入数据了,一个一个来吧。首先是getNewSearchCityResult
在写之前,要做一些简单的代码改动,
打开CodeToStringUtils,增加返回状态码的判断处理,S6和V7是不一样的。所以要增加V7的。
增加的代码如下:
//新增V7版本下的状态码判断
case “204”:
codeInfo = “你查询的地区暂时没有你需要的数据”;
break;
case “400”:
codeInfo = “请求错误,可能包含错误的请求参数或缺少必选的请求参数”;
break;
case “401”:
codeInfo = “认证失败,可能使用了错误的KEY、数字签名错误、KEY的类型错误”;
break;
case “402”:
最后
一线互联网Android面试题含详解(初级到高级专题)
这些题目是今年群友去腾讯、百度、小米、乐视、美团、58、猎豹、360、新浪、搜狐等一线互联网公司面试被问到的题目。并且大多数都整理了答案,熟悉这些知识点会大大增加通过前两轮技术面试的几率
[外链图片转存中…(img-ijz865XO-1715731534339)]
如果设置门槛,很多开发者朋友会因此错过这套高级架构资料,错过提升成为架构师的可能。这就失去了我们的初衷;让更多人都能通过高效高质量的学习,提升自己的技术和格局,升职加薪。
最后送给大家一句话,望共勉,永远不要放弃自己的梦想和追求;
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!