FileDocCategorySizeDatePackage
CalendarViewLegacyDelegate.javaAPI DocAndroid 5.1 API53521Thu Mar 12 22:22:10 GMT 2015android.widget

CalendarViewLegacyDelegate

public class CalendarViewLegacyDelegate extends CalendarView.AbstractCalendarViewDelegate
A delegate implementing the legacy CalendarView

Fields Summary
private static final boolean
DEFAULT_SHOW_WEEK_NUMBER
Default value whether to show week number.
private static final long
MILLIS_IN_DAY
The number of milliseconds in a day.e
private static final int
DAYS_PER_WEEK
The number of day in a week.
private static final long
MILLIS_IN_WEEK
The number of milliseconds in a week.
private static final int
SCROLL_HYST_WEEKS
Affects when the month selection will change while scrolling upe
private static final int
GOTO_SCROLL_DURATION
How long the GoTo fling animation should last.
private static final int
ADJUSTMENT_SCROLL_DURATION
The duration of the adjustment upon a user scroll in milliseconds.
private static final int
SCROLL_CHANGE_DELAY
How long to wait after receiving an onScrollStateChanged notification before acting on it.
private static final int
DEFAULT_SHOWN_WEEK_COUNT
private static final int
DEFAULT_DATE_TEXT_SIZE
private static final int
UNSCALED_SELECTED_DATE_VERTICAL_BAR_WIDTH
private static final int
UNSCALED_WEEK_MIN_VISIBLE_HEIGHT
private static final int
UNSCALED_LIST_SCROLL_TOP_OFFSET
private static final int
UNSCALED_BOTTOM_BUFFER
private static final int
UNSCALED_WEEK_SEPARATOR_LINE_WIDTH
private static final int
DEFAULT_WEEK_DAY_TEXT_APPEARANCE_RES_ID
private final int
mWeekSeperatorLineWidth
private int
mDateTextSize
private android.graphics.drawable.Drawable
mSelectedDateVerticalBar
private final int
mSelectedDateVerticalBarWidth
private int
mSelectedWeekBackgroundColor
private int
mFocusedMonthDateColor
private int
mUnfocusedMonthDateColor
private int
mWeekSeparatorLineColor
private int
mWeekNumberColor
private int
mWeekDayTextAppearanceResId
private int
mDateTextAppearanceResId
private int
mListScrollTopOffset
The top offset of the weeks list.
private int
mWeekMinVisibleHeight
The visible height of a week view.
private int
mBottomBuffer
The visible height of a week view.
private int
mShownWeekCount
The number of shown weeks.
private boolean
mShowWeekNumber
Flag whether to show the week number.
private int
mDaysPerWeek
The number of day per week to be shown.
private float
mFriction
The friction of the week list while flinging.
private float
mVelocityScale
Scale for adjusting velocity of the week list while flinging.
private WeeksAdapter
mAdapter
The adapter for the weeks list.
private ListView
mListView
The weeks list.
private TextView
mMonthName
The name of the month to display.
private android.view.ViewGroup
mDayNamesHeader
The header with week day names.
private String[]
mDayNamesShort
Cached abbreviations for day of week names.
private String[]
mDayNamesLong
Cached full-length day of week names.
private int
mFirstDayOfWeek
The first day of the week.
private int
mCurrentMonthDisplayed
Which month should be displayed/highlighted [0-11].
private long
mPreviousScrollPosition
Used for tracking during a scroll.
private boolean
mIsScrollingUp
Used for tracking which direction the view is scrolling.
private int
mPreviousScrollState
The previous scroll state of the weeks ListView.
private int
mCurrentScrollState
The current scroll state of the weeks ListView.
private CalendarView.OnDateChangeListener
mOnDateChangeListener
Listener for changes in the selected day.
private ScrollStateRunnable
mScrollStateChangedRunnable
Command for adjusting the position after a scroll/fling.
private Calendar
mTempDate
Temporary instance to avoid multiple instantiations.
private Calendar
mFirstDayOfMonth
The first day of the focused month.
private Calendar
mMinDate
The start date of the range supported by this picker.
private Calendar
mMaxDate
The end date of the range supported by this picker.
Constructors Summary
CalendarViewLegacyDelegate(CalendarView delegator, android.content.Context context, android.util.AttributeSet attrs, int defStyleAttr, int defStyleRes)


         
                
        super(delegator, context);

        final TypedArray a = context.obtainStyledAttributes(attrs,
                R.styleable.CalendarView, defStyleAttr, defStyleRes);
        mShowWeekNumber = a.getBoolean(R.styleable.CalendarView_showWeekNumber,
                DEFAULT_SHOW_WEEK_NUMBER);
        mFirstDayOfWeek = a.getInt(R.styleable.CalendarView_firstDayOfWeek,
                LocaleData.get(Locale.getDefault()).firstDayOfWeek);
        final String minDate = a.getString(R.styleable.CalendarView_minDate);
        if (TextUtils.isEmpty(minDate) || !parseDate(minDate, mMinDate)) {
            parseDate(DEFAULT_MIN_DATE, mMinDate);
        }
        final String maxDate = a.getString(R.styleable.CalendarView_maxDate);
        if (TextUtils.isEmpty(maxDate) || !parseDate(maxDate, mMaxDate)) {
            parseDate(DEFAULT_MAX_DATE, mMaxDate);
        }
        if (mMaxDate.before(mMinDate)) {
            throw new IllegalArgumentException("Max date cannot be before min date.");
        }
        mShownWeekCount = a.getInt(R.styleable.CalendarView_shownWeekCount,
                DEFAULT_SHOWN_WEEK_COUNT);
        mSelectedWeekBackgroundColor = a.getColor(
                R.styleable.CalendarView_selectedWeekBackgroundColor, 0);
        mFocusedMonthDateColor = a.getColor(
                R.styleable.CalendarView_focusedMonthDateColor, 0);
        mUnfocusedMonthDateColor = a.getColor(
                R.styleable.CalendarView_unfocusedMonthDateColor, 0);
        mWeekSeparatorLineColor = a.getColor(
                R.styleable.CalendarView_weekSeparatorLineColor, 0);
        mWeekNumberColor = a.getColor(R.styleable.CalendarView_weekNumberColor, 0);
        mSelectedDateVerticalBar = a.getDrawable(
                R.styleable.CalendarView_selectedDateVerticalBar);

        mDateTextAppearanceResId = a.getResourceId(
                R.styleable.CalendarView_dateTextAppearance, R.style.TextAppearance_Small);
        updateDateTextSize();

        mWeekDayTextAppearanceResId = a.getResourceId(
                R.styleable.CalendarView_weekDayTextAppearance,
                DEFAULT_WEEK_DAY_TEXT_APPEARANCE_RES_ID);
        a.recycle();

        DisplayMetrics displayMetrics = mDelegator.getResources().getDisplayMetrics();
        mWeekMinVisibleHeight = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
                UNSCALED_WEEK_MIN_VISIBLE_HEIGHT, displayMetrics);
        mListScrollTopOffset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
                UNSCALED_LIST_SCROLL_TOP_OFFSET, displayMetrics);
        mBottomBuffer = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
                UNSCALED_BOTTOM_BUFFER, displayMetrics);
        mSelectedDateVerticalBarWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
                UNSCALED_SELECTED_DATE_VERTICAL_BAR_WIDTH, displayMetrics);
        mWeekSeperatorLineWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
                UNSCALED_WEEK_SEPARATOR_LINE_WIDTH, displayMetrics);

        LayoutInflater layoutInflater = (LayoutInflater) mContext
                .getSystemService(Service.LAYOUT_INFLATER_SERVICE);
        View content = layoutInflater.inflate(R.layout.calendar_view, null, false);
        mDelegator.addView(content);

        mListView = (ListView) mDelegator.findViewById(R.id.list);
        mDayNamesHeader = (ViewGroup) content.findViewById(R.id.day_names);
        mMonthName = (TextView) content.findViewById(R.id.month_name);

        setUpHeader();
        setUpListView();
        setUpAdapter();

        // go to today or whichever is close to today min or max date
        mTempDate.setTimeInMillis(System.currentTimeMillis());
        if (mTempDate.before(mMinDate)) {
            goTo(mMinDate, false, true, true);
        } else if (mMaxDate.before(mTempDate)) {
            goTo(mMaxDate, false, true, true);
        } else {
            goTo(mTempDate, false, true, true);
        }

        mDelegator.invalidate();
    
Methods Summary
private static java.util.CalendargetCalendarForLocale(java.util.Calendar oldCalendar, java.util.Locale locale)
Gets a calendar for locale bootstrapped with the value of a given calendar.

param
oldCalendar The old calendar.
param
locale The locale.

        if (oldCalendar == null) {
            return Calendar.getInstance(locale);
        } else {
            final long currentTimeMillis = oldCalendar.getTimeInMillis();
            Calendar newCalendar = Calendar.getInstance(locale);
            newCalendar.setTimeInMillis(currentTimeMillis);
            return newCalendar;
        }
    
public longgetDate()

        return mAdapter.mSelectedDate.getTimeInMillis();
    
public intgetDateTextAppearance()

        return mDateTextAppearanceResId;
    
public intgetFirstDayOfWeek()

        return mFirstDayOfWeek;
    
public intgetFocusedMonthDateColor()

        return mFocusedMonthDateColor;
    
public longgetMaxDate()

        return mMaxDate.getTimeInMillis();
    
public longgetMinDate()

        return mMinDate.getTimeInMillis();
    
public android.graphics.drawable.DrawablegetSelectedDateVerticalBar()

        return mSelectedDateVerticalBar;
    
public intgetSelectedWeekBackgroundColor()

        return mSelectedWeekBackgroundColor;
    
