Java Code Examples for android.util.typedvalue#COMPLEX_UNIT_FRACTION_PARENT

The following examples show how to use android.util.typedvalue#COMPLEX_UNIT_FRACTION_PARENT . 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: Rotate3dAnimation.java    From pe-protector-moe with GNU General Public License v3.0 5 votes vote down vote up
Description parseValue(TypedValue value) {
    Description d = new Description();
    if (value == null) {
        d.type = ABSOLUTE;
        d.value = 0;
    } else {
        if (value.type == TypedValue.TYPE_FRACTION) {
            d.type = (value.data & TypedValue.COMPLEX_UNIT_MASK) ==
                    TypedValue.COMPLEX_UNIT_FRACTION_PARENT ?
                    RELATIVE_TO_PARENT : RELATIVE_TO_SELF;
            d.value = TypedValue.complexToFloat(value.data);
            return d;
        } else if (value.type == TypedValue.TYPE_FLOAT) {
            d.type = ABSOLUTE;
            d.value = value.getFloat();
            return d;
        } else if (value.type >= TypedValue.TYPE_FIRST_INT &&
                value.type <= TypedValue.TYPE_LAST_INT) {
            d.type = ABSOLUTE;
            d.value = value.data;
            return d;
        }
    }

    d.type = ABSOLUTE;
    d.value = 0.0f;

    return d;
}
 
Example 2
Source File: Animation.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/**
 * Size descriptions can appear inthree forms:
 * <ol>
 * <li>An absolute size. This is represented by a number.</li>
 * <li>A size relative to the size of the object being animated. This
 * is represented by a number followed by "%".</li> *
 * <li>A size relative to the size of the parent of object being
 * animated. This is represented by a number followed by "%p".</li>
 * </ol>
 * @param value The typed value to parse
 * @return The parsed version of the description
 */
static Description parseValue(TypedValue value) {
    Description d = new Description();
    if (value == null) {
        d.type = ABSOLUTE;
        d.value = 0;
    } else {
        if (value.type == TypedValue.TYPE_FRACTION) {
            d.type = (value.data & TypedValue.COMPLEX_UNIT_MASK) ==
                    TypedValue.COMPLEX_UNIT_FRACTION_PARENT ?
                            RELATIVE_TO_PARENT : RELATIVE_TO_SELF;
            d.value = TypedValue.complexToFloat(value.data);
            return d;
        } else if (value.type == TypedValue.TYPE_FLOAT) {
            d.type = ABSOLUTE;
            d.value = value.getFloat();
            return d;
        } else if (value.type >= TypedValue.TYPE_FIRST_INT &&
                value.type <= TypedValue.TYPE_LAST_INT) {
            d.type = ABSOLUTE;
            d.value = value.data;
            return d;
        }
    }

    d.type = ABSOLUTE;
    d.value = 0.0f;

    return d;
}
 
Example 3
Source File: Rotate3dAnimation.java    From KAlertDialog with Apache License 2.0 5 votes vote down vote up
private Description parseValue(TypedValue value) {
    Description d = new Description();
    if (value == null) {
        d.type = ABSOLUTE;
        d.value = 0;
    } else {
        if (value.type == TypedValue.TYPE_FRACTION) {
            d.type = (value.data & TypedValue.COMPLEX_UNIT_MASK) ==
                    TypedValue.COMPLEX_UNIT_FRACTION_PARENT ?
                    RELATIVE_TO_PARENT : RELATIVE_TO_SELF;
            d.value = TypedValue.complexToFloat(value.data);
            return d;
        } else if (value.type == TypedValue.TYPE_FLOAT) {
            d.type = ABSOLUTE;
            d.value = value.getFloat();
            return d;
        } else if (value.type >= TypedValue.TYPE_FIRST_INT &&
                value.type <= TypedValue.TYPE_LAST_INT) {
            d.type = ABSOLUTE;
            d.value = value.data;
            return d;
        }
    }

    d.type = ABSOLUTE;
    d.value = 0.0f;

    return d;
}
 
Example 4
Source File: Rotate3dAnimation.java    From HaiNaBaiChuan with Apache License 2.0 5 votes vote down vote up
Description parseValue(TypedValue value) {
    Description d = new Description();
    if (value == null) {
        d.type = ABSOLUTE;
        d.value = 0;
    } else {
        if (value.type == TypedValue.TYPE_FRACTION) {
            d.type = (value.data & TypedValue.COMPLEX_UNIT_MASK) ==
                    TypedValue.COMPLEX_UNIT_FRACTION_PARENT ?
                    RELATIVE_TO_PARENT : RELATIVE_TO_SELF;
            d.value = TypedValue.complexToFloat(value.data);
            return d;
        } else if (value.type == TypedValue.TYPE_FLOAT) {
            d.type = ABSOLUTE;
            d.value = value.getFloat();
            return d;
        } else if (value.type >= TypedValue.TYPE_FIRST_INT &&
                value.type <= TypedValue.TYPE_LAST_INT) {
            d.type = ABSOLUTE;
            d.value = value.data;
            return d;
        }
    }

    d.type = ABSOLUTE;
    d.value = 0.0f;

    return d;
}