From bf5735fc03e8949670469f59bd3858e7c1c22fe9 Mon Sep 17 00:00:00 2001 From: khacpv Date: Mon, 4 Jul 2016 13:02:35 +0700 Subject: [PATCH] fix display current time line & onEmptyViewClicked --- library/src/main/java/com/alamkanak/weekview/WeekView.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/library/src/main/java/com/alamkanak/weekview/WeekView.java b/library/src/main/java/com/alamkanak/weekview/WeekView.java index 37ec2d125..6441bdd81 100755 --- a/library/src/main/java/com/alamkanak/weekview/WeekView.java +++ b/library/src/main/java/com/alamkanak/weekview/WeekView.java @@ -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. @@ -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, hour + mStartTime); day.set(Calendar.MINUTE, minute); return day; }