Debian Codegraph @

layoutlib-api/src/main/java/com/android/resources/Navigation.java

raw
1 /*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package com.android.resources;
18
19 /**
20 * Navigation enum.
21 * <p>This is used in the manifest in the uses-configuration node and in the resource folder names.
22 */
23 public enum Navigation implements ResourceEnum {
24 NONAV("nonav", "None", "No navigation"), //$NON-NLS-1$
25 DPAD("dpad", "D-pad", "D-pad navigation"), //$NON-NLS-1$
26 TRACKBALL("trackball", "Trackball", "Trackball navigation"), //$NON-NLS-1$
27 WHEEL("wheel", "Wheel", "Wheel navigation"); //$NON-NLS-1$
28
29 private final String mValue;
30 private final String mShortDisplayValue;
31 private final String mLongDisplayValue;
32
33 Navigation(String value, String shortDisplayValue, String longDisplayValue) {
34 mValue = value;
35 mShortDisplayValue = shortDisplayValue;
36 mLongDisplayValue = longDisplayValue;
37 }
38
39 /**
40 * Returns the enum for matching the provided qualifier value.
41 * @param value The qualifier value.
42 * @return the enum for the qualifier value or null if no matching was found.
43 */
44 public static Navigation getEnum(String value) {
45 for (Navigation nav : values()) {
46 if (nav.mValue.equals(value)) {
47 return nav;
48 }
49 }
50
51 return null;
52 }
53
54 @Override
55 public String getResourceValue() {
56 return mValue;
57 }
58
59 @Override
60 public String getShortDisplayValue() {
61 return mShortDisplayValue;
62 }
63
64 @Override
65 public String getLongDisplayValue() {
66 return mLongDisplayValue;
67 }
68
69 public static int getIndex(Navigation value) {
70 return value == null ? -1 : value.ordinal();
71 }
72
73 public static Navigation getByIndex(int index) {
74 Navigation[] values = values();
75 if (index >= 0 && index < values.length) {
76 return values[index];
77 }
78 return null;
79 }
80
81 @Override
82 public boolean isFakeValue() {
83 return false;
84 }
85
86 @Override
87 public boolean isValidValueForDevice() {
88 return true;
89 }
90
91 }