Skip to content

Commit bec4a2b

Browse files
committed
Organize some of the code
1 parent 6137a28 commit bec4a2b

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,10 @@ public boolean onDown(MotionEvent e) {
144144

145145
@Override
146146
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
147-
if(mIsZooming)
147+
if (mIsZooming)
148148
return true;
149+
150+
// Calculate the direction to scroll.
149151
if (mCurrentScrollDirection == Direction.NONE) {
150152
// allow scrolling only in one direction
151153
if (Math.abs(distanceX) > Math.abs(distanceY)){
@@ -156,19 +158,17 @@ public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float d
156158
}
157159
}
158160

161+
// Calculate the new origin after scroll.
159162
switch (mCurrentScrollDirection) {
160163
case HORIZONTAL:
161164
mCurrentOrigin.x -= distanceX * mXScrollingSpeed;
162165
ViewCompat.postInvalidateOnAnimation(WeekView.this);
163-
164166
break;
165167
case VERTICAL:
166168
mCurrentOrigin.y -= distanceY;
167169
ViewCompat.postInvalidateOnAnimation(WeekView.this);
168-
169170
break;
170171
}
171-
172172
return true;
173173
}
174174

@@ -564,14 +564,14 @@ else if(mNewHourHeight > mMaxHourHeight)
564564

565565
// Draw background color for each day.
566566
float start = (startPixel < mHeaderColumnWidth ? mHeaderColumnWidth : startPixel);
567-
if (mWidthPerDay + startPixel - start> 0){
568-
if(mUseNewColoring){
567+
if (mWidthPerDay + startPixel - start > 0){
568+
if (mUseNewColoring){
569569
boolean isWeekend = (day.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || day.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY);
570570
Paint pastPaint = isWeekend ? mPastWeekendBackgroundPaint : mPastBackgroundPaint;
571571
Paint futurePaint = isWeekend ? mFutureWeekendBackgroundPaint : mFutureBackgroundPaint;
572572
float startY = mHeaderTextHeight + mHeaderRowPadding * 2 + mTimeTextHeight/2 + mHeaderMarginBottom + mCurrentOrigin.y;
573573

574-
if(sameDay){
574+
if (sameDay){
575575
Calendar now = Calendar.getInstance();
576576
float beforeNow = (now.get(Calendar.HOUR_OF_DAY)+now.get(Calendar.MINUTE)/60.0f)*mHourHeight;
577577
canvas.drawRect(start, startY, startPixel + mWidthPerDay, startY+beforeNow, pastPaint);
@@ -582,7 +582,7 @@ else if(mNewHourHeight > mMaxHourHeight)
582582
canvas.drawRect(start, startY, startPixel + mWidthPerDay, getHeight(), futurePaint);
583583
}
584584
}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);
586586
}
587587
}
588588

@@ -1189,7 +1189,7 @@ public String interpretTime(int hour) {
11891189
public void setDateTimeInterpreter(DateTimeInterpreter dateTimeInterpreter){
11901190
this.mDateTimeInterpreter = dateTimeInterpreter;
11911191

1192-
// refresh time column width
1192+
// Refresh time column width.
11931193
initTextTimeWidth();
11941194
}
11951195

0 commit comments

Comments
 (0)