public booleangetShowWeekNumber()

        return mShowWeekNumber;
    
public intgetShownWeekCount()

        return mShownWeekCount;
    
public intgetUnfocusedMonthDateColor()

        return mFocusedMonthDateColor;
    
public intgetWeekDayTextAppearance()

        return mWeekDayTextAppearanceResId;
    
public intgetWeekNumberColor()

        return mWeekNumberColor;
    
public intgetWeekSeparatorLineColor()

        return mWeekSeparatorLineColor;
    
private intgetWeeksSinceMinDate(java.util.Calendar date)

return
Returns the number of weeks between the current date and the mMinDate.

        if (date.before(mMinDate)) {
            throw new IllegalArgumentException("fromDate: " + mMinDate.getTime()
                    + " does not precede toDate: " + date.getTime());
        }
        long endTimeMillis = date.getTimeInMillis()
                + date.getTimeZone().getOffset(date.getTimeInMillis());
        long startTimeMillis = mMinDate.getTimeInMillis()
                + mMinDate.getTimeZone().getOffset(mMinDate.getTimeInMillis());
        long dayOffsetMillis = (mMinDate.get(Calendar.DAY_OF_WEEK) - mFirstDayOfWeek)
                * MILLIS_IN_DAY;
        return (int) ((endTimeMillis - startTimeMillis + dayOffsetMillis) / MILLIS_IN_WEEK);
    
private voidgoTo(java.util.Calendar date, boolean animate, boolean setSelected, boolean forceScroll)
This moves to the specified time in the view. If the time is not already in range it will move the list so that the first of the month containing the time is at the top of the view. If the new time is already in view the list will not be scrolled unless forceScroll is true. This time may optionally be highlighted as selected as well.

param
date The time to move to.
param
animate Whether to scroll to the given time or just redraw at the new location.
param
setSelected Whether to set the given time as selected.
param
forceScroll Whether to recenter even if the time is already visible.
throws
IllegalArgumentException of the provided date is before the range start of after the range end.

        if (date.before(mMinDate) || date.after(mMaxDate)) {
            throw new IllegalArgumentException("Time not between " + mMinDate.getTime()
                    + " and " + mMaxDate.getTime());
        }
        // Find the first and last entirely visible weeks
        int firstFullyVisiblePosition = mListView.getFirstVisiblePosition();
        View firstChild = mListView.getChildAt(0);
        if (firstChild != null && firstChild.getTop() < 0) {
            firstFullyVisiblePosition++;
        }
        int lastFullyVisiblePosition = firstFullyVisiblePosition + mShownWeekCount - 1;
        if (firstChild != null && firstChild.getTop() > mBottomBuffer) {
            lastFullyVisiblePosition--;
        }
        if (setSelected) {
            mAdapter.setSelectedDay(date);
        }
        // Get the week we're going to
        int position = getWeeksSinceMinDate(date);

        // Check if the selected day is now outside of our visible range
        // and if so scroll to the month that contains it
        if (position < firstFullyVisiblePosition || position > lastFullyVisiblePosition
                || forceScroll) {
            mFirstDayOfMonth.setTimeInMillis(date.getTimeInMillis());
            mFirstDayOfMonth.set(Calendar.DAY_OF_MONTH, 1);

            setMonthDisplayed(mFirstDayOfMonth);

            // the earliest time we can scroll to is the min date
            if (mFirstDayOfMonth.before(mMinDate)) {
                position = 0;
            } else {
                position = getWeeksSinceMinDate(mFirstDayOfMonth);
            }

            mPreviousScrollState = AbsListView.OnScrollListener.SCROLL_STATE_FLING;
            if (animate) {
                mListView.smoothScrollToPositionFromTop(position, mListScrollTopOffset,
                        GOTO_SCROLL_DURATION);
            } else {
                mListView.setSelectionFromTop(position, mListScrollTopOffset);
                // Perform any after scroll operations that are needed
                onScrollStateChanged(mListView, AbsListView.OnScrollListener.SCROLL_STATE_IDLE);
            }
        } else if (setSelected) {
            // Otherwise just set the selection
            setMonthDisplayed(date);
        }
    
private voidinvalidateAllWeekViews()
Invalidates all week views.

        final int childCount = mListView.getChildCount();
        for (int i = 0; i < childCount; i++) {
            View view = mListView.getChildAt(i);
            view.invalidate();
        }
    
private static booleanisSameDate(java.util.Calendar firstDate, java.util.Calendar secondDate)

return
True if the firstDate is the same as the secondDate.

        return (firstDate.get(Calendar.DAY_OF_YEAR) == secondDate.get(Calendar.DAY_OF_YEAR)
                && firstDate.get(Calendar.YEAR) == secondDate.get(Calendar.YEAR));
    
public voidonConfigurationChanged(android.content.res.Configuration newConfig)

        setCurrentLocale(newConfig.locale);
    
private voidonScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount)
Updates the title and selected month if the view has moved to a new month.

        WeekView child = (WeekView) view.getChildAt(0);
        if (child == null) {
            return;
        }

        // Figure out where we are
        long currScroll =
                view.getFirstVisiblePosition() * child.getHeight() - child.getBottom();

        // If we have moved since our last call update the direction
        if (currScroll < mPreviousScrollPosition) {
            mIsScrollingUp = true;
        } else if (currScroll > mPreviousScrollPosition) {
            mIsScrollingUp = false;
        } else {
            return;
        }

        // Use some hysteresis for checking which month to highlight. This
        // causes the month to transition when two full weeks of a month are
        // visible when scrolling up, and when the first day in a month reaches
        // the top of the screen when scrolling down.
        int offset = child.getBottom() < mWeekMinVisibleHeight ? 1 : 0;
        if (mIsScrollingUp) {
            child = (WeekView) view.getChildAt(SCROLL_HYST_WEEKS + offset);
        } else if (offset != 0) {
            child = (WeekView) view.getChildAt(offset);
        }

        if (child != null) {
            // Find out which month we're moving into
            int month;
            if (mIsScrollingUp) {
                month = child.getMonthOfFirstWeekDay();
            } else {
                month = child.getMonthOfLastWeekDay();
            }

            // And how it relates to our current highlighted month
            int monthDiff;
            if (mCurrentMonthDisplayed == 11 && month == 0) {
                monthDiff = 1;
            } else if (mCurrentMonthDisplayed == 0 && month == 11) {
                monthDiff = -1;
            } else {
                monthDiff = month - mCurrentMonthDisplayed;
            }

            // Only switch months if we're scrolling away from the currently
            // selected month
            if ((!mIsScrollingUp && monthDiff > 0) || (mIsScrollingUp && monthDiff < 0)) {
                Calendar firstDay = child.getFirstDay();
                if (mIsScrollingUp) {
                    firstDay.add(Calendar.DAY_OF_MONTH, -DAYS_PER_WEEK);
                } else {
                    firstDay.add(Calendar.DAY_OF_MONTH, DAYS_PER_WEEK);
                }
                setMonthDisplayed(firstDay);
            }
        }
        mPreviousScrollPosition = currScroll;
        mPreviousScrollState = mCurrentScrollState;
    
private voidonScrollStateChanged(AbsListView view, int scrollState)
Called when a view transitions to a new scrollState .

        mScrollStateChangedRunnable.doScrollStateChange(view, scrollState);
    
protected voidsetCurrentLocale(java.util.Locale locale)
Sets the current locale.

param
locale The current locale.

        super.setCurrentLocale(locale);

        mTempDate = getCalendarForLocale(mTempDate, locale);
        mFirstDayOfMonth = getCalendarForLocale(mFirstDayOfMonth, locale);
        mMinDate = getCalendarForLocale(mMinDate, locale);
        mMaxDate = getCalendarForLocale(mMaxDate, locale);
    
public voidsetDate(long date)

        setDate(date, false, false);
    
public voidsetDate(long date, boolean animate, boolean center)

        mTempDate.setTimeInMillis(date);
        if (isSameDate(mTempDate, mAdapter.mSelectedDate)) {
            return;
        }
        goTo(mTempDate, animate, true, center);
    
public voidsetDateTextAppearance(int resourceId)

        if (mDateTextAppearanceResId != resourceId) {
            mDateTextAppearanceResId = resourceId;
            updateDateTextSize();
            invalidateAllWeekViews();
        }
    
public voidsetFirstDayOfWeek(int firstDayOfWeek)

        if (mFirstDayOfWeek == firstDayOfWeek) {
            return;
        }
        mFirstDayOfWeek = firstDayOfWeek;
        mAdapter.init();
        mAdapter.notifyDataSetChanged();
        setUpHeader();
    
public voidsetFocusedMonthDateColor(int color)

        if (mFocusedMonthDateColor != color) {
            mFocusedMonthDateColor = color;
            final int childCount = mListView.getChildCount();
            for (int i = 0; i < childCount; i++) {
                WeekView weekView = (WeekView) mListView.getChildAt(i);
                if (weekView.mHasFocusedDay) {
                    weekView.invalidate();
                }
            }
        }
    
public voidsetMaxDate(long maxDate)

        mTempDate.setTimeInMillis(maxDate);
        if (isSameDate(mTempDate, mMaxDate)) {
            return;
        }
        mMaxDate.setTimeInMillis(maxDate);
        // reinitialize the adapter since its range depends on max date
        mAdapter.init();
        Calendar date = mAdapter.mSelectedDate;
        if (date.after(mMaxDate)) {
            setDate(mMaxDate.getTimeInMillis());
        } else {
            // we go to the current date to force the ListView to query its
            // adapter for the shown views since we have changed the adapter
            // range and the base from which the later calculates item indices
            // note that calling setDate will not work since the date is the same
            goTo(date, false, true, false);
        }
    
