Methods Summary |
---|
void | calculateValue(float fraction)Function used to calculate the value according to the evaluator set up for
this PropertyValuesHolder object. This function is called by ValueAnimator.animateValue().
Object value = mKeyframes.getValue(fraction);
mAnimatedValue = mConverter == null ? value : mConverter.convert(value);
|
public android.animation.PropertyValuesHolder | clone()
try {
PropertyValuesHolder newPVH = (PropertyValuesHolder) super.clone();
newPVH.mPropertyName = mPropertyName;
newPVH.mProperty = mProperty;
newPVH.mKeyframes = mKeyframes.clone();
newPVH.mEvaluator = mEvaluator;
return newPVH;
} catch (CloneNotSupportedException e) {
// won't reach here
return null;
}
|
private java.lang.Object | convertBack(java.lang.Object value)
if (mConverter != null) {
if (!(mConverter instanceof BidirectionalTypeConverter)) {
throw new IllegalArgumentException("Converter "
+ mConverter.getClass().getName()
+ " must be a BidirectionalTypeConverter");
}
value = ((BidirectionalTypeConverter) mConverter).convertBack(value);
}
return value;
|
java.lang.Object | getAnimatedValue()Internal function, called by ValueAnimator and ObjectAnimator, to retrieve the value
most recently calculated in calculateValue().
return mAnimatedValue;
|
static java.lang.String | getMethodName(java.lang.String prefix, java.lang.String propertyName)Utility method to derive a setter/getter method name from a property name, where the
prefix is typically "set" or "get" and the first letter of the property name is
capitalized.
if (propertyName == null || propertyName.length() == 0) {
// shouldn't get here
return prefix;
}
char firstLetter = Character.toUpperCase(propertyName.charAt(0));
String theRest = propertyName.substring(1);
return prefix + firstLetter + theRest;
|
private java.lang.reflect.Method | getPropertyFunction(java.lang.Class targetClass, java.lang.String prefix, java.lang.Class valueType)Determine the setter or getter function using the JavaBeans convention of setFoo or
getFoo for a property named 'foo'. This function figures out what the name of the
function should be and uses reflection to find the Method with that name on the
target object.
// TODO: faster implementation...
Method returnVal = null;
String methodName = getMethodName(prefix, mPropertyName);
Class args[] = null;
if (valueType == null) {
try {
returnVal = targetClass.getMethod(methodName, args);
} catch (NoSuchMethodException e) {
// Swallow the error, log it later
}
} else {
args = new Class[1];
Class typeVariants[];
if (valueType.equals(Float.class)) {
typeVariants = FLOAT_VARIANTS;
} else if (valueType.equals(Integer.class)) {
typeVariants = INTEGER_VARIANTS;
} else if (valueType.equals(Double.class)) {
typeVariants = DOUBLE_VARIANTS;
} else {
typeVariants = new Class[1];
typeVariants[0] = valueType;
}
for (Class typeVariant : typeVariants) {
args[0] = typeVariant;
try {
returnVal = targetClass.getMethod(methodName, args);
if (mConverter == null) {
// change the value type to suit
mValueType = typeVariant;
}
return returnVal;
} catch (NoSuchMethodException e) {
// Swallow the error and keep trying other variants
}
}
// If we got here, then no appropriate function was found
}
if (returnVal == null) {
Log.w("PropertyValuesHolder", "Method " +
getMethodName(prefix, mPropertyName) + "() with type " + valueType +
" not found on target class " + targetClass);
}
return returnVal;
|
public java.lang.String | getPropertyName()Gets the name of the property that will be animated. This name will be used to derive
a setter function that will be called to set animated values.
For example, a property name of foo will result
in a call to the function setFoo() on the target object. If either
valueFrom or valueTo is null, then a getter function will
also be derived and called.
return mPropertyName;
|
void | init()Internal function, called by ValueAnimator, to set up the TypeEvaluator that will be used
to calculate animated values.
if (mEvaluator == null) {
// We already handle int and float automatically, but not their Object
// equivalents
mEvaluator = (mValueType == Integer.class) ? sIntEvaluator :
(mValueType == Float.class) ? sFloatEvaluator :
null;
}
if (mEvaluator != null) {
// KeyframeSet knows how to evaluate the common types - only give it a custom
// evaluator if one has been set on this class
mKeyframes.setEvaluator(mEvaluator);
}
|
private static native void | nCallFloatMethod(java.lang.Object target, long methodID, float arg)
|
private static native void | nCallFourFloatMethod(java.lang.Object target, long methodID, float arg1, float arg2, float arg3, float arg4)
|
private static native void | nCallFourIntMethod(java.lang.Object target, long methodID, int arg1, int arg2, int arg3, int arg4)
|
private static native void | nCallIntMethod(java.lang.Object target, long methodID, int arg)
|
private static native void | nCallMultipleFloatMethod(java.lang.Object target, long methodID, float[] args)
|
private static native void | nCallMultipleIntMethod(java.lang.Object target, long methodID, int[] args)
|
private static native void | nCallTwoFloatMethod(java.lang.Object target, long methodID, float arg1, float arg2)
|
private static native void | nCallTwoIntMethod(java.lang.Object target, long methodID, int arg1, int arg2)
|
private static native long | nGetFloatMethod(java.lang.Class targetClass, java.lang.String methodName)
|
private static native long | nGetIntMethod(java.lang.Class targetClass, java.lang.String methodName)
|
private static native long | nGetMultipleFloatMethod(java.lang.Class targetClass, java.lang.String methodName, int numParams)
|
private static native long | nGetMultipleIntMethod(java.lang.Class targetClass, java.lang.String methodName, int numParams)
|
public static android.animation.PropertyValuesHolder | ofFloat(android.util.Property property, float values)Constructs and returns a PropertyValuesHolder with a given property and
set of float values.
return new FloatPropertyValuesHolder(property, values);
|
public static android.animation.PropertyValuesHolder | ofFloat(java.lang.String propertyName, float values)Constructs and returns a PropertyValuesHolder with a given property name and
set of float values.
return new FloatPropertyValuesHolder(propertyName, values);
|
public static android.animation.PropertyValuesHolder | ofInt(java.lang.String propertyName, int values)Constructs and returns a PropertyValuesHolder with a given property name and
set of int values.
return new IntPropertyValuesHolder(propertyName, values);
|
public static android.animation.PropertyValuesHolder | ofInt(android.util.Property property, int values)Constructs and returns a PropertyValuesHolder with a given property and
set of int values.
return new IntPropertyValuesHolder(property, values);
|
public static android.animation.PropertyValuesHolder | ofKeyframe(java.lang.String propertyName, Keyframe values)Constructs and returns a PropertyValuesHolder object with the specified property name and set
of values. These values can be of any type, but the type should be consistent so that
an appropriate {@link android.animation.TypeEvaluator} can be found that matches
the common type.
If there is only one value, it is assumed to be the end value of an animation,
and an initial value will be derived, if possible, by calling a getter function
on the object. Also, if any value is null, the value will be filled in when the animation
starts in the same way. This mechanism of automatically getting null values only works
if the PropertyValuesHolder object is used in conjunction
{@link ObjectAnimator}, and with a getter function
derived automatically from propertyName , since otherwise PropertyValuesHolder has
no way of determining what the value should be.
KeyframeSet keyframeSet = KeyframeSet.ofKeyframe(values);
return ofKeyframes(propertyName, keyframeSet);
|
public static android.animation.PropertyValuesHolder | ofKeyframe(android.util.Property property, Keyframe values)Constructs and returns a PropertyValuesHolder object with the specified property and set
of values. These values can be of any type, but the type should be consistent so that
an appropriate {@link android.animation.TypeEvaluator} can be found that matches
the common type.
If there is only one value, it is assumed to be the end value of an animation,
and an initial value will be derived, if possible, by calling the property's
{@link android.util.Property#get(Object)} function.
Also, if any value is null, the value will be filled in when the animation
starts in the same way. This mechanism of automatically getting null values only works
if the PropertyValuesHolder object is used in conjunction with
{@link ObjectAnimator}, since otherwise PropertyValuesHolder has
no way of determining what the value should be.
KeyframeSet keyframeSet = KeyframeSet.ofKeyframe(values);
return ofKeyframes(property, keyframeSet);
|
static android.animation.PropertyValuesHolder | ofKeyframes(java.lang.String propertyName, Keyframes keyframes)
if (keyframes instanceof Keyframes.IntKeyframes) {
return new IntPropertyValuesHolder(propertyName, (Keyframes.IntKeyframes) keyframes);
} else if (keyframes instanceof Keyframes.FloatKeyframes) {
return new FloatPropertyValuesHolder(propertyName,
(Keyframes.FloatKeyframes) keyframes);
} else {
PropertyValuesHolder pvh = new PropertyValuesHolder(propertyName);
pvh.mKeyframes = keyframes;
pvh.mValueType = keyframes.getType();
return pvh;
}
|
static android.animation.PropertyValuesHolder | ofKeyframes(android.util.Property property, Keyframes keyframes)
if (keyframes instanceof Keyframes.IntKeyframes) {
return new IntPropertyValuesHolder(property, (Keyframes.IntKeyframes) keyframes);
} else if (keyframes instanceof Keyframes.FloatKeyframes) {
return new FloatPropertyValuesHolder(property, (Keyframes.FloatKeyframes) keyframes);
} else {
PropertyValuesHolder pvh = new PropertyValuesHolder(property);
pvh.mKeyframes = keyframes;
pvh.mValueType = keyframes.getType();
return pvh;
}
|
public static android.animation.PropertyValuesHolder | ofMultiFloat(java.lang.String propertyName, float[][] values)Constructs and returns a PropertyValuesHolder with a given property name and
set of float[] values. At least two float[] values must be supplied,
a start and end value. If more values are supplied, the values will be animated from the
start, through all intermediate values to the end value. When used with ObjectAnimator,
the elements of the array represent the parameters of the setter function.
if (values.length < 2) {
throw new IllegalArgumentException("At least 2 values must be supplied");
}
int numParameters = 0;
for (int i = 0; i < values.length; i++) {
if (values[i] == null) {
throw new IllegalArgumentException("values must not be null");
}
int length = values[i].length;
if (i == 0) {
numParameters = length;
} else if (length != numParameters) {
throw new IllegalArgumentException("Values must all have the same length");
}
}
FloatArrayEvaluator evaluator = new FloatArrayEvaluator(new float[numParameters]);
return new MultiFloatValuesHolder(propertyName, null, evaluator, (Object[]) values);
|
public static android.animation.PropertyValuesHolder | ofMultiFloat(java.lang.String propertyName, android.graphics.Path path)Constructs and returns a PropertyValuesHolder with a given property name to use
as a multi-float setter. The values are animated along the path, with the first
parameter of the setter set to the x coordinate and the second set to the y coordinate.
Keyframes keyframes = KeyframeSet.ofPath(path);
PointFToFloatArray converter = new PointFToFloatArray();
return new MultiFloatValuesHolder(propertyName, converter, null, keyframes);
|
public static android.animation.PropertyValuesHolder | ofMultiFloat(java.lang.String propertyName, TypeConverter converter, TypeEvaluator evaluator, V values)Constructs and returns a PropertyValuesHolder with a given property and
set of Object values for use with ObjectAnimator multi-value setters. The Object
values are converted to float[] using the converter.
return new MultiFloatValuesHolder(propertyName, converter, evaluator, values);
|
public static android.animation.PropertyValuesHolder | ofMultiFloat(java.lang.String propertyName, TypeConverter converter, TypeEvaluator evaluator, Keyframe values)Constructs and returns a PropertyValuesHolder object with the specified property name or
setter name for use in a multi-float setter function using ObjectAnimator. The values can be
of any type, but the type should be consistent so that the supplied
{@link android.animation.TypeEvaluator} can be used to to evaluate the animated value. The
converter converts the values to parameters in the setter function.
At least two values must be supplied, a start and an end value.
KeyframeSet keyframeSet = KeyframeSet.ofKeyframe(values);
return new MultiFloatValuesHolder(propertyName, converter, evaluator, keyframeSet);
|
public static android.animation.PropertyValuesHolder | ofMultiInt(java.lang.String propertyName, int[][] values)Constructs and returns a PropertyValuesHolder with a given property name and
set of int[] values. At least two int[] values must be supplied,
a start and end value. If more values are supplied, the values will be animated from the
start, through all intermediate values to the end value. When used with ObjectAnimator,
the elements of the array represent the parameters of the setter function.
if (values.length < 2) {
throw new IllegalArgumentException("At least 2 values must be supplied");
}
int numParameters = 0;
for (int i = 0; i < values.length; i++) {
if (values[i] == null) {
throw new IllegalArgumentException("values must not be null");
}
int length = values[i].length;
if (i == 0) {
numParameters = length;
} else if (length != numParameters) {
throw new IllegalArgumentException("Values must all have the same length");
}
}
IntArrayEvaluator evaluator = new IntArrayEvaluator(new int[numParameters]);
return new MultiIntValuesHolder(propertyName, null, evaluator, (Object[]) values);
|
public static android.animation.PropertyValuesHolder | ofMultiInt(java.lang.String propertyName, android.graphics.Path path)Constructs and returns a PropertyValuesHolder with a given property name to use
as a multi-int setter. The values are animated along the path, with the first
parameter of the setter set to the x coordinate and the second set to the y coordinate.
Keyframes keyframes = KeyframeSet.ofPath(path);
PointFToIntArray converter = new PointFToIntArray();
return new MultiIntValuesHolder(propertyName, converter, null, keyframes);
|
public static android.animation.PropertyValuesHolder | ofMultiInt(java.lang.String propertyName, TypeConverter converter, TypeEvaluator evaluator, V values)Constructs and returns a PropertyValuesHolder with a given property and
set of Object values for use with ObjectAnimator multi-value setters. The Object
values are converted to int[] using the converter.
return new MultiIntValuesHolder(propertyName, converter, evaluator, values);
|
public static android.animation.PropertyValuesHolder | ofMultiInt(java.lang.String propertyName, TypeConverter converter, TypeEvaluator evaluator, Keyframe values)Constructs and returns a PropertyValuesHolder object with the specified property name or
setter name for use in a multi-int setter function using ObjectAnimator. The values can be
of any type, but the type should be consistent so that the supplied
{@link android.animation.TypeEvaluator} can be used to to evaluate the animated value. The
converter converts the values to parameters in the setter function.
At least two values must be supplied, a start and an end value.
KeyframeSet keyframeSet = KeyframeSet.ofKeyframe(values);
return new MultiIntValuesHolder(propertyName, converter, evaluator, keyframeSet);
|
public static android.animation.PropertyValuesHolder | ofObject(java.lang.String propertyName, TypeEvaluator evaluator, java.lang.Object values)Constructs and returns a PropertyValuesHolder with a given property name and
set of Object values. This variant also takes a TypeEvaluator because the system
cannot automatically interpolate between objects of unknown type.
PropertyValuesHolder pvh = new PropertyValuesHolder(propertyName);
pvh.setObjectValues(values);
pvh.setEvaluator(evaluator);
return pvh;
|
public static android.animation.PropertyValuesHolder | ofObject(java.lang.String propertyName, TypeConverter converter, android.graphics.Path path)Constructs and returns a PropertyValuesHolder with a given property name and
a Path along which the values should be animated. This variant supports a
TypeConverter to convert from PointF to the target
type.
The PointF passed to converter or property , if
converter is null , is reused on each animation frame and should
not be stored by the setter or TypeConverter.
PropertyValuesHolder pvh = new PropertyValuesHolder(propertyName);
pvh.mKeyframes = KeyframeSet.ofPath(path);
pvh.mValueType = PointF.class;
pvh.setConverter(converter);
return pvh;
|
public static android.animation.PropertyValuesHolder | ofObject(android.util.Property property, TypeEvaluator evaluator, V values)Constructs and returns a PropertyValuesHolder with a given property and
set of Object values. This variant also takes a TypeEvaluator because the system
cannot automatically interpolate between objects of unknown type.
PropertyValuesHolder pvh = new PropertyValuesHolder(property);
pvh.setObjectValues(values);
pvh.setEvaluator(evaluator);
return pvh;
|
public static android.animation.PropertyValuesHolder | ofObject(android.util.Property property, TypeConverter converter, TypeEvaluator evaluator, T values)Constructs and returns a PropertyValuesHolder with a given property and
set of Object values. This variant also takes a TypeEvaluator because the system
cannot automatically interpolate between objects of unknown type. This variant also
takes a TypeConverter to convert from animated values to the type
of the property. If only one value is supplied, the TypeConverter
must be a {@link android.animation.BidirectionalTypeConverter} to retrieve the current
value.
PropertyValuesHolder pvh = new PropertyValuesHolder(property);
pvh.setConverter(converter);
pvh.setObjectValues(values);
pvh.setEvaluator(evaluator);
return pvh;
|
public static android.animation.PropertyValuesHolder | ofObject(android.util.Property property, TypeConverter converter, android.graphics.Path path)Constructs and returns a PropertyValuesHolder with a given property and
a Path along which the values should be animated. This variant supports a
TypeConverter to convert from PointF to the target
type.
The PointF passed to converter or property , if
converter is null , is reused on each animation frame and should
not be stored by the setter or TypeConverter.
PropertyValuesHolder pvh = new PropertyValuesHolder(property);
pvh.mKeyframes = KeyframeSet.ofPath(path);
pvh.mValueType = PointF.class;
pvh.setConverter(converter);
return pvh;
|
void | setAnimatedValue(java.lang.Object target)Internal function to set the value on the target object, using the setter set up
earlier on this PropertyValuesHolder object. This function is called by ObjectAnimator
to handle turning the value calculated by ValueAnimator into a value set on the object
according to the name of the property.
if (mProperty != null) {
mProperty.set(target, getAnimatedValue());
}
if (mSetter != null) {
try {
mTmpValueArray[0] = getAnimatedValue();
mSetter.invoke(target, mTmpValueArray);
} catch (InvocationTargetException e) {
Log.e("PropertyValuesHolder", e.toString());
} catch (IllegalAccessException e) {
Log.e("PropertyValuesHolder", e.toString());
}
}
|
public void | setConverter(TypeConverter converter)Sets the converter to convert from the values type to the setter's parameter type.
If only one value is supplied, converter must be a
{@link android.animation.BidirectionalTypeConverter}.
mConverter = converter;
|
public void | setEvaluator(TypeEvaluator evaluator)The TypeEvaluator will be automatically determined based on the type of values
supplied to PropertyValuesHolder. The evaluator can be manually set, however, if so
desired. This may be important in cases where either the type of the values supplied
do not match the way that they should be interpolated between, or if the values
are of a custom type or one not currently understood by the animation system. Currently,
only values of type float and int (and their Object equivalents: Float
and Integer) are correctly interpolated; all other types require setting a TypeEvaluator.
mEvaluator = evaluator;
mKeyframes.setEvaluator(evaluator);
|
public void | setFloatValues(float values)Set the animated values for this object to this set of floats.
If there is only one value, it is assumed to be the end value of an animation,
and an initial value will be derived, if possible, by calling a getter function
on the object. Also, if any value is null, the value will be filled in when the animation
starts in the same way. This mechanism of automatically getting null values only works
if the PropertyValuesHolder object is used in conjunction
{@link ObjectAnimator}, and with a getter function
derived automatically from propertyName , since otherwise PropertyValuesHolder has
no way of determining what the value should be.
mValueType = float.class;
mKeyframes = KeyframeSet.ofFloat(values);
|
public void | setIntValues(int values)Set the animated values for this object to this set of ints.
If there is only one value, it is assumed to be the end value of an animation,
and an initial value will be derived, if possible, by calling a getter function
on the object. Also, if any value is null, the value will be filled in when the animation
starts in the same way. This mechanism of automatically getting null values only works
if the PropertyValuesHolder object is used in conjunction
{@link ObjectAnimator}, and with a getter function
derived automatically from propertyName , since otherwise PropertyValuesHolder has
no way of determining what the value should be.
mValueType = int.class;
mKeyframes = KeyframeSet.ofInt(values);
|
public void | setKeyframes(Keyframe values)Set the animated values for this object to this set of Keyframes.
int numKeyframes = values.length;
Keyframe keyframes[] = new Keyframe[Math.max(numKeyframes,2)];
mValueType = ((Keyframe)values[0]).getType();
for (int i = 0; i < numKeyframes; ++i) {
keyframes[i] = (Keyframe)values[i];
}
mKeyframes = new KeyframeSet(keyframes);
|
public void | setObjectValues(java.lang.Object values)Set the animated values for this object to this set of Objects.
If there is only one value, it is assumed to be the end value of an animation,
and an initial value will be derived, if possible, by calling a getter function
on the object. Also, if any value is null, the value will be filled in when the animation
starts in the same way. This mechanism of automatically getting null values only works
if the PropertyValuesHolder object is used in conjunction
{@link ObjectAnimator}, and with a getter function
derived automatically from propertyName , since otherwise PropertyValuesHolder has
no way of determining what the value should be.
mValueType = values[0].getClass();
mKeyframes = KeyframeSet.ofObject(values);
if (mEvaluator != null) {
mKeyframes.setEvaluator(mEvaluator);
}
|
public void | setProperty(android.util.Property property)Sets the property that will be animated.
Note that if this PropertyValuesHolder object is used with ObjectAnimator, the property
must exist on the target object specified in that ObjectAnimator.
mProperty = property;
|
public void | setPropertyName(java.lang.String propertyName)Sets the name of the property that will be animated. This name is used to derive
a setter function that will be called to set animated values.
For example, a property name of foo will result
in a call to the function setFoo() on the target object. If either
valueFrom or valueTo is null, then a getter function will
also be derived and called.
Note that the setter function derived from this property name
must take the same parameter type as the
valueFrom and valueTo properties, otherwise the call to
the setter function will fail.
mPropertyName = propertyName;
|
void | setupEndValue(java.lang.Object target)This function is called by ObjectAnimator when setting the end values for an animation.
The end values are set according to the current values in the target object. The
property whose value is extracted is whatever is specified by the propertyName of this
PropertyValuesHolder object.
List<Keyframe> keyframes = mKeyframes.getKeyframes();
if (!keyframes.isEmpty()) {
setupValue(target, keyframes.get(keyframes.size() - 1));
}
|
private void | setupGetter(java.lang.Class targetClass)Utility function to get the getter from targetClass
mGetter = setupSetterOrGetter(targetClass, sGetterPropertyMap, "get", null);
|
void | setupSetter(java.lang.Class targetClass)Utility function to get the setter from targetClass
Class<?> propertyType = mConverter == null ? mValueType : mConverter.getTargetType();
mSetter = setupSetterOrGetter(targetClass, sSetterPropertyMap, "set", propertyType);
|
void | setupSetterAndGetter(java.lang.Object target)Internal function (called from ObjectAnimator) to set up the setter and getter
prior to running the animation. If the setter has not been manually set for this
object, it will be derived automatically given the property name, target object, and
types of values supplied. If no getter has been set, it will be supplied iff any of the
supplied values was null. If there is a null value, then the getter (supplied or derived)
will be called to set those null values to the current value of the property
on the target object.
mKeyframes.invalidateCache();
if (mProperty != null) {
// check to make sure that mProperty is on the class of target
try {
Object testValue = null;
List<Keyframe> keyframes = mKeyframes.getKeyframes();
int keyframeCount = keyframes == null ? 0 : keyframes.size();
for (int i = 0; i < keyframeCount; i++) {
Keyframe kf = keyframes.get(i);
if (!kf.hasValue() || kf.valueWasSetOnStart()) {
if (testValue == null) {
testValue = convertBack(mProperty.get(target));
}
kf.setValue(testValue);
kf.setValueWasSetOnStart(true);
}
}
return;
} catch (ClassCastException e) {
Log.w("PropertyValuesHolder","No such property (" + mProperty.getName() +
") on target object " + target + ". Trying reflection instead");
mProperty = null;
}
}
// We can't just say 'else' here because the catch statement sets mProperty to null.
if (mProperty == null) {
Class targetClass = target.getClass();
if (mSetter == null) {
setupSetter(targetClass);
}
List<Keyframe> keyframes = mKeyframes.getKeyframes();
int keyframeCount = keyframes == null ? 0 : keyframes.size();
for (int i = 0; i < keyframeCount; i++) {
Keyframe kf = keyframes.get(i);
if (!kf.hasValue() || kf.valueWasSetOnStart()) {
if (mGetter == null) {
setupGetter(targetClass);
if (mGetter == null) {
// Already logged the error - just return to avoid NPE
return;
}
}
try {
Object value = convertBack(mGetter.invoke(target));
kf.setValue(value);
kf.setValueWasSetOnStart(true);
} catch (InvocationTargetException e) {
Log.e("PropertyValuesHolder", e.toString());
} catch (IllegalAccessException e) {
Log.e("PropertyValuesHolder", e.toString());
}
}
}
}
|
private java.lang.reflect.Method | setupSetterOrGetter(java.lang.Class targetClass, java.util.HashMap propertyMapMap, java.lang.String prefix, java.lang.Class valueType)Returns the setter or getter requested. This utility function checks whether the
requested method exists in the propertyMapMap cache. If not, it calls another
utility function to request the Method from the targetClass directly.
Method setterOrGetter = null;
synchronized(propertyMapMap) {
// Have to lock property map prior to reading it, to guard against
// another thread putting something in there after we've checked it
// but before we've added an entry to it
HashMap<String, Method> propertyMap = propertyMapMap.get(targetClass);
boolean wasInMap = false;
if (propertyMap != null) {
wasInMap = propertyMap.containsKey(mPropertyName);
if (wasInMap) {
setterOrGetter = propertyMap.get(mPropertyName);
}
}
if (!wasInMap) {
setterOrGetter = getPropertyFunction(targetClass, prefix, valueType);
if (propertyMap == null) {
propertyMap = new HashMap<String, Method>();
propertyMapMap.put(targetClass, propertyMap);
}
propertyMap.put(mPropertyName, setterOrGetter);
}
}
return setterOrGetter;
|
void | setupStartValue(java.lang.Object target)This function is called by ObjectAnimator when setting the start values for an animation.
The start values are set according to the current values in the target object. The
property whose value is extracted is whatever is specified by the propertyName of this
PropertyValuesHolder object.
List<Keyframe> keyframes = mKeyframes.getKeyframes();
if (!keyframes.isEmpty()) {
setupValue(target, keyframes.get(0));
}
|
private void | setupValue(java.lang.Object target, Keyframe kf)Utility function to set the value stored in a particular Keyframe. The value used is
whatever the value is for the property name specified in the keyframe on the target object.
if (mProperty != null) {
Object value = convertBack(mProperty.get(target));
kf.setValue(value);
}
try {
if (mGetter == null) {
Class targetClass = target.getClass();
setupGetter(targetClass);
if (mGetter == null) {
// Already logged the error - just return to avoid NPE
return;
}
}
Object value = convertBack(mGetter.invoke(target));
kf.setValue(value);
} catch (InvocationTargetException e) {
Log.e("PropertyValuesHolder", e.toString());
} catch (IllegalAccessException e) {
Log.e("PropertyValuesHolder", e.toString());
}
|
public java.lang.String | toString()
return mPropertyName + ": " + mKeyframes.toString();
|