-implements DatePickerDialog.OnDateSetListener, DatePicker.OnDateChangedListener
-{
- @NonNull
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- final Calendar c = GregorianCalendar.getInstance();
- int year = c.get(GregorianCalendar.YEAR);
- int month = c.get(GregorianCalendar.MONTH);
- int day = c.get(GregorianCalendar.DAY_OF_MONTH);
- TextView date = Objects.requireNonNull(getActivity()).findViewById(R.id.new_transaction_date);
-
- CharSequence present = date.getText();
-
- Pattern re_mon_day = Pattern.compile("^\\s*(\\d+)\\s*/\\s*(\\d+)\\s*$");
- Matcher m_mon_day = re_mon_day.matcher(present);
-
- if (m_mon_day.matches()) {
- month = Integer.parseInt(m_mon_day.group(1))-1;
- day = Integer.parseInt(m_mon_day.group(2));
+ implements CalendarView.OnDateChangeListener {
+ static final Pattern reYMD = Pattern.compile("^\\s*(\\d+)\\d*/\\s*(\\d+)\\s*/\\s*(\\d+)\\s*$");
+ static final Pattern reMD = Pattern.compile("^\\s*(\\d+)\\s*/\\s*(\\d+)\\s*$");
+ static final Pattern reD = Pattern.compile("\\s*(\\d+)\\s*$");
+ private final Calendar presentDate = GregorianCalendar.getInstance();
+ private DatePickedListener onDatePickedListener;
+ private long minDate = 0;
+ private long maxDate = Long.MAX_VALUE;
+ public void setDateRange(@Nullable SimpleDate minDate, @Nullable SimpleDate maxDate) {
+ if (minDate == null)
+ this.minDate = 0;
+ else
+ this.minDate = minDate.toDate().getTime();
+
+ if (maxDate == null)
+ this.maxDate = Long.MAX_VALUE;
+ else
+ this.maxDate = maxDate.toDate().getTime();
+ }
+ public void setFutureDates(FutureDates futureDates) {
+ if (futureDates == FutureDates.All) {
+ maxDate = Long.MAX_VALUE;