Java Code Examples for android.util.StateSet#trimStateSet()

The following examples show how to use android.util.StateSet#trimStateSet() . 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: DrawableUtils.java    From timecat with Apache License 2.0 6 votes vote down vote up
/**
 * Extracts state_ attributes from an attribute set.
 *
 * @param attrs The attribute set.
 *
 * @return An array of state_ attributes.
 */
static int[] extractStateSet(AttributeSet attrs) {
    int j = 0;
    final int numAttrs = attrs.getAttributeCount();
    int[] states = new int[numAttrs];
    for (int i = 0; i < numAttrs; i++) {
        final int stateResId = attrs.getAttributeNameResource(i);
        if (stateResId == 0) {
            break;
        } else if (stateResId == android.R.attr.drawable || stateResId == android.R.attr.id || stateResId == R.attr.drawableTint || stateResId == R.attr.drawableTintMode) {
            // Ignore attributes from StateListDrawableItem and
            // AnimatedStateListDrawableItem.
            continue;
        } else {
            states[j++] = attrs.getAttributeBooleanValue(i, false) ? stateResId : -stateResId;
        }
    }
    states = StateSet.trimStateSet(states, j);
    return states;
}
 
Example 2
Source File: ColorStateListUtils.java    From timecat with Apache License 2.0 6 votes vote down vote up
protected static int[] extractStateSet(AttributeSet attrs) {
    int j = 0;
    final int numAttrs = attrs.getAttributeCount();
    int[] states = new int[numAttrs];
    for (int i = 0; i < numAttrs; i++) {
        final int stateResId = attrs.getAttributeNameResource(i);
        switch (stateResId) {
            case 0:
                break;
            case android.R.attr.color:
            case android.R.attr.alpha:
                // Ignore attributes from StateListDrawableItem and
                // AnimatedStateListDrawableItem.
                continue;
            default:
                states[j++] = attrs.getAttributeBooleanValue(i, false) ? stateResId : -stateResId;
        }
    }
    states = StateSet.trimStateSet(states, j);
    return states;
}
 
Example 3
Source File: DrawableUtils.java    From MagicaSakura with Apache License 2.0 6 votes vote down vote up
/**
 * Extracts state_ attributes from an attribute set.
 *
 * @param attrs The attribute set.
 * @return An array of state_ attributes.
 */
static int[] extractStateSet(AttributeSet attrs) {
    int j = 0;
    final int numAttrs = attrs.getAttributeCount();
    int[] states = new int[numAttrs];
    for (int i = 0; i < numAttrs; i++) {
        final int stateResId = attrs.getAttributeNameResource(i);
        if (stateResId == 0) {
            break;
        } else if (stateResId == android.R.attr.drawable
                || stateResId == android.R.attr.id
                || stateResId == R.attr.drawableTint
                || stateResId == R.attr.drawableTintMode) {
            // Ignore attributes from StateListDrawableItem and
            // AnimatedStateListDrawableItem.
            continue;
        } else {
            states[j++] = attrs.getAttributeBooleanValue(i, false)
                    ? stateResId : -stateResId;
        }
    }
    states = StateSet.trimStateSet(states, j);
    return states;
}
 
Example 4
Source File: ColorStateListUtils.java    From MagicaSakura with Apache License 2.0 6 votes vote down vote up
protected static int[] extractStateSet(AttributeSet attrs) {
    int j = 0;
    final int numAttrs = attrs.getAttributeCount();
    int[] states = new int[numAttrs];
    for (int i = 0; i < numAttrs; i++) {
        final int stateResId = attrs.getAttributeNameResource(i);
        switch (stateResId) {
            case 0:
                break;
            case android.R.attr.color:
            case android.R.attr.alpha:
                // Ignore attributes from StateListDrawableItem and
                // AnimatedStateListDrawableItem.
                continue;
            default:
                states[j++] = attrs.getAttributeBooleanValue(i, false)
                        ? stateResId : -stateResId;
        }
    }
    states = StateSet.trimStateSet(states, j);
    return states;
}