]> git.ktnx.net Git - mobile-ledger.git/blob - app/src/main/java/net/ktnx/mobileledger/model/FutureDates.java
more pronounced day/month delimiters in the transaction list
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / model / FutureDates.java
1 /*
2  * Copyright © 2021 Damyan Ivanov.
3  * This file is part of MoLe.
4  * MoLe is free software: you can distribute it and/or modify it
5  * under the term of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your opinion), any later version.
8  *
9  * MoLe is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License terms for details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with MoLe. If not, see <https://www.gnu.org/licenses/>.
16  */
17
18 package net.ktnx.mobileledger.model;
19
20 import android.content.res.Resources;
21 import android.util.SparseArray;
22
23 import net.ktnx.mobileledger.R;
24
25 public enum FutureDates {
26     None(0), OneWeek(7), TwoWeeks(14), OneMonth(30), TwoMonths(60), ThreeMonths(90),
27     SixMonths(180), OneYear(365), All(-1);
28     private static final SparseArray<FutureDates> map = new SparseArray<>();
29
30     static {
31         for (FutureDates item : FutureDates.values()) {
32             map.put(item.value, item);
33         }
34     }
35
36     private final int value;
37     FutureDates(int value) {
38         this.value = value;
39     }
40     public static FutureDates valueOf(int i) {
41         return map.get(i, None);
42     }
43     public int toInt() {
44         return this.value;
45     }
46     public String getText(Resources resources) {
47         switch (value) {
48             case 7:
49                 return resources.getString(R.string.future_dates_7);
50             case 14:
51                 return resources.getString(R.string.future_dates_14);
52             case 30:
53                 return resources.getString(R.string.future_dates_30);
54             case 60:
55                 return resources.getString(R.string.future_dates_60);
56             case 90:
57                 return resources.getString(R.string.future_dates_90);
58             case 180:
59                 return resources.getString(R.string.future_dates_180);
60             case 365:
61                 return resources.getString(R.string.future_dates_365);
62             case -1:
63                 return resources.getString(R.string.future_dates_all);
64             default:
65                 return resources.getString(R.string.future_dates_none);
66         }
67     }
68 }