summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2015-01-30 15:55:48 -0800
committerAlan Viverette <alanv@google.com>2015-01-30 15:55:48 -0800
commit96ccd39d354d8b268eac32e4cf873ea141ef5ed4 (patch)
tree053354d010f7ee44de3d02690070cfb38bba8a49
parent84183103f4a9222ddbe22c7289f9627c74892d53 (diff)
downloadframeworks_base-96ccd39d354d8b268eac32e4cf873ea141ef5ed4.zip
frameworks_base-96ccd39d354d8b268eac32e4cf873ea141ef5ed4.tar.gz
frameworks_base-96ccd39d354d8b268eac32e4cf873ea141ef5ed4.tar.bz2
Use inherited visibility to set visibility of managed drawables
Previously we only used direct visibility, which resulted in strange behavior when a parent view with an animated child was hidden. We were also incorrectly awakening scroll bars for non-visible views, though that's a much less visible (pun intended) bug. Only handles the two most common cases for ripples. A subsequent CL will update handling of View drawable management and fix this for all managed drawables. Bug: 15350931 Change-Id: I0d0fe2c51210e8d2e0a73b0248cec3b93bfc36f5
-rw-r--r--core/java/android/view/View.java21
-rw-r--r--core/java/android/widget/FrameLayout.java15
2 files changed, 24 insertions, 12 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 19c9271..5b26ebb 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);
+ }
}
/**
diff --git a/core/java/android/widget/FrameLayout.java b/core/java/android/widget/FrameLayout.java
index f208fff..b5782fc 100644
--- a/core/java/android/widget/FrameLayout.java
+++ b/core/java/android/widget/FrameLayout.java
@@ -18,6 +18,7 @@ package android.widget;
import java.util.ArrayList;
+import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
import android.content.res.ColorStateList;
@@ -203,11 +204,15 @@ public class FrameLayout extends ViewGroup {
}
@Override
- @RemotableViewMethod
- public void setVisibility(@Visibility int visibility) {
- super.setVisibility(visibility);
- if (mForeground != null) {
- mForeground.setVisible(visibility == VISIBLE, false);
+ protected void onVisibilityChanged(@NonNull View changedView, @Visibility int visibility) {
+ super.onVisibilityChanged(changedView, visibility);
+
+ final Drawable dr = mForeground;
+ if (dr != null) {
+ final boolean visible = visibility == VISIBLE && getVisibility() == VISIBLE;
+ if (visible != dr.isVisible()) {
+ dr.setVisible(visible, false);
+ }
}
}