如何将一周的第一天和一周的最后一天设置为白色?

How to set first day of week and last day of week to be white colour?

我正在尝试实现一个日历,其中一周的第一天和一周的最后几天的颜色不同。现在我可以给今天的日子、活动日和通常的日子上色了,但是,我不知道如何比较 "Day" 是否是一周的第一天。

我有这个功能:

    /**
     * This method is used to set a color of texts, font types and backgrounds of TextView objects
     * in a current visible month. Visible day labels from previous and forward months are set using
     * setDayColors() method. It also checks if a day number is a day number of today and set it
     * a different color and bold face type.
     *
     * @param day                A calendar instance representing day date
     * @param today              A calendar instance representing today date
     * @param dayLabel           TextView containing a day numberx
     * @param calendarProperties A resource of a color used to mark today day
     */
    public static void setCurrentMonthDayColors(Calendar day, Calendar today, TextView dayLabel,
                                                CalendarProperties calendarProperties) {
        Log.i(TAG,"Day: " + day);
        if (today.equals(day)) {
            setDayColors(dayLabel, calendarProperties.getTodayLabelColor(), Typeface.BOLD,
                    R.drawable.background_transparent);
        } else if (EventDayUtils.isEventDayWithLabelColor(day, calendarProperties)) {
            EventDayUtils.getEventDayWithLabelColor(day, calendarProperties).executeIfPresent(eventDay ->
                DayColorsUtils.setDayColors(dayLabel, eventDay.getLabelColor(),
                        Typeface.NORMAL, R.drawable.background_transparent));

        } else if (calendarProperties.getHighlightedDays().contains(day)) {
            setDayColors(dayLabel, calendarProperties.getHighlightedDaysLabelsColor(),
                    Typeface.NORMAL, R.drawable.background_transparent);
        } else if (day.equals(GregorianCalendar.getInstance().getFirstDayOfWeek())) {
            setDayColors(dayLabel, Color.WHITE, Typeface.BOLD,
                    R.drawable.background_transparent);
        } else {
            setDayColors(dayLabel, calendarProperties.getDaysLabelsColor(), Typeface.BOLD,
                    R.drawable.background_transparent);
        }
    }

现在在这个 else if:

else if (day.equals(GregorianCalendar.getInstance().getFirstDayOfWeek())) {
            setDayColors(dayLabel, Color.WHITE, Typeface.BOLD,
                    R.drawable.background_transparent);

我正在尝试比较我们现在设置的日期是否是一周的第一天,但​​是,每次我尝试比较时,我都知道您可以将日历对象与 int 进行比较。从日志中,我可以看出 "day" 对象有一个字段,说明它是星期几:

DAY_OF_WEEK=1

如果设置为白色,应该检查该值是否为第一天。

这样解决了:

 else if (day.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY ||
                day.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY) {
            setDayColors(dayLabel, Color.WHITE, Typeface.NORMAL,
                    R.drawable.background_transparent);