From 11d07b02149e4f3d157afa5421e7ade26c921269 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Thu, 20 Feb 2020 18:01:26 +0200 Subject: [PATCH] fix limitting of future dates entry to measure from today, not from the currently selected date --- .../ktnx/mobileledger/ui/DatePickerFragment.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) 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); -- 2.39.5