Skip to content

Commit bf5735f

Browse files
committed
fix display current time line & onEmptyViewClicked
1 parent 3ed0eb4 commit bf5735f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

library/src/main/java/com/alamkanak/weekview/WeekView.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -714,8 +714,9 @@ else if (day.before(today)) {
714714
if (mShowNowLine && sameDay){
715715
float startY = mHeaderHeight + mHeaderRowPadding * 2 + mTimeTextHeight/2 + mHeaderMarginBottom + mCurrentOrigin.y;
716716
Calendar now = Calendar.getInstance();
717-
float beforeNow = (now.get(Calendar.HOUR_OF_DAY) + now.get(Calendar.MINUTE)/60.0f) * mHourHeight;
718-
canvas.drawLine(start, startY + beforeNow, startPixel + mWidthPerDay, startY + beforeNow, mNowLinePaint);
717+
float beforeNow = (now.get(Calendar.HOUR_OF_DAY) - mStartTime + now.get(Calendar.MINUTE)/60.0f) * mHourHeight;
718+
float top = startY + beforeNow;
719+
canvas.drawLine(start, top, startPixel + mWidthPerDay, top, mNowLinePaint);
719720
}
720721

721722
// In the next iteration, start from the next day.
@@ -772,7 +773,7 @@ private Calendar getTimeFromPoint(float x, float y){
772773
- mHeaderRowPadding * 2 - mTimeTextHeight/2 - mHeaderMarginBottom;
773774
int hour = (int)(pixelsFromZero / mHourHeight);
774775
int minute = (int) (60 * (pixelsFromZero - hour * mHourHeight) / mHourHeight);
775-
day.add(Calendar.HOUR, hour);
776+
day.add(Calendar.HOUR, hour + mStartTime);
776777
day.set(Calendar.MINUTE, minute);
777778
return day;
778779
}

0 commit comments

Comments
 (0)