Skip to content

Commit

Permalink
fix display current time line & onEmptyViewClicked
Browse files Browse the repository at this point in the history
  • Loading branch information
khacpv committed Oct 6, 2016
1 parent 3ed0eb4 commit 82771f7
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions library/src/main/java/com/alamkanak/weekview/WeekView.java
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ private void drawTimeColumnAndAxes(Canvas canvas) {
// Clip to paint in left column only.
canvas.clipRect(0, mHeaderHeight + mHeaderRowPadding * 2, mHeaderColumnWidth, getHeight(), Region.Op.REPLACE);

for (int i = 0; i < 24; i++) {
for (int i = mStartTime; i < mEndTime; i++) {
float top = mHeaderHeight + mHeaderRowPadding * 2 + mCurrentOrigin.y + mHourHeight * (i-mStartTime) + mHeaderMarginBottom;

// Draw the text if its y position is not outside of the visible area. The pivot point of the text is the point at the bottom-right corner.
Expand Down Expand Up @@ -613,7 +613,7 @@ else if (mNewHourHeight > mMaxHourHeight)

// Prepare to iterate for each day.
Calendar day = (Calendar) today.clone();
day.add(Calendar.HOUR, 6);
day.add(Calendar.HOUR_OF_DAY, 6);

// Prepare to iterate for each hour to draw the hour lines.
int lineCount = (int) ((getHeight() - mHeaderHeight - mHeaderRowPadding * 2 -
Expand Down Expand Up @@ -687,7 +687,7 @@ else if (day.before(today)) {

// Prepare the separator lines for hours.
int i = 0;
for (int hourNumber = 0; hourNumber < 24; hourNumber++) {
for (int hourNumber = mStartTime; hourNumber < mEndTime; hourNumber++) {
float top = mHeaderHeight + mHeaderRowPadding * 2 + mCurrentOrigin.y + mHourHeight * (hourNumber-mStartTime) + mTimeTextHeight/2 + mHeaderMarginBottom;
if (top > mHeaderHeight + mHeaderRowPadding * 2 + mTimeTextHeight/2 + mHeaderMarginBottom - mHourSeparatorHeight && top < getHeight() && startPixel + mWidthPerDay - start > 0){
hourLines[i * 4] = start;
Expand All @@ -714,8 +714,9 @@ else if (day.before(today)) {
if (mShowNowLine && sameDay){
float startY = mHeaderHeight + mHeaderRowPadding * 2 + mTimeTextHeight/2 + mHeaderMarginBottom + mCurrentOrigin.y;
Calendar now = Calendar.getInstance();
float beforeNow = (now.get(Calendar.HOUR_OF_DAY) + now.get(Calendar.MINUTE)/60.0f) * mHourHeight;
canvas.drawLine(start, startY + beforeNow, startPixel + mWidthPerDay, startY + beforeNow, mNowLinePaint);
float beforeNow = (now.get(Calendar.HOUR_OF_DAY) - mStartTime + now.get(Calendar.MINUTE)/60.0f) * mHourHeight;
float top = startY + beforeNow;
canvas.drawLine(start, top, startPixel + mWidthPerDay, top, mNowLinePaint);
}

// In the next iteration, start from the next day.
Expand Down Expand Up @@ -772,7 +773,7 @@ private Calendar getTimeFromPoint(float x, float y){
- mHeaderRowPadding * 2 - mTimeTextHeight/2 - mHeaderMarginBottom;
int hour = (int)(pixelsFromZero / mHourHeight);
int minute = (int) (60 * (pixelsFromZero - hour * mHourHeight) / mHourHeight);
day.add(Calendar.HOUR, hour);
day.add(Calendar.HOUR_OF_DAY, hour + mStartTime);
day.set(Calendar.MINUTE, minute);
return day;
}
Expand Down Expand Up @@ -805,7 +806,7 @@ private void limitEventTime(Calendar date){

if(startTime!=null && endTime !=null && startTime.before(endTime)) {
mStartTime = Math.max(0,startTime.get(Calendar.HOUR_OF_DAY));
mEndTime = Math.min(24,endTime.get(Calendar.HOUR_OF_DAY));
mEndTime = Math.min(24,endTime.get(Calendar.HOUR_OF_DAY)+1);
return;
}
}
Expand Down

0 comments on commit 82771f7

Please sign in to comment.