Methods Summary |
---|
void | computeBusyBits(int firstDate, int numDays, byte[][] busyBits, Event event, int interval)
if (event.allDay) {
return;
}
int endDate = firstDate + numDays;
int startDay = event.startDay;
int endDay = event.endDay;
if (startDay >= endDate || endDay < firstDate) {
return;
}
int startTime = event.startTime;
int day = startDay;
// If the event started on a previous day, then show it starting
// at the beginning of this day.
if (day < firstDate) {
day = firstDate;
startTime = 0;
}
if (endDay >= endDate) {
endDay = endDate - 1;
}
int dayIndex = day - firstDate;
while (day <= endDay) {
int endTime = event.endTime;
// If the event ends on a future day, then show it extending to
// the end of this day.
if (endDay > day) {
endTime = CalendarView.MINUTES_PER_DAY;
}
int startInterval = startTime / interval;
int endInterval = (endTime + interval - 1) / interval;
for (int ii = startInterval; ii < endInterval; ii++) {
busyBits[dayIndex][ii] = 1;
}
day += 1;
dayIndex += 1;
startTime = 0;
}
|
boolean | computeEventRect(int date, int left, int top, int cellWidth, Event event)
if (event.allDay) {
return false;
}
float cellMinuteHeight = mMinuteHeight;
int startDay = event.startDay;
int endDay = event.endDay;
if (startDay > date || endDay < date) {
return false;
}
int startTime = event.startTime;
int endTime = event.endTime;
// If the event started on a previous day, then show it starting
// at the beginning of this day.
if (startDay < date) {
startTime = 0;
}
// If the event ends on a future day, then show it extending to
// the end of this day.
if (endDay > date) {
endTime = CalendarView.MINUTES_PER_DAY;
}
int col = event.getColumn();
int maxCols = event.getMaxColumns();
int startHour = startTime / 60;
int endHour = endTime / 60;
// If the end point aligns on a cell boundary then count it as
// ending in the previous cell so that we don't cross the border
// between hours.
if (endHour * 60 == endTime)
endHour -= 1;
event.top = top;
event.top += (int) (startTime * cellMinuteHeight);
event.top += startHour * mHourGap;
event.bottom = top;
event.bottom += (int) (endTime * cellMinuteHeight);
event.bottom += endHour * mHourGap;
// Make the rectangle be at least mMinEventHeight pixels high
if (event.bottom < event.top + mMinEventHeight) {
event.bottom = event.top + mMinEventHeight;
}
float colWidth = (float) (cellWidth - 2 * mCellMargin) / (float) maxCols;
event.left = left + mCellMargin + col * colWidth;
event.right = event.left + colWidth;
return true;
|
boolean | eventIntersectsSelection(Event event, android.graphics.Rect selection)Returns true if this event intersects the selection region.
if (event.left < selection.right && event.right >= selection.left
&& event.top < selection.bottom && event.bottom >= selection.top) {
return true;
}
return false;
|
float | pointToEvent(float x, float y, Event event)Computes the distance from the given point to the given event.
float left = event.left;
float right = event.right;
float top = event.top;
float bottom = event.bottom;
if (x >= left) {
if (x <= right) {
if (y >= top) {
if (y <= bottom) {
// x,y is inside the event rectangle
return 0f;
}
// x,y is below the event rectangle
return y - bottom;
}
// x,y is above the event rectangle
return top - y;
}
// x > right
float dx = x - right;
if (y < top) {
// the upper right corner
float dy = top - y;
return (float) Math.sqrt(dx * dx + dy * dy);
}
if (y > bottom) {
// the lower right corner
float dy = y - bottom;
return (float) Math.sqrt(dx * dx + dy * dy);
}
// x,y is to the right of the event rectangle
return dx;
}
// x < left
float dx = left - x;
if (y < top) {
// the upper left corner
float dy = top - y;
return (float) Math.sqrt(dx * dx + dy * dy);
}
if (y > bottom) {
// the lower left corner
float dy = y - bottom;
return (float) Math.sqrt(dx * dx + dy * dy);
}
// x,y is to the left of the event rectangle
return dx;
|
void | setCellMargin(int cellMargin)
mCellMargin = cellMargin;
|
void | setHourGap(float gap)
mHourGap = gap;
|
void | setHourHeight(float height)
mMinuteHeight = height / 60.0f;
|
void | setMinEventHeight(float height)
mMinEventHeight = height;
|