public voidsetMinDate(long minDate)

        mTempDate.setTimeInMillis(minDate);
        if (isSameDate(mTempDate, mMinDate)) {
            return;
        }
        mMinDate.setTimeInMillis(minDate);
        // make sure the current date is not earlier than
        // the new min date since the latter is used for
        // calculating the indices in the adapter thus
        // avoiding out of bounds error
        Calendar date = mAdapter.mSelectedDate;
        if (date.before(mMinDate)) {
            mAdapter.setSelectedDay(mMinDate);
        }
        // reinitialize the adapter since its range depends on min date
        mAdapter.init();
        if (date.before(mMinDate)) {
            setDate(mTempDate.getTimeInMillis());
        } else {
            // we go to the current date to force the ListView to query its
            // adapter for the shown views since we have changed the adapter
            // range and the base from which the later calculates item indices
            // note that calling setDate will not work since the date is the same
            goTo(date, false, true, false);
        }
    
private voidsetMonthDisplayed(java.util.Calendar calendar)
Sets the month displayed at the top of this view based on time. Override to add custom events when the title is changed.

param
calendar A day in the new focus month.

        mCurrentMonthDisplayed = calendar.get(Calendar.MONTH);
        mAdapter.setFocusMonth(mCurrentMonthDisplayed);
        final int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_NO_MONTH_DAY
                | DateUtils.FORMAT_SHOW_YEAR;
        final long millis = calendar.getTimeInMillis();
        String newMonthName = DateUtils.formatDateRange(mContext, millis, millis, flags);
        mMonthName.setText(newMonthName);
        mMonthName.invalidate();
    
public voidsetOnDateChangeListener(CalendarView.OnDateChangeListener listener)

        mOnDateChangeListener = listener;
    
public voidsetSelectedDateVerticalBar(int resourceId)

        Drawable drawable = mDelegator.getContext().getDrawable(resourceId);
        setSelectedDateVerticalBar(drawable);
    
public voidsetSelectedDateVerticalBar(android.graphics.drawable.Drawable drawable)

        if (mSelectedDateVerticalBar != drawable) {
            mSelectedDateVerticalBar = drawable;
            final int childCount = mListView.getChildCount();
            for (int i = 0; i < childCount; i++) {
                WeekView weekView = (WeekView) mListView.getChildAt(i);
                if (weekView.mHasSelectedDay) {
                    weekView.invalidate();
                }
            }
        }
    
public voidsetSelectedWeekBackgroundColor(int color)

        if (mSelectedWeekBackgroundColor != color) {
            mSelectedWeekBackgroundColor = color;
            final int childCount = mListView.getChildCount();
            for (int i = 0; i < childCount; i++) {
                WeekView weekView = (WeekView) mListView.getChildAt(i);
                if (weekView.mHasSelectedDay) {
                    weekView.invalidate();
                }
            }
        }
    
public voidsetShowWeekNumber(boolean showWeekNumber)

        if (mShowWeekNumber == showWeekNumber) {
            return;
        }
        mShowWeekNumber = showWeekNumber;
        mAdapter.notifyDataSetChanged();
        setUpHeader();
    
public voidsetShownWeekCount(int count)

        if (mShownWeekCount != count) {
            mShownWeekCount = count;
            mDelegator.invalidate();
        }
    
public voidsetUnfocusedMonthDateColor(int color)

        if (mUnfocusedMonthDateColor != color) {
            mUnfocusedMonthDateColor = color;
            final int childCount = mListView.getChildCount();
            for (int i = 0; i < childCount; i++) {
                WeekView weekView = (WeekView) mListView.getChildAt(i);
                if (weekView.mHasUnfocusedDay) {
                    weekView.invalidate();
                }
            }
        }
    
private voidsetUpAdapter()
Creates a new adapter if necessary and sets up its parameters.

        if (mAdapter == null) {
            mAdapter = new WeeksAdapter(mContext);
            mAdapter.registerDataSetObserver(new DataSetObserver() {
                @Override
                public void onChanged() {
                    if (mOnDateChangeListener != null) {
                        Calendar selectedDay = mAdapter.getSelectedDay();
                        mOnDateChangeListener.onSelectedDayChange(mDelegator,
                                selectedDay.get(Calendar.YEAR),
                                selectedDay.get(Calendar.MONTH),
                                selectedDay.get(Calendar.DAY_OF_MONTH));
                    }
                }
            });
            mListView.setAdapter(mAdapter);
        }

        // refresh the view with the new parameters
        mAdapter.notifyDataSetChanged();
    
