aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam W. Brown <adamwbrown@gmail.com>2013-11-03 13:57:30 -0800
committerAdam W. Brown <adamwbrown@gmail.com>2013-11-03 14:18:18 -0800
commit54086f9c87af47015cb5de5356310598e4b7dbf5 (patch)
treef584de3bd3a6cc4c7f0ce5c89ca245436945141e /src
parentc69c01be6ed2403242ee9cf8c2052c031879fa69 (diff)
downloadvolley-54086f9c87af47015cb5de5356310598e4b7dbf5.tar.gz
Fix default image not displaying prior to load
Previously, if a default image was set, it would not be displayed until a network load had begun. In some use cases where the load would not be started until some arbitrary time in the future, this would leave an empty image view visible to the user. This patch checks to see if there is a default image set, and if so, uses that to clear the view, so prior to loading, the defualt image will be shown. Change-Id: I6fcee408d95d708676d68f3f0bc7222e56570f39
Diffstat (limited to 'src')
-rw-r--r--src/com/android/volley/toolbox/NetworkImageView.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/com/android/volley/toolbox/NetworkImageView.java b/src/com/android/volley/toolbox/NetworkImageView.java
index 74c9159..6fe857f 100644
--- a/src/com/android/volley/toolbox/NetworkImageView.java
+++ b/src/com/android/volley/toolbox/NetworkImageView.java
@@ -120,7 +120,7 @@ public class NetworkImageView extends ImageView {
mImageContainer.cancelRequest();
mImageContainer = null;
}
- setImageBitmap(null);
+ setDefaultImageOrNull();
return;
}
@@ -132,7 +132,7 @@ public class NetworkImageView extends ImageView {
} else {
// if there is a pre-existing request, cancel it if it's fetching a different URL.
mImageContainer.cancelRequest();
- setImageBitmap(null);
+ setDefaultImageOrNull();
}
}
@@ -175,6 +175,15 @@ public class NetworkImageView extends ImageView {
mImageContainer = newContainer;
}
+ private void setDefaultImageOrNull() {
+ if(mDefaultImageId != 0) {
+ setImageResource(mDefaultImageId);
+ }
+ else {
+ setImageBitmap(null);
+ }
+ }
+
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);