diff options
| author | 2012-01-17 15:05:23 -0800 | |
|---|---|---|
| committer | 2012-01-17 15:05:23 -0800 | |
| commit | 73d27c3d46ce9a19c0cc358d0b2788f1f51706d7 (patch) | |
| tree | 19597a1b66ca975e7875545095bdc53d5918505e | |
| parent | 11d06a73df371be0b11d5cf586e24601d796c048 (diff) | |
| parent | a7a7eedee58b69ff3d36fa9d413ea902eb0d5d45 (diff) | |
Merge "Check if View's alpha must be updated in setter"
| -rw-r--r-- | core/java/android/view/View.java | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index e28028634852..9d5a773c0e64 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -7597,15 +7597,17 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal */ public void setAlpha(float alpha) { ensureTransformationInfo(); - mTransformationInfo.mAlpha = alpha; - invalidateParentCaches(); - if (onSetAlpha((int) (alpha * 255))) { - mPrivateFlags |= ALPHA_SET; - // subclass is handling alpha - don't optimize rendering cache invalidation - invalidate(true); - } else { - mPrivateFlags &= ~ALPHA_SET; - invalidate(false); + if (mTransformationInfo.mAlpha != alpha) { + mTransformationInfo.mAlpha = alpha; + invalidateParentCaches(); + if (onSetAlpha((int) (alpha * 255))) { + mPrivateFlags |= ALPHA_SET; + // subclass is handling alpha - don't optimize rendering cache invalidation + invalidate(true); + } else { + mPrivateFlags &= ~ALPHA_SET; + invalidate(false); + } } } @@ -7616,18 +7618,22 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal * alpha (the return value for onSetAlpha()). * * @param alpha The new value for the alpha property - * @return true if the View subclass handles alpha (the return value for onSetAlpha()) + * @return true if the View subclass handles alpha (the return value for onSetAlpha()) and + * the new value for the alpha property is different from the old value */ boolean setAlphaNoInvalidation(float alpha) { ensureTransformationInfo(); - mTransformationInfo.mAlpha = alpha; - boolean subclassHandlesAlpha = onSetAlpha((int) (alpha * 255)); - if (subclassHandlesAlpha) { - mPrivateFlags |= ALPHA_SET; - } else { - mPrivateFlags &= ~ALPHA_SET; + if (mTransformationInfo.mAlpha != alpha) { + mTransformationInfo.mAlpha = alpha; + boolean subclassHandlesAlpha = onSetAlpha((int) (alpha * 255)); + if (subclassHandlesAlpha) { + mPrivateFlags |= ALPHA_SET; + return true; + } else { + mPrivateFlags &= ~ALPHA_SET; + } } - return subclassHandlesAlpha; + return false; } /** |