summaryrefslogtreecommitdiff
path: root/core/java/android/widget/ImageView.java
diff options
context:
space:
mode:
authorAdam Powell <adamp@google.com>2016-03-15 14:43:19 -0700
committerAdam Powell <adamp@google.com>2016-03-15 16:20:11 -0700
commit41d9690c3e3588dd273308279b9e609c2c6da3c7 (patch)
treeb2d4d2b7680f0ff328ad90bba6305b67aeec7fa2 /core/java/android/widget/ImageView.java
parentde2fa62f8601cec6d45e4dc4b5bb68b7cc145051 (diff)
Add View#onVisibilityAggregated
There's a common misconception (even across the framework) that View#onVisibilityChanged determines and reports visibility on 'this' up to the changed view and the total visibility within the window. Knowing this is useful for things like starting/stopping animations. onVisibilityChanged only reports the visibility for the specific changed view, not the effects that would have down the tree. Add onVisibilityAggregated to report what some code thought it was getting already, and move ImageView and ProgressBar over to using it. Bug 27461617 Change-Id: I433f41de453e27a53f907f1d9805350f30f31de9
Diffstat (limited to 'core/java/android/widget/ImageView.java')
-rw-r--r--core/java/android/widget/ImageView.java25
1 files changed, 5 insertions, 20 deletions
diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java
index 3400873896f8..71b5ce9547c5 100644
--- a/core/java/android/widget/ImageView.java
+++ b/core/java/android/widget/ImageView.java
@@ -913,6 +913,7 @@ public class ImageView extends View {
if (mDrawable != null) {
mDrawable.setCallback(null);
unscheduleDrawable(mDrawable);
+ mDrawable.setVisible(false, false);
}
mDrawable = d;
@@ -923,7 +924,8 @@ public class ImageView extends View {
if (d.isStateful()) {
d.setState(getDrawableState());
}
- d.setVisible(getVisibility() == VISIBLE, true);
+ d.setVisible(isAttachedToWindow() && getWindowVisibility() == VISIBLE && isShown(),
+ true);
d.setLevel(mLevel);
mDrawableWidth = d.getIntrinsicWidth();
mDrawableHeight = d.getIntrinsicHeight();
@@ -1498,32 +1500,15 @@ public class ImageView extends View {
}
}
- @RemotableViewMethod
@Override
- public void setVisibility(int visibility) {
- super.setVisibility(visibility);
+ public void onVisibilityAggregated(View changedView, @Visibility int visibility) {
+ super.onVisibilityAggregated(changedView, visibility);
if (mDrawable != null) {
mDrawable.setVisible(visibility == VISIBLE, false);
}
}
@Override
- protected void onAttachedToWindow() {
- super.onAttachedToWindow();
- if (mDrawable != null) {
- mDrawable.setVisible(getVisibility() == VISIBLE, false);
- }
- }
-
- @Override
- protected void onDetachedFromWindow() {
- super.onDetachedFromWindow();
- if (mDrawable != null) {
- mDrawable.setVisible(false, false);
- }
- }
-
- @Override
public CharSequence getAccessibilityClassName() {
return ImageView.class.getName();
}