Java Code Examples for com.android.internal.util.XmlUtils#convertValueToInt()
The following examples show how to use
com.android.internal.util.XmlUtils#convertValueToInt() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TypedArray.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * Retrieve the integer value for the attribute at <var>index</var>. * <p> * If the attribute is not an integer, this method will attempt to coerce * it to an integer using {@link Integer#decode(String)}. * * @param index Index of attribute to retrieve. * @param defValue Value to return if the attribute is not defined or * cannot be coerced to an integer. * * @return Integer value of the attribute, or defValue if the attribute was * not defined or could not be coerced to an integer. * @throws RuntimeException if the TypedArray has already been recycled. */ public int getInt(@StyleableRes int index, int defValue) { if (mRecycled) { throw new RuntimeException("Cannot make calls to a recycled instance!"); } index *= STYLE_NUM_ENTRIES; final int[] data = mData; final int type = data[index + STYLE_TYPE]; if (type == TypedValue.TYPE_NULL) { return defValue; } else if (type >= TypedValue.TYPE_FIRST_INT && type <= TypedValue.TYPE_LAST_INT) { return data[index + STYLE_DATA]; } final TypedValue v = mValue; if (getValueAt(index, v)) { StrictMode.noteResourceMismatch(v); return XmlUtils.convertValueToInt(v.coerceToString(), defValue); } // We already checked for TYPE_NULL. This should never happen. throw new RuntimeException("getInt of bad type: 0x" + Integer.toHexString(type)); }
Example 2
Source File: XmlPullAttributes.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
public int getAttributeResourceValue(String namespace, String attribute, int defaultValue) { return XmlUtils.convertValueToInt( getAttributeValue(namespace, attribute), defaultValue); }
Example 3
Source File: XmlPullAttributes.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
public int getAttributeIntValue(String namespace, String attribute, int defaultValue) { return XmlUtils.convertValueToInt( getAttributeValue(namespace, attribute), defaultValue); }
Example 4
Source File: XmlPullAttributes.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
public int getAttributeResourceValue(int index, int defaultValue) { return XmlUtils.convertValueToInt( getAttributeValue(index), defaultValue); }
Example 5
Source File: XmlPullAttributes.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
public int getAttributeIntValue(int index, int defaultValue) { return XmlUtils.convertValueToInt( getAttributeValue(index), defaultValue); }