DayOfMonthCursorpublic class DayOfMonthCursor extends MonthDisplayHelper Helps control and display a month view of a calendar that has a current
selected day.
- Keeps track of current month, day, year
- Keeps track of current cursor position (row, column)
- Provides methods to help display the calendar
- Provides methods to move the cursor up / down / left / right.
This should be used by anyone who presents a month view to users and wishes
to behave consistently with other widgets and apps; if we ever change our
mind about when to flip the month, we can change it here only. |
Fields Summary |
---|
private int | mRow | private int | mColumn |
Constructors Summary |
---|
public DayOfMonthCursor(int year, int month, int dayOfMonth, int weekStartDay)
super(year, month, weekStartDay);
mRow = getRowOf(dayOfMonth);
mColumn = getColumnOf(dayOfMonth);
|
Methods Summary |
---|
public boolean | down()Move down one box, potentially flipping to the next month.
if (isWithinCurrentMonth(mRow + 1, mColumn)) {
// within current month, just move down
mRow++;
return false;
}
// flip to next month, same column, first position within month
nextMonth();
mRow = 0;
while (!isWithinCurrentMonth(mRow, mColumn)) {
mRow++;
}
return true;
| public int | getSelectedColumn()
return mColumn;
| public int | getSelectedDayOfMonth()
return getDayAt(mRow, mColumn);
| public int | getSelectedMonthOffset()
if (isWithinCurrentMonth(mRow, mColumn)) {
return 0;
}
if (mRow == 0) {
return -1;
}
return 1;
| public int | getSelectedRow()
return mRow;
| public boolean | isSelected(int row, int column)
return (mRow == row) && (mColumn == column);
| public boolean | left()Move left one box, potentially flipping to the previous month.
if (mColumn == 0) {
mRow--;
mColumn = 6;
} else {
mColumn--;
}
if (isWithinCurrentMonth(mRow, mColumn)) {
return false;
}
// need to flip to last day of previous month
previousMonth();
int lastDay = getNumberOfDaysInMonth();
mRow = getRowOf(lastDay);
mColumn = getColumnOf(lastDay);
return true;
| public boolean | right()Move right one box, potentially flipping to the next month.
if (mColumn == 6) {
mRow++;
mColumn = 0;
} else {
mColumn++;
}
if (isWithinCurrentMonth(mRow, mColumn)) {
return false;
}
// need to flip to first day of next month
nextMonth();
mRow = 0;
mColumn = 0;
while (!isWithinCurrentMonth(mRow, mColumn)) {
mColumn++;
}
return true;
| public void | setSelectedDayOfMonth(int dayOfMonth)
mRow = getRowOf(dayOfMonth);
mColumn = getColumnOf(dayOfMonth);
| public void | setSelectedRowColumn(int row, int col)
mRow = row;
mColumn = col;
| public boolean | up()Move up one box, potentially flipping to the previous month.
if (isWithinCurrentMonth(mRow - 1, mColumn)) {
// within current month, just move up
mRow--;
return false;
}
// flip back to previous month, same column, first position within month
previousMonth();
mRow = 5;
while(!isWithinCurrentMonth(mRow, mColumn)) {
mRow--;
}
return true;
|
|