Commit 5fb48d82 by fengquan

fix: 修复设置生日页面的年份可以选择当前日期之后的时间

parent 4d0229af
......@@ -67,9 +67,21 @@ public class DatePickerDialogFragment extends BaseDialogFragment implements Date
@Override
public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
this.year = year;
this.month = monthOfYear;
this.day = dayOfMonth;
if (isDataAfter(view)) {
Calendar mCalendar = Calendar.getInstance();
view.init(mCalendar.get(Calendar.YEAR), mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH), this);
}
}
private boolean isDataAfter(DatePicker datePicker) {
Calendar mCalendar = Calendar.getInstance();
Calendar tempCalendar = Calendar.getInstance();
tempCalendar.set(datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth(), 0, 0, 0);
if (tempCalendar.after(mCalendar)) {
return true;
} else {
return false;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment