- @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();
+ 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(MobileLedgerProfile.FutureDates futureDates) {
+ if (futureDates == MobileLedgerProfile.FutureDates.All) {
+ maxDate = Long.MAX_VALUE;
+ }
+ else {
+ final Calendar dateLimit = GregorianCalendar.getInstance();
+ switch (futureDates) {
+ case None:
+ // already there
+ break;
+ case OneWeek:
+ dateLimit.add(Calendar.DAY_OF_MONTH, 7);
+ break;
+ case TwoWeeks:
+ dateLimit.add(Calendar.DAY_OF_MONTH, 14);
+ break;
+ case OneMonth:
+ dateLimit.add(Calendar.MONTH, 1);
+ break;
+ case TwoMonths:
+ dateLimit.add(Calendar.MONTH, 2);
+ break;
+ case ThreeMonths:
+ dateLimit.add(Calendar.MONTH, 3);
+ break;
+ case SixMonths:
+ dateLimit.add(Calendar.MONTH, 6);
+ break;
+ case OneYear:
+ dateLimit.add(Calendar.YEAR, 1);
+ break;
+ }
+ maxDate = dateLimit.getTime()
+ .getTime();
+ }
+ }
+ public void setCurrentDateFromText(CharSequence present) {
+ final Calendar now = GregorianCalendar.getInstance();
+ int year = now.get(GregorianCalendar.YEAR);
+ int month = now.get(GregorianCalendar.MONTH);
+ int day = now.get(GregorianCalendar.DAY_OF_MONTH);