Search in sources :

Example 1 with Property

use of android.util.Property in project android_frameworks_base by ResurrectionRemix.

the class AnimatedVectorDrawable method updateAnimatorProperty.

private static void updateAnimatorProperty(Animator animator, String targetName, VectorDrawable vectorDrawable, boolean ignoreInvalidAnim) {
    if (animator instanceof ObjectAnimator) {
        // Change the property of the Animator from using reflection based on the property
        // name to a Property object that wraps the setter and getter for modifying that
        // specific property for a given object. By replacing the reflection with a direct call,
        // we can largely reduce the time it takes for a animator to modify a VD property.
        PropertyValuesHolder[] holders = ((ObjectAnimator) animator).getValues();
        for (int i = 0; i < holders.length; i++) {
            PropertyValuesHolder pvh = holders[i];
            String propertyName = pvh.getPropertyName();
            Object targetNameObj = vectorDrawable.getTargetByName(targetName);
            Property property = null;
            if (targetNameObj instanceof VectorDrawable.VObject) {
                property = ((VectorDrawable.VObject) targetNameObj).getProperty(propertyName);
            } else if (targetNameObj instanceof VectorDrawable.VectorDrawableState) {
                property = ((VectorDrawable.VectorDrawableState) targetNameObj).getProperty(propertyName);
            }
            if (property != null) {
                if (containsSameValueType(pvh, property)) {
                    pvh.setProperty(property);
                } else if (!ignoreInvalidAnim) {
                    throw new RuntimeException("Wrong valueType for Property: " + propertyName + ".  Expected type: " + property.getType().toString() + ". Actual " + "type defined in resources: " + pvh.getValueType().toString());
                }
            }
        }
    } else if (animator instanceof AnimatorSet) {
        for (Animator anim : ((AnimatorSet) animator).getChildAnimations()) {
            updateAnimatorProperty(anim, targetName, vectorDrawable, ignoreInvalidAnim);
        }
    }
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) PropertyValuesHolder(android.animation.PropertyValuesHolder) Property(android.util.Property)

Example 2 with Property

use of android.util.Property in project android_frameworks_base by DirtyUnicorns.

the class AnimatedVectorDrawable method updateAnimatorProperty.

private static void updateAnimatorProperty(Animator animator, String targetName, VectorDrawable vectorDrawable, boolean ignoreInvalidAnim) {
    if (animator instanceof ObjectAnimator) {
        // Change the property of the Animator from using reflection based on the property
        // name to a Property object that wraps the setter and getter for modifying that
        // specific property for a given object. By replacing the reflection with a direct call,
        // we can largely reduce the time it takes for a animator to modify a VD property.
        PropertyValuesHolder[] holders = ((ObjectAnimator) animator).getValues();
        for (int i = 0; i < holders.length; i++) {
            PropertyValuesHolder pvh = holders[i];
            String propertyName = pvh.getPropertyName();
            Object targetNameObj = vectorDrawable.getTargetByName(targetName);
            Property property = null;
            if (targetNameObj instanceof VectorDrawable.VObject) {
                property = ((VectorDrawable.VObject) targetNameObj).getProperty(propertyName);
            } else if (targetNameObj instanceof VectorDrawable.VectorDrawableState) {
                property = ((VectorDrawable.VectorDrawableState) targetNameObj).getProperty(propertyName);
            }
            if (property != null) {
                if (containsSameValueType(pvh, property)) {
                    pvh.setProperty(property);
                } else if (!ignoreInvalidAnim) {
                    throw new RuntimeException("Wrong valueType for Property: " + propertyName + ".  Expected type: " + property.getType().toString() + ". Actual " + "type defined in resources: " + pvh.getValueType().toString());
                }
            }
        }
    } else if (animator instanceof AnimatorSet) {
        for (Animator anim : ((AnimatorSet) animator).getChildAnimations()) {
            updateAnimatorProperty(anim, targetName, vectorDrawable, ignoreInvalidAnim);
        }
    }
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) PropertyValuesHolder(android.animation.PropertyValuesHolder) Property(android.util.Property)

Example 3 with Property

use of android.util.Property in project android_frameworks_base by AOSPA.

the class AnimatedVectorDrawable method updateAnimatorProperty.

private static void updateAnimatorProperty(Animator animator, String targetName, VectorDrawable vectorDrawable, boolean ignoreInvalidAnim) {
    if (animator instanceof ObjectAnimator) {
        // Change the property of the Animator from using reflection based on the property
        // name to a Property object that wraps the setter and getter for modifying that
        // specific property for a given object. By replacing the reflection with a direct call,
        // we can largely reduce the time it takes for a animator to modify a VD property.
        PropertyValuesHolder[] holders = ((ObjectAnimator) animator).getValues();
        for (int i = 0; i < holders.length; i++) {
            PropertyValuesHolder pvh = holders[i];
            String propertyName = pvh.getPropertyName();
            Object targetNameObj = vectorDrawable.getTargetByName(targetName);
            Property property = null;
            if (targetNameObj instanceof VectorDrawable.VObject) {
                property = ((VectorDrawable.VObject) targetNameObj).getProperty(propertyName);
            } else if (targetNameObj instanceof VectorDrawable.VectorDrawableState) {
                property = ((VectorDrawable.VectorDrawableState) targetNameObj).getProperty(propertyName);
            }
            if (property != null) {
                if (containsSameValueType(pvh, property)) {
                    pvh.setProperty(property);
                } else if (!ignoreInvalidAnim) {
                    throw new RuntimeException("Wrong valueType for Property: " + propertyName + ".  Expected type: " + property.getType().toString() + ". Actual " + "type defined in resources: " + pvh.getValueType().toString());
                }
            }
        }
    } else if (animator instanceof AnimatorSet) {
        for (Animator anim : ((AnimatorSet) animator).getChildAnimations()) {
            updateAnimatorProperty(anim, targetName, vectorDrawable, ignoreInvalidAnim);
        }
    }
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) PropertyValuesHolder(android.animation.PropertyValuesHolder) Property(android.util.Property)

