2 * Copyright © 2020 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.
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.
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/>.
18 package net.ktnx.mobileledger.json;
20 import android.content.res.Resources;
21 import android.util.SparseArray;
23 import net.ktnx.mobileledger.R;
26 auto(0), html(-1), v1_14(-2), v1_15(-3), v1_19_1(-4);
27 private static final SparseArray<API> map = new SparseArray<>();
28 public static API[] allVersions = {v1_19_1, v1_15, v1_14};
31 for (API item : API.values()) {
32 map.put(item.value, item);
36 private final int value;
41 public static API valueOf(int i) {
42 return map.get(i, auto);
47 public String getDescription(Resources resources) {
50 return resources.getString(R.string.api_auto);
52 return resources.getString(R.string.api_html);
54 return resources.getString(R.string.api_1_14);
56 return resources.getString(R.string.api_1_15);
58 return resources.getString(R.string.api_1_19_1);
60 throw new IllegalStateException("Unexpected value: " + value);
63 public String getDescription() {
76 throw new IllegalStateException("Unexpected value: " + this);