// 生成日历实例; private CalendarBean getCalendarData(String date, int week) { // TODO String[] strList = date.split(CalendarUtil.DATE_FORMATTER_GAP); if (strList == null) { return null; } CalendarBean calendarBean = new CalendarBean(); if (strList.length == CalendarUtil.DATE_FORMATTER_NUM) { try { calendarBean.setYear(Integer.parseInt(strList[0])); calendarBean.setMonth(Integer.parseInt(strList[1])); calendarBean.setDay(Integer.parseInt(strList[2])); } catch (Exception e) { } } return calendarBean; }
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long arg3) { CalendarBean selectCalendarModel = (CalendarBean) view.getTag(); if (selectCalendarModel == null) { return; } int type = selectCalendarModel.getType(); if (type == CalendarBean.MODEL_TAG_THIS) { if (mDateType == CalendarBean.MODEL_SELECT_IN) { if (mLastOutCalendarModel != null && selectCalendarModel.compareTo(mLastOutCalendarModel) >= 0) { // 选择的入住日期 如果大于 离店日期,则清除离店日期 mLastOutCalendarModel = null; mCalendarAdapter.clearOutCalendarInfo(); mNeedClearOutCalendarInfo = true; } mLastInCalendarModel = selectCalendarModel; } else if (mDateType == CalendarBean.MODEL_SELECT_OUT) { if (mLastInCalendarModel != null && selectCalendarModel.compareTo(mLastInCalendarModel) <= 0) { // 离店日期 必须大于 入住日期 mHandler.sendEmptyMessageDelayed(MSG_SHOW_SELECTDATE_HINT_ACTION, 300); return; } mLastOutCalendarModel = selectCalendarModel; } mCalendarAdapter.setCalendarInfo(position, mDateType); Intent intent = new Intent(); if (mNeedClearOutCalendarInfo) { // 返回到订机票页面时清除离店日期 intent.putExtra("NeedClearOutCalendar", true); } intent.putExtra("SelectCalendar", selectCalendarModel); setResult(RESULT_OK, intent); mHandler.sendEmptyMessageDelayed(MSG_RETURN_ACTION, 300); } else if (type == CalendarBean.MODEL_TAG_NEXT) { mCalendarAdapter.showNextMonth(this); } }
private void parseIntent() { Intent intent = getIntent(); today = getCalendarData(CalendarUtil.getNowDateStr(), CalendarUtil.getDayOfWeek()); tomorrow = getCalendarData(CalendarUtil.getTomorrowDateStr(), CalendarUtil.getDayOfWeek()); afterTomorrow = getCalendarData( CalendarUtil.getAppointTomorrowDate( tomorrow.getYear(), tomorrow.getMonth(), tomorrow.getDay()), CalendarUtil.getDayOfWeek()); if (intent != null) { mDateType = intent.getIntExtra("DateType", CalendarBean.MODEL_SELECT_IN); // modify by lisheng start ; if (mDateType == CalendarBean.MODEL_TRAIN_START) { mLastTrainCalendarModel = (CalendarBean) intent.getSerializableExtra("trainCalendarData"); } else { mLastInCalendarModel = (CalendarBean) intent.getSerializableExtra("InCalendarData"); mLastOutCalendarModel = (CalendarBean) intent.getSerializableExtra("OutCalendarData"); } // modify by lisheng end; } }