Methods Summary |
---|
public abstract MonthView | createMonthView(android.content.Context context)
|
public int | getCount()
return ((mController.getMaxYear() - mController.getMinYear()) + 1) * MONTHS_IN_YEAR;
|
public java.lang.Object | getItem(int position)
return null;
|
public long | getItemId(int position)
return position;
|
public com.android.datetimepicker.date.MonthAdapter$CalendarDay | getSelectedDay()
return mSelectedDay;
|
public android.view.View | getView(int position, android.view.View convertView, android.view.ViewGroup parent)
MonthView v;
HashMap<String, Integer> drawingParams = null;
if (convertView != null) {
v = (MonthView) convertView;
// We store the drawing parameters in the view so it can be recycled
drawingParams = (HashMap<String, Integer>) v.getTag();
} else {
v = createMonthView(mContext);
// Set up the new view
LayoutParams params = new LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
v.setLayoutParams(params);
v.setClickable(true);
v.setOnDayClickListener(this);
}
if (drawingParams == null) {
drawingParams = new HashMap<String, Integer>();
}
drawingParams.clear();
final int month = position % MONTHS_IN_YEAR;
final int year = position / MONTHS_IN_YEAR + mController.getMinYear();
int selectedDay = -1;
if (isSelectedDayInMonth(year, month)) {
selectedDay = mSelectedDay.day;
}
// Invokes requestLayout() to ensure that the recycled view is set with the appropriate
// height/number of weeks before being displayed.
v.reuse();
drawingParams.put(MonthView.VIEW_PARAMS_SELECTED_DAY, selectedDay);
drawingParams.put(MonthView.VIEW_PARAMS_YEAR, year);
drawingParams.put(MonthView.VIEW_PARAMS_MONTH, month);
drawingParams.put(MonthView.VIEW_PARAMS_WEEK_START, mController.getFirstDayOfWeek());
v.setMonthParams(drawingParams);
v.invalidate();
return v;
|
public boolean | hasStableIds()
return true;
|
protected void | init()Set up the gesture detector and selected time
mSelectedDay = new CalendarDay(System.currentTimeMillis());
|
private boolean | isSelectedDayInMonth(int year, int month)
return mSelectedDay.year == year && mSelectedDay.month == month;
|
public void | onDayClick(MonthView view, com.android.datetimepicker.date.MonthAdapter$CalendarDay day)
if (day != null) {
onDayTapped(day);
}
|
protected void | onDayTapped(com.android.datetimepicker.date.MonthAdapter$CalendarDay day)Maintains the same hour/min/sec but moves the day to the tapped day.
mController.tryVibrate();
mController.onDayOfMonthSelected(day.year, day.month, day.day);
setSelectedDay(day);
|
public void | setSelectedDay(com.android.datetimepicker.date.MonthAdapter$CalendarDay day)Updates the selected day and related parameters.
mSelectedDay = day;
notifyDataSetChanged();
|