- public enum API {
- auto(0), html(-1), pre_1_15(-2), post_1_14(-3);
- private static SparseArray<API> map = new SparseArray<>();
-
- static {
- for (API item : API.values()) {
- map.put(item.value, item);
- }
- }
-
- private int value;
-
- API(int value) {
- this.value = value;
- }
- public static API valueOf(int i) {
- return map.get(i, auto);
- }
- public int toInt() {
- return this.value;
- }
- public String getDescription(Resources resources) {
- switch (this) {
- case auto:
- return resources.getString(R.string.api_auto);
- case html:
- return resources.getString(R.string.api_html);
- case pre_1_15:
- return resources.getString(R.string.api_pre_1_15);
- case post_1_14:
- return resources.getString(R.string.api_post_1_14);
- default:
- throw new IllegalStateException("Unexpected value: " + value);
- }
- }
- }
-}