public static int getIndex(NavigationState value) { return value == null ? -1 : value.ordinal(); }
public static NavigationState getByIndex(int index) { NavigationState[] values = values(); if (index >= 0 && index < values.length) { return values[index]; } return null; }
private static Element generateStateNode(State s, Document doc, Hardware defaultHardware) { Element state = doc.createElement(PREFIX + DeviceSchema.NODE_STATE); state.setAttribute(DeviceSchema.ATTR_NAME, s.getName()); if (s.isDefaultState()) { state.setAttribute(DeviceSchema.ATTR_DEFAULT, Boolean.toString(s.isDefaultState())); } addElement(doc, state, DeviceSchema.NODE_DESCRIPTION, s.getDescription()); addElement(doc, state, DeviceSchema.NODE_SCREEN_ORIENTATION, s.getOrientation().getResourceValue()); addElement(doc, state, DeviceSchema.NODE_KEYBOARD_STATE, s.getKeyState().getResourceValue()); addElement(doc, state, DeviceSchema.NODE_NAV_STATE, s.getNavState().getResourceValue()); // Only if the hardware is different do we want to append hardware values if (!s.getHardware().equals(defaultHardware)) { // TODO: Only append nodes which are different from the default hardware Element hardware = generateHardwareNode(s.getHardware(), doc); NodeList children = hardware.getChildNodes(); for (int i = 0 ; i < children.getLength(); i++) { Node child = children.item(i); state.appendChild(child); } } return state; }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (!(o instanceof State)) { return false; } State s = (State) o; return mDefaultState == s.isDefaultState() && mName.equals(s.getName()) && mDescription.equals(s.getDescription()) && mOrientation.equals(s.getOrientation()) && mKeyState.equals(s.getKeyState()) && mNavState.equals(s.getNavState()) && mHardwareOverride.equals(s.getHardware()); }
mState.setNavState(NavigationState.HIDDEN); } else { mState.setNavState(NavigationState.getEnum(getString(mStringAccumulator)));
public static int getIndex(NavigationState value) { int i = 0; for (NavigationState input : values()) { if (value == input) { return i; } i++; } return -1; }
@Override public int hashCode() { int hash = 17; hash = 31 * hash + (mDefaultState ? 1 : 0); if (mName != null) { hash = 31 * hash + mName.hashCode(); } if (mDescription != null) { hash = 31 * hash + mDescription.hashCode(); } hash = 31 * hash + mOrientation.ordinal(); hash = 31 * hash + mKeyState.ordinal(); hash = 31 * hash + mNavState.ordinal(); hash = 31 * hash + mHardwareOverride.hashCode(); return hash; }
public static NavigationState getByIndex(int index) { int i = 0; for (NavigationState value : values()) { if (i == index) { return value; } i++; } return null; }
/** * Returns the enum for matching the provided qualifier value. * @param value The qualifier value. * @return the enum for the qualifier value or null if no matching was found. */ public static NavigationState getEnum(String value) { for (NavigationState state : values()) { if (state.mValue.equals(value)) { return state; } } return null; }
/** * Returns the enum for matching the provided qualifier value. * @param value The qualifier value. * @return the enum for the qualifier value or null if no matching was found. */ public static NavigationState getEnum(String value) { for (NavigationState state : values()) { if (state.mValue.equals(value)) { return state; } } return null; }