Buggy code:
private int mHeaderRowBackgroundColor = Color . WHITE ; private int mDayBackgroundColor = Color . rgb ( 245 , 245 , 245 ) ; private int mHourSeparatorColor = Color . rgb ( 230 , 230 , 230 ) ; private int mTodayBackgroundColor = Color . rgb ( 239 , 247 , 254 ) ; private int mHourSeparatorHeight = 2 ; private int mTodayHeaderTextColor = Color . rgb ( 39 , 137 , 228 ) ; private int mEventTextSize = 12 ; private int mEventTextColor = Color . BLACK ; private int mEventPadding = 8 ; private int mHeaderColumnBackgroundColor = Color . WHITE ; private int mDefaultEventColor ; private boolean mIsFirstDraw = true ; private boolean mAreDimensionsInvalid = true ; @ Deprecated private int mDayNameLength = WeekView . LENGTH_LONG ; private int mOverlappingEventGap = 0 ; private int mEventMarginVertical = 0 ; private float mXScrollingSpeed = 1.0F ; private Calendar mFirstVisibleDay ; private Calendar mLastVisibleDay ; private Calendar mScrollToDay = null ; private double mScrollToHour = - 1 ; private WeekView . EventClickListener mEventClickListener ; private WeekView . EventLongPressListener mEventLongPressListener ; private WeekView . MonthChangeListener mMonthChangeListener ; private WeekView . EmptyViewClickListener mEmptyViewClickListener ; private WeekView . EmptyViewLongPressListener mEmptyViewLongPressListener ; private DateTimeInterpreter mDateTimeInterpreter ; private WeekView . ScrollListener mScrollListener ; private final SimpleOnGestureListener mGestureListener = new GestureDetector . SimpleOnGestureListener ( ) { @ Override public boolean onDown ( MotionEvent e ) { } @ Override public boolean onScroll ( MotionEvent e1 , MotionEvent e2 , float distanceX , float distanceY ) { } @ Override public boolean onFling ( MotionEvent e1 , MotionEvent e2 , float velocityX , float velocityY ) { } @ Override public boolean onSingleTapConfirmed ( MotionEvent e ) { } @ Override public void onLongPress ( MotionEvent e ) { } } ; private enum Direction { NONE , HORIZONTAL , VERTICAL ; } public WeekView ( Context context ) { } public WeekView ( Context context , AttributeSet attrs ) { } public WeekView ( Context context , AttributeSet attrs , int defStyleAttr ) { } private void init ( ) { } @ Override protected void onDraw ( Canvas canvas ) { } private void drawTimeColumnAndAxes ( Canvas canvas ) { } private void drawHeaderRowAndEvents ( Canvas canvas ) { mHeaderColumnWidth = ( mTimeTextWidth ) + ( ( mHeaderColumnPadding ) * 2 ) ; mWidthPerDay = ( ( getWidth ( ) ) - ( mHeaderColumnWidth ) ) - ( ( mColumnGap ) * ( ( mNumberOfVisibleDays ) - 1 ) ) ; mWidthPerDay = ( mWidthPerDay ) // ( mNumberOfVisibleDays ) ; if ( mAreDimensionsInvalid ) { mAreDimensionsInvalid = false ; if ( ( mScrollToDay ) != null ) goToDate ( mScrollToDay ) ; mAreDimensionsInvalid = false ; if ( ( mScrollToHour ) >= 0 ) goToHour ( mScrollToHour ) ; mScrollToDay = null ; mScrollToHour = - 1 ; mAreDimensionsInvalid = false ; } if ( mIsFirstDraw ) { mIsFirstDraw = false ; if ( ( ( mNumberOfVisibleDays ) >= 7 ) && ( ( mToday . get ( Calendar . DAY_OF_WEEK ) ) != ( mFirstDayOfWeek ) ) ) { <START_BUG> int difference = 7 + ( ( mToday . get ( Calendar . DAY_OF_WEEK ) ) - ( mFirstDayOfWeek ) ) ; <END_BUG> mCurrentOrigin . x += ( ( mWidthPerDay ) + ( mColumnGap ) ) * difference ; } } if ( ( mCurrentScrollDirection ) == ( WeekView . Direction . HORIZONTAL ) ) mCurrentOrigin . x -= mDistanceX ; int leftDaysWithGaps = ( ( int ) ( - ( Math . ceil ( ( ( mCurrentOrigin . x ) // ( ( mWidthPerDay ) + ( mColumnGap ) ) ) ) ) ) ) ; float startFromPixel = ( ( mCurrentOrigin . x ) + ( ( ( mWidthPerDay ) + ( mColumnGap ) ) * leftDaysWithGaps ) ) + ( mHeaderColumnWidth ) ; float startPixel = startFromPixel ; Calendar day = ( ( Calendar ) ( mToday . clone ( ) ) ) ; day . add ( Calendar . HOUR , 6 ) ; int lineCount = ( ( int ) ( ( ( ( ( getHeight ( ) ) - ( mHeaderTextHeight ) ) - ( ( mHeaderRowPadding ) * 2 ) ) - ( mHeaderMarginBottom ) ) // ( mHourHeight ) ) ) + 1 ; lineCount = lineCount * ( ( mNumberOfVisibleDays ) + 1 ) ; float [ ] hourLines = new float [ lineCount * 4 ] ; if ( ( mEventRects ) != null ) { for ( WeekView . EventRect eventRect : mEventRects ) { eventRect . rectF = null ; } } Calendar oldFirstVisibleDay = mFirstVisibleDay ; mFirstVisibleDay = ( ( Calendar ) ( mToday . clone ( ) ) ) ; mFirstVisibleDay . add ( Calendar . DATE , leftDaysWithGaps ) ; if ( ( ! ( mFirstVisibleDay . equals ( oldFirstVisibleDay ) ) ) && ( ( mScrollListener ) != null ) ) { mScrollListener . onFirstVisibleDayChanged ( mFirstVisibleDay , oldFirstVisibleDay ) ; } for ( int dayNumber = leftDaysWithGaps + 1 ; dayNumber <= ( ( leftDaysWithGaps + ( mNumberOfVisibleDays ) ) + 1 ) ; dayNumber ++ ) { day = ( ( Calendar ) ( mToday . clone ( ) ) ) ; mLastVisibleDay = ( ( Calendar ) ( day . clone ( ) ) ) ; day . add ( Calendar . DATE , ( dayNumber - 1 ) ) ; mLastVisibleDay . add ( Calendar . DATE , ( dayNumber - 2 ) ) ; boolean sameDay = isSameDay ( day , mToday ) ;

Fix:
int difference = ( 7 + ( ( mToday . get ( Calendar . DAY_OF_WEEK ) ) - ( mFirstDayOfWeek ) ) ) % 7 ;