Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change color of weak start day and weak end days #61

Open
SaNu-hIT opened this issue Apr 7, 2017 · 1 comment
Open

Change color of weak start day and weak end days #61

SaNu-hIT opened this issue Apr 7, 2017 · 1 comment

Comments

@SaNu-hIT
Copy link

SaNu-hIT commented Apr 7, 2017

How to change the color of weak end days and weak start days. by default it is red I want to change it as black . how to do this ??

@pateelhs
Copy link

# Modify this class to display Start day as Sunday

public abstract class DPCalendar {
protected final Calendar c = Calendar.getInstance();

/**
 * 获取某年某月的节日数组
 * <p/>
 * Build the festival date array of given year and month
 *
 * @param year  某年
 * @param month 某月
 * @return 该月节日数组
 */
public abstract String[][] buildMonthFestival(int year, int month);

/**
 * 获取某年某月的假期数组
 * <p/>
 * Build the holiday date array of given year and month
 *
 * @param year  某年
 * @param month 某月
 * @return 该月假期数组
 */
public abstract Set<String> buildMonthHoliday(int year, int month);

/**
 * 判断某年是否为闰年
 *
 * @param year ...
 * @return true表示闰年
 */
public boolean isLeapYear(int year) {
    return (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0));
}

/**
 * 判断给定日期是否为今天
 *
 * @param year  某年
 * @param month 某月
 * @param day   某天
 * @return ...
 */
public boolean isToday(int year, int month, int day) {
    Calendar c1 = Calendar.getInstance();
    Calendar c2 = Calendar.getInstance();
    c1.set(year, month - 1, day);
    return (c1.get(Calendar.YEAR) == c2.get(Calendar.YEAR)) &&
            (c1.get(Calendar.MONTH) == (c2.get(Calendar.MONTH))) &&
            (c1.get(Calendar.DAY_OF_MONTH) == c2.get(Calendar.DAY_OF_MONTH));
}

/**
 * 生成某年某月的公历天数数组
 * 数组为6x7的二维数组因为一个月的周数永远不会超过六周
 * 天数填充对应相应的二维数组下标
 * 如果某个数组下标中没有对应天数那么则填充一个空字符串
 *
 * @param year  某年
 * @param month 某月
 * @return 某年某月的公历天数数组
 */
public String[][] buildMonthG(int year, int month) {
    c.clear();
    String tmp[][] = new String[6][7];
    c.set(year, month - 1, 1);

    int daysInMonth = 0;
    if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 ||
            month == 12) {
        daysInMonth = 31;
    } else if (month == 4 || month == 6 || month == 9 || month == 11) {
        daysInMonth = 30;
    } else if (month == 2) {
        if (isLeapYear(year)) {
            daysInMonth = 29;
        } else {
            daysInMonth = 28;
        }
    }
    int dayOfWeek= c.get(Calendar.DAY_OF_WEEK) - Calendar.SUNDAY;
    int day = 1;

// if(c.DAY_OF_YEAR==2017 && c.MONTH==1 ||c.DAY_OF_YEAR==2017&& c.MONTH==10)
// {
// dayOfWeek=c.get(Calendar.DAY_OF_WEEK) - Calendar.SUNDAY;
// }
// else{
// dayOfWeek = c.get(Calendar.DAY_OF_WEEK) - Calendar.MONDAY;
// }
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 7; j++) {
tmp[i][j] = "";
if (i == 0 && j >= dayOfWeek) {
tmp[i][j] = "" + day;
day++;
} else if (i > 0 && day <= daysInMonth) {
tmp[i][j] = "" + day;
day++;
}
}
}
return tmp;
}

/**
 * 生成某年某月的周末日期集合
 *
 * @param year  某年
 * @param month 某月
 * @return 某年某月的周末日期集合
 */
public Set<String> buildMonthWeekend(int year, int month) {
    Set<String> set = new HashSet<>();
    c.clear();
    c.set(year, month - 1, 1);
    do {
        int day = c.get(Calendar.DAY_OF_WEEK);
        if (day == Calendar.SATURDAY || day == Calendar.SUNDAY) {
            set.add(String.valueOf(c.get(Calendar.DAY_OF_MONTH)));
        }
        c.add(Calendar.DAY_OF_YEAR, 1);
    } while (c.get(Calendar.MONTH) == month - 1);
    return set;
}

protected long GToNum(int year, int month, int day) {
    month = (month + 9) % 12;
    year = year - month / 10;
    return 365 * year + year / 4 - year / 100 + year / 400 + (month * 306 + 5) / 10 + (day - 1);
}

protected int getBitInt(int data, int length, int shift) {
    return (data & (((1 << length) - 1) << shift)) >> shift;
}

}

# Here you can change the week start and weekend day color
public class DPBaseTheme extends DPTheme {
@OverRide
public int colorBG() {
return 0xFFFFFFFF;
}

@Override
public int colorBGCircle() {
    return 0x44000000;
}

@Override
public int colorTitleBG() {
    return 0xFFF37B7A;
}

@Override
public int colorTitle() {
    return 0xEEFFFFFF;
}

@Override
public int colorToday() {
    return 0x88F37B7A;
}

@Override
public int colorG() {
    return 0xEE333333;
}

@Override
public int colorF() {
    return 0xEEC08AA4;
}

@OverRide

public int colorWeekend() {
    return 0xEEF78082;
}

@Override
public int colorHoliday() {
    return 0x80FED6D6;
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants