hxb
2022-11-22 b3513b1713bb979d0a69c5a8c4ddcd038f184e6e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package com.mm.android.deviceaddmodule.mobilecommon.widget.calendar.day;
 
import android.graphics.Color;
 
import com.mm.android.deviceaddmodule.mobilecommon.widget.calendar.CalendarUtils;
 
import java.io.Serializable;
 
public class SelectedDays implements Serializable
{
    private static final long serialVersionUID = 3942549765282708376L;
    private CalendarDay mFirst;
    private CalendarDay mLast;
    private boolean mIsThisWeek;
    private boolean mIsLastWeek;
 
    public SelectedDays(CalendarDay first, CalendarDay last) {
        mFirst = first;
        mLast = last;
        generateVaule();
    }
 
    public SelectedDays(CalendarDay calendarDay) {
 
        this(CalendarUtils.getFixedMonday(calendarDay.getYear(), calendarDay.getMonth(), calendarDay.getDay()),
                CalendarUtils.getFixedSunday(calendarDay.getYear(), calendarDay.getMonth(), calendarDay.getDay()));
    }
 
    private void generateVaule() {
        mIsThisWeek = CalendarUtils.isThisWeek(mFirst);
        mIsLastWeek = CalendarUtils.isLastWeek(mLast);
        if(mIsThisWeek) {
            mFirst.setColor(Color.parseColor(SimpleMonthView.COLOR_SELECTED_BG_THIS));
            mLast.setColor(Color.parseColor(SimpleMonthView.COLOR_SELECTED_BG_THIS));
        } else if(mIsLastWeek) {
            mFirst.setColor(Color.parseColor(SimpleMonthView.COLOR_SELECTED_BG_LAST));
            mLast.setColor(Color.parseColor(SimpleMonthView.COLOR_SELECTED_BG_LAST));
        }
    }
 
    public boolean isThisWeek() {
        return mIsThisWeek;
    }
 
    public void setThisWeek(boolean thisWeek) {
        mIsThisWeek = thisWeek;
    }
 
    public boolean isLastWeek() {
        return mIsLastWeek;
    }
 
    public void setLastWeek(boolean lastWeek) {
        mIsLastWeek = lastWeek;
    }
 
    public CalendarDay getFirst()
    {
        return mFirst;
    }
 
    public void setFirst(CalendarDay first)
    {
        mFirst = first;
    }
 
    public CalendarDay getLast()
    {
        return mLast;
    }
 
    public void setLast(CalendarDay last)
    {
        mLast = last;
    }
 
    @Override
    public int hashCode() {
        int result = 17;
        result = 31 * result + mFirst.hashCode();
        result = 31 * result + mLast.hashCode();
        return result;
    }
 
    @Override
    public boolean equals(Object o) {
        if(o == this) return true;
        if(!(o instanceof SelectedDays)) {
            return false;
        }
        SelectedDays selectedDays = (SelectedDays)o;
        return selectedDays.getFirst().equals(mFirst)
                && selectedDays.getLast().equals(mLast);
    }
}