From: Damyan Ivanov Date: Thu, 20 Feb 2020 16:01:26 +0000 (+0200) Subject: fix limitting of future dates entry to measure from today, not from the currently... X-Git-Tag: v0.12.0~89 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=11d07b02149e4f3d157afa5421e7ade26c921269;p=mobile-ledger.git fix limitting of future dates entry to measure from today, not from the currently selected date --- diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/DatePickerFragment.java b/app/src/main/java/net/ktnx/mobileledger/ui/DatePickerFragment.java index b300ea6c..cd69f7d8 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/DatePickerFragment.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/DatePickerFragment.java @@ -92,28 +92,29 @@ public class DatePickerFragment extends AppCompatDialogFragment cv.setMaxDate(Long.MAX_VALUE); } else { + final Calendar dateLimit = GregorianCalendar.getInstance(); switch (futureDates) { case None: // already there break; case OneMonth: - c.add(Calendar.MONTH, 1); + dateLimit.add(Calendar.MONTH, 1); break; case TwoMonths: - c.add(Calendar.MONTH, 2); + dateLimit.add(Calendar.MONTH, 2); break; case ThreeMonths: - c.add(Calendar.MONTH, 3); + dateLimit.add(Calendar.MONTH, 3); break; case SixMonths: - c.add(Calendar.MONTH, 6); + dateLimit.add(Calendar.MONTH, 6); break; case OneYear: - c.add(Calendar.YEAR, 1); + dateLimit.add(Calendar.YEAR, 1); break; } - cv.setMaxDate(c.getTime() - .getTime()); + cv.setMaxDate(dateLimit.getTime() + .getTime()); } cv.setOnDateChangeListener(this);