Example 4 with Property

use of android.util.Property in project platform_frameworks_base by android.

the class AnimatedVectorDrawable method updateAnimatorProperty.

private static void updateAnimatorProperty(Animator animator, String targetName, VectorDrawable vectorDrawable, boolean ignoreInvalidAnim) {
    if (animator instanceof ObjectAnimator) {
        // Change the property of the Animator from using reflection based on the property
        // name to a Property object that wraps the setter and getter for modifying that
        // specific property for a given object. By replacing the reflection with a direct call,
        // we can largely reduce the time it takes for a animator to modify a VD property.
        PropertyValuesHolder[] holders = ((ObjectAnimator) animator).getValues();
        for (int i = 0; i < holders.length; i++) {
            PropertyValuesHolder pvh = holders[i];
            String propertyName = pvh.getPropertyName();
            Object targetNameObj = vectorDrawable.getTargetByName(targetName);
            Property property = null;
            if (targetNameObj instanceof VectorDrawable.VObject) {
                property = ((VectorDrawable.VObject) targetNameObj).getProperty(propertyName);
            } else if (targetNameObj instanceof VectorDrawable.VectorDrawableState) {
                property = ((VectorDrawable.VectorDrawableState) targetNameObj).getProperty(propertyName);
            }
            if (property != null) {
                if (containsSameValueType(pvh, property)) {
                    pvh.setProperty(property);
                } else if (!ignoreInvalidAnim) {
                    throw new RuntimeException("Wrong valueType for Property: " + propertyName + ".  Expected type: " + property.getType().toString() + ". Actual " + "type defined in resources: " + pvh.getValueType().toString());
                }
            }
        }
    } else if (animator instanceof AnimatorSet) {
        for (Animator anim : ((AnimatorSet) animator).getChildAnimations()) {
            updateAnimatorProperty(anim, targetName, vectorDrawable, ignoreInvalidAnim);
        }
    }
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) PropertyValuesHolder(android.animation.PropertyValuesHolder) Property(android.util.Property)

Example 5 with Property

use of android.util.Property in project android_frameworks_base by crdroidandroid.

the class AnimatedVectorDrawable method updateAnimatorProperty.

private static void updateAnimatorProperty(Animator animator, String targetName, VectorDrawable vectorDrawable, boolean ignoreInvalidAnim) {
    if (animator instanceof ObjectAnimator) {
        // Change the property of the Animator from using reflection based on the property
        // name to a Property object that wraps the setter and getter for modifying that
        // specific property for a given object. By replacing the reflection with a direct call,
        // we can largely reduce the time it takes for a animator to modify a VD property.
        PropertyValuesHolder[] holders = ((ObjectAnimator) animator).getValues();
        for (int i = 0; i < holders.length; i++) {
            PropertyValuesHolder pvh = holders[i];
            String propertyName = pvh.getPropertyName();
            Object targetNameObj = vectorDrawable.getTargetByName(targetName);
            Property property = null;
            if (targetNameObj instanceof VectorDrawable.VObject) {
                property = ((VectorDrawable.VObject) targetNameObj).getProperty(propertyName);
            } else if (targetNameObj instanceof VectorDrawable.VectorDrawableState) {
                property = ((VectorDrawable.VectorDrawableState) targetNameObj).getProperty(propertyName);
            }
            if (property != null) {
                if (containsSameValueType(pvh, property)) {
                    pvh.setProperty(property);
                } else if (!ignoreInvalidAnim) {
                    throw new RuntimeException("Wrong valueType for Property: " + propertyName + ".  Expected type: " + property.getType().toString() + ". Actual " + "type defined in resources: " + pvh.getValueType().toString());
                }
            }
        }
    } else if (animator instanceof AnimatorSet) {
        for (Animator anim : ((AnimatorSet) animator).getChildAnimations()) {
            updateAnimatorProperty(anim, targetName, vectorDrawable, ignoreInvalidAnim);
        }
    }
}
Also used : ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ValueAnimator(android.animation.ValueAnimator) PropertyValuesHolder(android.animation.PropertyValuesHolder) Property(android.util.Property)

Aggregations

Animator (android.animation.Animator)5 AnimatorSet (android.animation.AnimatorSet)5 ObjectAnimator (android.animation.ObjectAnimator)5 PropertyValuesHolder (android.animation.PropertyValuesHolder)5 ValueAnimator (android.animation.ValueAnimator)5 Property (android.util.Property)5