@@ -537,7 +537,7 @@ private void drawTimeColumnAndAxes(Canvas canvas) {
537
537
// Clip to paint in left column only.
538
538
canvas .clipRect (0 , mHeaderHeight + mHeaderRowPadding * 2 , mHeaderColumnWidth , getHeight (), Region .Op .REPLACE );
539
539
540
- for (int i = 0 ; i < 24 ; i ++) {
540
+ for (int i = mStartTime ; i < mEndTime ; i ++) {
541
541
float top = mHeaderHeight + mHeaderRowPadding * 2 + mCurrentOrigin .y + mHourHeight * (i -mStartTime ) + mHeaderMarginBottom ;
542
542
543
543
// 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.
@@ -613,7 +613,7 @@ else if (mNewHourHeight > mMaxHourHeight)
613
613
614
614
// Prepare to iterate for each day.
615
615
Calendar day = (Calendar ) today .clone ();
616
- day .add (Calendar .HOUR , 6 );
616
+ day .add (Calendar .HOUR_OF_DAY , 6 );
617
617
618
618
// Prepare to iterate for each hour to draw the hour lines.
619
619
int lineCount = (int ) ((getHeight () - mHeaderHeight - mHeaderRowPadding * 2 -
@@ -687,7 +687,7 @@ else if (day.before(today)) {
687
687
688
688
// Prepare the separator lines for hours.
689
689
int i = 0 ;
690
- for (int hourNumber = 0 ; hourNumber < 24 ; hourNumber ++) {
690
+ for (int hourNumber = mStartTime ; hourNumber < mEndTime ; hourNumber ++) {
691
691
float top = mHeaderHeight + mHeaderRowPadding * 2 + mCurrentOrigin .y + mHourHeight * (hourNumber -mStartTime ) + mTimeTextHeight /2 + mHeaderMarginBottom ;
692
692
if (top > mHeaderHeight + mHeaderRowPadding * 2 + mTimeTextHeight /2 + mHeaderMarginBottom - mHourSeparatorHeight && top < getHeight () && startPixel + mWidthPerDay - start > 0 ){
693
693
hourLines [i * 4 ] = start ;
@@ -714,8 +714,9 @@ else if (day.before(today)) {
714
714
if (mShowNowLine && sameDay ){
715
715
float startY = mHeaderHeight + mHeaderRowPadding * 2 + mTimeTextHeight /2 + mHeaderMarginBottom + mCurrentOrigin .y ;
716
716
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 );
719
720
}
720
721
721
722
// In the next iteration, start from the next day.
@@ -772,7 +773,7 @@ private Calendar getTimeFromPoint(float x, float y){
772
773
- mHeaderRowPadding * 2 - mTimeTextHeight /2 - mHeaderMarginBottom ;
773
774
int hour = (int )(pixelsFromZero / mHourHeight );
774
775
int minute = (int ) (60 * (pixelsFromZero - hour * mHourHeight ) / mHourHeight );
775
- day .add (Calendar .HOUR , hour );
776
+ day .add (Calendar .HOUR_OF_DAY , hour + mStartTime );
776
777
day .set (Calendar .MINUTE , minute );
777
778
return day ;
778
779
}
@@ -805,7 +806,7 @@ private void limitEventTime(Calendar date){
805
806
806
807
if (startTime !=null && endTime !=null && startTime .before (endTime )) {
807
808
mStartTime = Math .max (0 ,startTime .get (Calendar .HOUR_OF_DAY ));
808
- mEndTime = Math .min (24 ,endTime .get (Calendar .HOUR_OF_DAY ));
809
+ mEndTime = Math .min (24 ,endTime .get (Calendar .HOUR_OF_DAY )+ 1 );
809
810
return ;
810
811
}
811
812
}
0 commit comments