diff options
| author | Alan Viverette <alanv@google.com> | 2015-01-31 00:21:46 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-01-31 00:21:47 +0000 |
| commit | e426f3b0b2ffd0b4cb72063db509cd4bacabfdcf (patch) | |
| tree | c7fb61bc86d2b7246e0f410255102235a71792a4 /core/java/android/view/View.java | |
| parent | 8a6b56651b42df2a073d68bbaf23e681acd7eeb5 (diff) | |
| parent | 96ccd39d354d8b268eac32e4cf873ea141ef5ed4 (diff) | |
Merge "Use inherited visibility to set visibility of managed drawables"
Diffstat (limited to 'core/java/android/view/View.java')
| -rw-r--r-- | core/java/android/view/View.java | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 19c9271cb137..5b26ebba6b35 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -6780,7 +6780,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, @RemotableViewMethod public void setVisibility(@Visibility int visibility) { setFlags(visibility, VISIBILITY_MASK); - if (mBackground != null) mBackground.setVisible(visibility == VISIBLE, false); } /** @@ -8806,20 +8805,28 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } /** - * Called when the visibility of the view or an ancestor of the view is changed. - * @param changedView The view whose visibility changed. Could be 'this' or - * an ancestor view. - * @param visibility The new visibility of changedView: {@link #VISIBLE}, - * {@link #INVISIBLE} or {@link #GONE}. + * Called when the visibility of the view or an ancestor of the view has + * changed. + * + * @param changedView The view whose visibility changed. May be + * {@code this} or an ancestor view. + * @param visibility The new visibility, one of {@link #VISIBLE}, + * {@link #INVISIBLE} or {@link #GONE}. */ protected void onVisibilityChanged(@NonNull View changedView, @Visibility int visibility) { - if (visibility == VISIBLE) { + final boolean visible = visibility == VISIBLE && getVisibility() == VISIBLE; + if (visible) { if (mAttachInfo != null) { initialAwakenScrollBars(); } else { mPrivateFlags |= PFLAG_AWAKEN_SCROLL_BARS_ON_ATTACH; } } + + final Drawable dr = mBackground; + if (dr != null && visible != dr.isVisible()) { + dr.setVisible(visible, false); + } } /** |
