/** * 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. * * @param target The target object from which the current value should be extracted. * @param kf The keyframe which holds the property name and value. */ private void setupValue(Object target, Keyframe kf) { // if (mProperty != null) { // kf.setValue(mProperty.get(target)); // } try { if (mGetter == null) { Class targetClass = target.getClass(); setupGetter(targetClass); } kf.setValue(mGetter.invoke(target)); } catch (InvocationTargetException e) { Log.e("PropertyValuesHolder", e.toString()); } catch (IllegalAccessException e) { Log.e("PropertyValuesHolder", e.toString()); } }
/** * 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. * * @param target The object on which the setter (and possibly getter) exist. */ void setupSetterAndGetter(Object target) { // if (mProperty != null) { // // check to make sure that mProperty is on the class of target // try { // Object testValue = mProperty.get(target); // for (Keyframe kf : mKeyframeSet.mKeyframes) { // if (!kf.hasValue()) { // kf.setValue(mProperty.get(target)); // } // } // return; // } catch (ClassCastException e) { // Log.e("PropertyValuesHolder","No such property (" + mProperty.getName() + // ") on target object " + target + ". Trying reflection instead"); // mProperty = null; // } // } Class targetClass = target.getClass(); if (mSetter == null) { setupSetter(targetClass); } for (Keyframe kf : mKeyframeSet.mKeyframes) { if (!kf.hasValue()) { if (mGetter == null) { setupGetter(targetClass); } try { kf.setValue(mGetter.invoke(target)); } catch (InvocationTargetException e) { Log.e("PropertyValuesHolder", e.toString()); } catch (IllegalAccessException e) { Log.e("PropertyValuesHolder", e.toString()); } } } }