Skip to content

Commit 0af2288

Browse files
author
Jens Claes
committed
Merge branch 'pr-269' into develop
2 parents 7a959b2 + 8678909 commit 0af2288

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ private enum Direction {
9393
private boolean mIsZooming;
9494
private Calendar mFirstVisibleDay;
9595
private Calendar mLastVisibleDay;
96+
private boolean mShowFirstDayOfWeekFirst = false;
9697
private int mDefaultEventColor;
9798
private int mMinimumFlingVelocity = 0;
9899
private int mScaledTouchSlop = 0;
@@ -319,6 +320,7 @@ public WeekView(Context context, AttributeSet attrs, int defStyleAttr) {
319320
mColumnGap = a.getDimensionPixelSize(R.styleable.WeekView_columnGap, mColumnGap);
320321
mHeaderColumnTextColor = a.getColor(R.styleable.WeekView_headerColumnTextColor, mHeaderColumnTextColor);
321322
mNumberOfVisibleDays = a.getInteger(R.styleable.WeekView_noOfVisibleDays, mNumberOfVisibleDays);
323+
mShowFirstDayOfWeekFirst = a.getBoolean(R.styleable.WeekView_showFirstDayOfWeekFirst, mShowFirstDayOfWeekFirst);
322324
mHeaderRowPadding = a.getDimensionPixelSize(R.styleable.WeekView_headerRowPadding, mHeaderRowPadding);
323325
mHeaderRowBackgroundColor = a.getColor(R.styleable.WeekView_headerRowBackgroundColor, mHeaderRowBackgroundColor);
324326
mDayBackgroundColor = a.getColor(R.styleable.WeekView_dayBackgroundColor, mDayBackgroundColor);
@@ -564,8 +566,8 @@ private void drawHeaderRowAndEvents(Canvas canvas) {
564566
mIsFirstDraw = false;
565567

566568
// If the week view is being drawn for the first time, then consider the first day of the week.
567-
if(mNumberOfVisibleDays >= 7 && today.get(Calendar.DAY_OF_WEEK) != mFirstDayOfWeek) {
568-
int difference = 7 + (today.get(Calendar.DAY_OF_WEEK) - mFirstDayOfWeek);
569+
if(mNumberOfVisibleDays >= 7 && today.get(Calendar.DAY_OF_WEEK) != mFirstDayOfWeek && mShowFirstDayOfWeekFirst) {
570+
int difference = (today.get(Calendar.DAY_OF_WEEK) - mFirstDayOfWeek);
569571
mCurrentOrigin.x += (mWidthPerDay + mColumnGap) * difference;
570572
}
571573
}
@@ -1418,6 +1420,14 @@ public void setFirstDayOfWeek(int firstDayOfWeek) {
14181420
invalidate();
14191421
}
14201422

1423+
public boolean isShowFirstDayOfWeekFirst() {
1424+
return mShowFirstDayOfWeekFirst;
1425+
}
1426+
1427+
public void setShowFirstDayOfWeekFirst(boolean show) {
1428+
mShowFirstDayOfWeekFirst = show;
1429+
}
1430+
14211431
public int getTextSize() {
14221432
return mTextSize;
14231433
}

library/src/main/res/values/attrs.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<attr name="columnGap" format="dimension"/>
2121
<attr name="headerColumnTextColor" format="color"/>
2222
<attr name="noOfVisibleDays" format="integer"/>
23+
<attr name="showFirstDayOfWeekFirst" format="boolean"/>
2324
<attr name="headerRowBackgroundColor" format="color"/>
2425
<attr name="dayBackgroundColor" format="color"/>
2526
<attr name="hourSeparatorColor" format="color"/>

0 commit comments

Comments
 (0)