@@ -144,8 +144,10 @@ public boolean onDown(MotionEvent e) {
144
144
145
145
@ Override
146
146
public boolean onScroll (MotionEvent e1 , MotionEvent e2 , float distanceX , float distanceY ) {
147
- if (mIsZooming )
147
+ if (mIsZooming )
148
148
return true ;
149
+
150
+ // Calculate the direction to scroll.
149
151
if (mCurrentScrollDirection == Direction .NONE ) {
150
152
// allow scrolling only in one direction
151
153
if (Math .abs (distanceX ) > Math .abs (distanceY )){
@@ -156,19 +158,17 @@ public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float d
156
158
}
157
159
}
158
160
161
+ // Calculate the new origin after scroll.
159
162
switch (mCurrentScrollDirection ) {
160
163
case HORIZONTAL :
161
164
mCurrentOrigin .x -= distanceX * mXScrollingSpeed ;
162
165
ViewCompat .postInvalidateOnAnimation (WeekView .this );
163
-
164
166
break ;
165
167
case VERTICAL :
166
168
mCurrentOrigin .y -= distanceY ;
167
169
ViewCompat .postInvalidateOnAnimation (WeekView .this );
168
-
169
170
break ;
170
171
}
171
-
172
172
return true ;
173
173
}
174
174
@@ -564,14 +564,14 @@ else if(mNewHourHeight > mMaxHourHeight)
564
564
565
565
// Draw background color for each day.
566
566
float start = (startPixel < mHeaderColumnWidth ? mHeaderColumnWidth : startPixel );
567
- if (mWidthPerDay + startPixel - start > 0 ){
568
- if (mUseNewColoring ){
567
+ if (mWidthPerDay + startPixel - start > 0 ){
568
+ if (mUseNewColoring ){
569
569
boolean isWeekend = (day .get (Calendar .DAY_OF_WEEK ) == Calendar .SATURDAY || day .get (Calendar .DAY_OF_WEEK ) == Calendar .SUNDAY );
570
570
Paint pastPaint = isWeekend ? mPastWeekendBackgroundPaint : mPastBackgroundPaint ;
571
571
Paint futurePaint = isWeekend ? mFutureWeekendBackgroundPaint : mFutureBackgroundPaint ;
572
572
float startY = mHeaderTextHeight + mHeaderRowPadding * 2 + mTimeTextHeight /2 + mHeaderMarginBottom + mCurrentOrigin .y ;
573
573
574
- if (sameDay ){
574
+ if (sameDay ){
575
575
Calendar now = Calendar .getInstance ();
576
576
float beforeNow = (now .get (Calendar .HOUR_OF_DAY )+now .get (Calendar .MINUTE )/60.0f )*mHourHeight ;
577
577
canvas .drawRect (start , startY , startPixel + mWidthPerDay , startY +beforeNow , pastPaint );
@@ -582,7 +582,7 @@ else if(mNewHourHeight > mMaxHourHeight)
582
582
canvas .drawRect (start , startY , startPixel + mWidthPerDay , getHeight (), futurePaint );
583
583
}
584
584
}else {
585
- canvas .drawRect (start , mHeaderTextHeight + mHeaderRowPadding * 2 + mTimeTextHeight / 2 + mHeaderMarginBottom , startPixel + mWidthPerDay , getHeight (), sameDay ? mTodayBackgroundPaint : mDayBackgroundPaint );
585
+ canvas .drawRect (start , mHeaderTextHeight + mHeaderRowPadding * 2 + mTimeTextHeight / 2 + mHeaderMarginBottom , startPixel + mWidthPerDay , getHeight (), sameDay ? mTodayBackgroundPaint : mDayBackgroundPaint );
586
586
}
587
587
}
588
588
@@ -1189,7 +1189,7 @@ public String interpretTime(int hour) {
1189
1189
public void setDateTimeInterpreter (DateTimeInterpreter dateTimeInterpreter ){
1190
1190
this .mDateTimeInterpreter = dateTimeInterpreter ;
1191
1191
1192
- // refresh time column width
1192
+ // Refresh time column width.
1193
1193
initTextTimeWidth ();
1194
1194
}
1195
1195
0 commit comments