Java Code Examples for com.android.internal.util.XmlUtils#convertValueToBoolean()
The following examples show how to use
com.android.internal.util.XmlUtils#convertValueToBoolean() .
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 boolean value for the attribute at <var>index</var>. * <p> * If the attribute is an integer value, this method will return whether * it is equal to zero. If the attribute is not a boolean or integer value, * this method will attempt to coerce it to an integer using * {@link Integer#decode(String)} and return whether it is equal to zero. * * @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 Boolean 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 boolean getBoolean(@StyleableRes int index, boolean 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] != 0; } final TypedValue v = mValue; if (getValueAt(index, v)) { StrictMode.noteResourceMismatch(v); return XmlUtils.convertValueToBoolean(v.coerceToString(), defValue); } // We already checked for TYPE_NULL. This should never happen. throw new RuntimeException("getBoolean 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 boolean getAttributeBooleanValue(String namespace, String attribute, boolean defaultValue) { return XmlUtils.convertValueToBoolean( getAttributeValue(namespace, attribute), defaultValue); }
Example 3
Source File: XmlPullAttributes.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
public boolean getAttributeBooleanValue(int index, boolean defaultValue) { return XmlUtils.convertValueToBoolean( getAttributeValue(index), defaultValue); }