- else date.setText(String.format(Locale.US, "%d/%d/%d", year, month + 1, day));
-
- TextView description = Objects.requireNonNull(getActivity())
- .findViewById(R.id.new_transaction_description);
- description.requestFocus();
- }
-
- @Override
- public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
- TextView date =
- Objects.requireNonNull(getActivity()).findViewById(R.id.new_transaction_date);
-
- final Calendar c = GregorianCalendar.getInstance();
- if (c.get(GregorianCalendar.YEAR) == year) {
- if (c.get(GregorianCalendar.MONTH) == monthOfYear) {
- date.setText(String.format(Locale.US, "%d", dayOfMonth));
- }
- else {
- date.setText(String.format(Locale.US, "%d/%d", monthOfYear + 1, dayOfMonth));
+ 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;