亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

接口變了,復制我的這兩個方法加進去就行了

WeatherUtilsImpl?WeatherUtils?{
????<>?getValue(Object?map,?String?path,?Class<>?clazz)?{
????????{
????????????OgnlContext?context?=?OgnlContext();
????????????context.setRoot(map);
????????????value?=?()?Ognl.(path,?context,?context.getRoot());
????????????value;
????????}?(Exception?e)?{
????????????RuntimeException(e);
????????}
????}

????List<HourWeather>?w24h(String?appCode,?String?area)?{
????????List<HourWeather>?resultList?=?ArrayList<HourWeather>();
????????{
????????????OkHttpClient?client?=?OkHttpClient();
????????????Request?request?=?Request.Builder()
????????????????????.get()
????????????????????.url(+?area)
????????????????????.header(,?+?appCode)
????????????????????.build();
????????????Call?call?=?client.newCall(request);
????????????Response?response?=?call.execute();
????????????Gson?gson?=?GsonBuilder()
????????????????????.setFieldNamingPolicy(FieldNamingPolicy.)
????????????????????.create();
????????????String?resBody?=?response.body().string();
????????????Map?result?=?gson.fromJson(resBody,?TypeToken<Map>()?{
????????????}.getType());
????????????List<Map<String,?String>>?hourList?=?.getValue(result,?,?ArrayList.);
????????????(hourList?==?||?hourList.size()?==?)?{
????????????????ArrayList<HourWeather>();
????????????}
????????????(Map<String,?String>?hour?:?hourList)?{
????????????????HourWeather?hourWeather?=?HourWeather();
????????????????hourWeather.setYear(hour.get().substring(,?));
????????????????hourWeather.setMonth(hour.get().substring(,?));
????????????????hourWeather.setDay(hour.get().substring(,?));
????????????????hourWeather.setHour(hour.get().substring(,?));
????????????????hourWeather.setWindDirection(hour.get());
????????????????hourWeather.setWindPower(hour.get());
????????????????hourWeather.setWeather(hour.get());
????????????????hourWeather.setTemperature(hour.get());
????????????????resultList.add(hourWeather);
????????????}

????????}?(Exception?e)?{
????????????RuntimeException(e);
????????}
????????resultList;

????}

????List<DayWeather>?w3d(String?appCode,?String?area)?{
????????;
????}

????List<DayWeather>?w7d(String?appCode,?String?area)?{
????????;
????}


正在回答

1 回答

厲害的

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

接口變了,復制我的這兩個方法加進去就行了

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號