We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
首先十分感谢作者的控件!!!
之前使用一切正常,升级到了安卓14之后发现系统时间返回有了变化,控件内的判断存在边界错误,具体表现为:高亮日期是当前日期的后一天。
经过初步排查,问题出在OnDateBuildAapter的onHighLight函数内。
OnDateBuildAapter
onHighLight
//获取周几,1->7 Calendar now = Calendar.getInstance(); //一周第一天是否为星期天 boolean isFirstSunday = (now.getFirstDayOfWeek() == Calendar.SUNDAY); int weekDay = now.get(Calendar.DAY_OF_WEEK); //若一周第一天为星期天,则-1 if (isFirstSunday) { weekDay = weekDay - 1; if (weekDay == 0) { weekDay = 7; } }
代码中,安卓13及以前, Calendar.getInstance().getFirstDayOfWeek()返回为1,逻辑正常,但是安卓14会返回2,但是代码会按返回值为0进行处理,从而导致计算结果比预期值+1。
Calendar.getInstance().getFirstDayOfWeek()
// 安卓14的情况如下: Calendar now = Calendar.getInstance(); //一周第一天是否为星期天 int firstDayOfWeek = now.getFirstDayOfWeek(); // 2 int sunday = Calendar.SUNDAY; // 1 boolean isFirstSunday = (now.getFirstDayOfWeek() == Calendar.SUNDAY); // false
所以需要将下方的计算函数改为:
if (isFirstSunday) { weekDay = weekDay - firstDayOfWeek ; if (weekDay == 0) { weekDay = 7; } }
希望作者尽快更新仓库代码,感谢!!!
The text was updated successfully, but these errors were encountered:
No branches or pull requests
首先十分感谢作者的控件!!!
之前使用一切正常,升级到了安卓14之后发现系统时间返回有了变化,控件内的判断存在边界错误,具体表现为:高亮日期是当前日期的后一天。
经过初步排查,问题出在
OnDateBuildAapter
的onHighLight
函数内。代码中,安卓13及以前,
Calendar.getInstance().getFirstDayOfWeek()
返回为1,逻辑正常,但是安卓14会返回2,但是代码会按返回值为0进行处理,从而导致计算结果比预期值+1。所以需要将下方的计算函数改为:
希望作者尽快更新仓库代码,感谢!!!
The text was updated successfully, but these errors were encountered: