]> git.ktnx.net Git - mobile-ledger.git/commitdiff
fix limitting of future dates entry to measure from today, not from the currently...
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Thu, 20 Feb 2020 16:01:26 +0000 (18:01 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Thu, 20 Feb 2020 16:01:26 +0000 (18:01 +0200)
app/src/main/java/net/ktnx/mobileledger/ui/DatePickerFragment.java

index b300ea6ce4e75b364b8c7bdf526900cb5c7ac4d9..cd69f7d83d7bfa2871965b95f5e7dc30202d7f3c 100644 (file)
@@ -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);