private void setViewFromFlightListVo(FlightListVo result) { if (result != null && result.getAir() != null && !result.getAir().isEmpty()) { String devTime = result.getAir().get(0).getArrtime(); // 接口返回的出发时间和到达时间反了,App为了适应接口 String arrTime = result.getAir().get(0).getDevtime(); flightVo.setDevtime(devTime); flightVo.setArrtime(arrTime); tvDepartureTime.setText(devTime); tvArriveTime.setText(arrTime); int arrInt = 0, depInt = 0; try { arrInt = Integer.parseInt(arrTime.split(":")[0]); depInt = Integer.parseInt(devTime.split(":")[0]); } catch (NumberFormatException e) { // TODO Auto-generated catch block e.printStackTrace(); } SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd"); // sdf=SimpleDateFormat.getDateInstance(); Date date2 = new Date(System.currentTimeMillis()); tvDepartureDay.setText(TimeUtil.parseDateToString(sdf, date2)); if (arrInt > depInt) { tvArriveDay.setText(TimeUtil.parseDateToString(sdf, date2)); } else { // 跨天时间 date2.setTime(System.currentTimeMillis() + 24 * 3600 * 1000); tvArriveDay.setText(TimeUtil.parseDateToString(sdf, date2)); } } }
private void setWeatherFromBaiduWeatherListVo(BaiduWeatherListVo result) { if (result != null) { try { Date date = TimeUtil.parseDate(TimeUtil.sdf1, result.getDate()); List<BaiduWeatherData> weatherResults = result.getResults().get(0).getWeather_data(); Calendar nowCalendar = Calendar.getInstance(); Calendar weatherCalendar = Calendar.getInstance(); weatherCalendar.setTime(date); int index = nowCalendar.get(Calendar.DAY_OF_YEAR) - weatherCalendar.get(Calendar.DAY_OF_YEAR); BaiduWeatherData baiduWeatherData = weatherResults.get(index); String imgUrl = baiduWeatherData.getDayPictureUrl(); if (nowCalendar.get(Calendar.HOUR_OF_DAY) > 18 || nowCalendar.get(Calendar.HOUR_OF_DAY) < 6) { imgUrl = baiduWeatherData.getNightPictureUrl(); } if (flightVo.getLeave()) { ivWeatherFrom.setVisibility(View.VISIBLE); FinalBitmap.create(FlightDetailActivity.this).display(ivWeatherFrom, imgUrl); } else { ivWeatherTo.setVisibility(View.VISIBLE); FinalBitmap.create(FlightDetailActivity.this).display(ivWeatherTo, imgUrl); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } }