summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Nader Jawad <njawad@google.com> 2019-09-16 16:46:25 -0700
committer Nader Jawad <njawad@google.com> 2019-09-20 14:55:14 -0700
commit6fa971bab3bb53c35e9792019c438bada8c18f09 (patch)
tree268763353e3f1257b4d5a284ca06b0f8fb5c17bb
parentd4718e182daf17ab9789744649f4ff663c5ccd63 (diff)
Updated ViewPropertyAnimator to call View
methods Modified ViewPropertyAnimator to call directly into View setters instead of RenderNode APIs to match implementation of FloatProperty objects on View. This makes the animation APIs consistent with one another and always call through the proper code paths to give View implementations an opportunity to handle alpha changes themselves. Bug: 140961174 Test: Added CTS tests for ViewPropertyAnimator Change-Id: I1c0023af50be47786296b46510034eb798658c20
-rw-r--r--core/java/android/view/ViewPropertyAnimator.java21
1 files changed, 18 insertions, 3 deletions
diff --git a/core/java/android/view/ViewPropertyAnimator.java b/core/java/android/view/ViewPropertyAnimator.java
index 957673dba133..859e9a43f7c2 100644
--- a/core/java/android/view/ViewPropertyAnimator.java
+++ b/core/java/android/view/ViewPropertyAnimator.java
@@ -1138,6 +1138,12 @@ public class ViewPropertyAnimator {
boolean hardwareAccelerated = mView.isHardwareAccelerated();
+ // alpha requires slightly different treatment than the other (transform) properties.
+ // The logic in setAlpha() is not simply setting mAlpha, plus the invalidation
+ // logic is dependent on how the view handles an internal call to onSetAlpha().
+ // We track what kinds of properties are set, and how alpha is handled when it is
+ // set, and perform the invalidation steps appropriately.
+ boolean alphaHandled = false;
if (!hardwareAccelerated) {
mView.invalidateParentCaches();
}
@@ -1152,7 +1158,11 @@ public class ViewPropertyAnimator {
for (int i = 0; i < count; ++i) {
NameValuesHolder values = valueList.get(i);
float value = values.mFromValue + fraction * values.mDeltaValue;
- setValue(values.mNameConstant, value);
+ if (values.mNameConstant == ALPHA) {
+ alphaHandled = mView.setAlphaNoInvalidation(value);
+ } else {
+ setValue(values.mNameConstant, value);
+ }
}
}
if ((propertyMask & TRANSFORM_MASK) != 0) {
@@ -1160,8 +1170,13 @@ public class ViewPropertyAnimator {
mView.mPrivateFlags |= View.PFLAG_DRAWN; // force another invalidation
}
}
-
- mView.invalidateViewProperty(false, false);
+ // invalidate(false) in all cases except if alphaHandled gets set to true
+ // via the call to setAlphaNoInvalidation(), above
+ if (alphaHandled) {
+ mView.invalidate(true);
+ } else {
+ mView.invalidateViewProperty(false, false);
+ }
if (mUpdateListener != null) {
mUpdateListener.onAnimationUpdate(animation);
}