summaryrefslogtreecommitdiffstats
path: root/core/java/android/widget/ImageView.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/java/android/widget/ImageView.java')
-rw-r--r--core/java/android/widget/ImageView.java32
1 files changed, 21 insertions, 11 deletions
diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java
index f90a9fe..c68bfca 100644
--- a/core/java/android/widget/ImageView.java
+++ b/core/java/android/widget/ImageView.java
@@ -386,21 +386,21 @@ public class ImageView extends View {
*/
@android.view.RemotableViewMethod
public void setImageResource(int resId) {
- if (mUri != null || mResource != resId) {
- final int oldWidth = mDrawableWidth;
- final int oldHeight = mDrawableHeight;
+ // The resource configuration may have changed, so we should always
+ // try to load the resource even if the resId hasn't changed.
+ final int oldWidth = mDrawableWidth;
+ final int oldHeight = mDrawableHeight;
- updateDrawable(null);
- mResource = resId;
- mUri = null;
+ updateDrawable(null);
+ mResource = resId;
+ mUri = null;
- resolveUri();
+ resolveUri();
- if (oldWidth != mDrawableWidth || oldHeight != mDrawableHeight) {
- requestLayout();
- }
- invalidate();
+ if (oldWidth != mDrawableWidth || oldHeight != mDrawableHeight) {
+ requestLayout();
}
+ invalidate();
}
/**
@@ -527,6 +527,12 @@ public class ImageView extends View {
if (mHasDrawableTintMode) {
mDrawable.setTintMode(mDrawableTintMode);
}
+
+ // The drawable (or one of its children) may not have been
+ // stateful before applying the tint, so let's try again.
+ if (mDrawable.isStateful()) {
+ mDrawable.setState(getDrawableState());
+ }
}
}
@@ -820,6 +826,7 @@ public class ImageView extends View {
mDrawableHeight = d.getIntrinsicHeight();
applyImageTint();
applyColorMod();
+
configureBounds();
} else {
mDrawableWidth = mDrawableHeight = -1;
@@ -1120,6 +1127,9 @@ public class ImageView extends View {
/** @hide */
public void animateTransform(Matrix matrix) {
+ if (mDrawable == null) {
+ return;
+ }
if (matrix == null) {
mDrawable.setBounds(0, 0, getWidth(), getHeight());
} else {