private voidsetUpHeader()
Sets up the strings to be used by the header.

        mDayNamesShort = new String[mDaysPerWeek];
        mDayNamesLong = new String[mDaysPerWeek];
        for (int i = mFirstDayOfWeek, count = mFirstDayOfWeek + mDaysPerWeek; i < count; i++) {
            int calendarDay = (i > Calendar.SATURDAY) ? i - Calendar.SATURDAY : i;
            mDayNamesShort[i - mFirstDayOfWeek] = DateUtils.getDayOfWeekString(calendarDay,
                    DateUtils.LENGTH_SHORTEST);
            mDayNamesLong[i - mFirstDayOfWeek] = DateUtils.getDayOfWeekString(calendarDay,
                    DateUtils.LENGTH_LONG);
        }

        TextView label = (TextView) mDayNamesHeader.getChildAt(0);
        if (mShowWeekNumber) {
            label.setVisibility(View.VISIBLE);
        } else {
            label.setVisibility(View.GONE);
        }
        for (int i = 1, count = mDayNamesHeader.getChildCount(); i < count; i++) {
            label = (TextView) mDayNamesHeader.getChildAt(i);
            if (mWeekDayTextAppearanceResId > -1) {
                label.setTextAppearance(mContext, mWeekDayTextAppearanceResId);
            }
            if (i < mDaysPerWeek + 1) {
                label.setText(mDayNamesShort[i - 1]);
                label.setContentDescription(mDayNamesLong[i - 1]);
                label.setVisibility(View.VISIBLE);
            } else {
                label.setVisibility(View.GONE);
            }
        }
        mDayNamesHeader.invalidate();
    
private voidsetUpListView()
Sets all the required fields for the list view.

        // Configure the listview
        mListView.setDivider(null);
        mListView.setItemsCanFocus(true);
        mListView.setVerticalScrollBarEnabled(false);
        mListView.setOnScrollListener(new AbsListView.OnScrollListener() {
            public void onScrollStateChanged(AbsListView view, int scrollState) {
                CalendarViewLegacyDelegate.this.onScrollStateChanged(view, scrollState);
            }

            public void onScroll(
                    AbsListView view, int firstVisibleItem, int visibleItemCount,
                    int totalItemCount) {
                CalendarViewLegacyDelegate.this.onScroll(view, firstVisibleItem,
                        visibleItemCount, totalItemCount);
            }
        });
        // Make the scrolling behavior nicer
        mListView.setFriction(mFriction);
        mListView.setVelocityScale(mVelocityScale);
    
public voidsetWeekDayTextAppearance(int resourceId)

        if (mWeekDayTextAppearanceResId != resourceId) {
            mWeekDayTextAppearanceResId = resourceId;
            setUpHeader();
        }
    
public voidsetWeekNumberColor(int color)

        if (mWeekNumberColor != color) {
            mWeekNumberColor = color;
            if (mShowWeekNumber) {
                invalidateAllWeekViews();
            }
        }
    
public voidsetWeekSeparatorLineColor(int color)

        if (mWeekSeparatorLineColor != color) {
            mWeekSeparatorLineColor = color;
            invalidateAllWeekViews();
        }
    
private voidupdateDateTextSize()

        TypedArray dateTextAppearance = mDelegator.getContext().obtainStyledAttributes(
                mDateTextAppearanceResId, R.styleable.TextAppearance);
        mDateTextSize = dateTextAppearance.getDimensionPixelSize(
                R.styleable.TextAppearance_textSize, DEFAULT_DATE_TEXT_SIZE);
        dateTextAppearance.recycle();