From 406a02b59d3a8f9890509200f048c23c3b3200b7 Mon Sep 17 00:00:00 2001 From: Chet Haase Date: Mon, 11 Jan 2016 16:27:20 -0800 Subject: [PATCH] Don't double-set keyframe values when Property exists There is logic in PVH.setupValue() that sets the value of the appropriate keyframe from a Property, if that Property object exists for the animator. But after that is done, it goes ahead and sets the same keyframe value based on the getter for the target object. This is not only redundant; it is wrong (in the odd situation in which a getter would return something different than Property.get()). The solution is to return early once we've set the value with the Property object. Issue #26471646 PropertyValuesHolder uses reflection in setupValue when a Property is being used Change-Id: I12634a25661400f13f44872ba17625b32e93ca19 --- .../animation/PropertyValuesHolder.java | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/core/java/android/animation/PropertyValuesHolder.java b/core/java/android/animation/PropertyValuesHolder.java index 8928e99cecd28..e993cca9e3251 100644 --- a/core/java/android/animation/PropertyValuesHolder.java +++ b/core/java/android/animation/PropertyValuesHolder.java @@ -861,22 +861,23 @@ public class PropertyValuesHolder implements Cloneable { if (mProperty != null) { Object value = convertBack(mProperty.get(target)); kf.setValue(value); - } - try { - if (mGetter == null) { - Class targetClass = target.getClass(); - setupGetter(targetClass); + } else { + try { if (mGetter == null) { - // Already logged the error - just return to avoid NPE - return; + 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()); } - 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()); } }