I am trying to change the image of an avatar dynamically. When I change the avatar image, it results in no image (nor background color showing).
This method loads an image or sets background color of avatar properly.
public static Avatar getAvatar(User user) {
Avatar avatar;
String filename = DIRECTORY + user.getImageName();
//helper to get download handler for the filename
DownloadHandler dh = ImageDownloader.getDownloadHandler(filename);
//Check if there is an image first; otherwise set the background color
if (dh != null) {
avatar = new Avatar();
avatar.setImageHandler(dh);
} else {
avatar = new Avatar(user.getFormattedName(false));
avatar.setColorIndex(user.getAvatarBackgroundIndex());
}
return avatar;
}
When my getAvatar method is called, I get the correct avatar:

This is the code to change the avatar image dynamically. The call to getDownloadHandler is returning a valid DownloadHandler (is not null).
avatar.setImageHandler(ImageDownloader.getDownloadHandler(
AvatarLoader.DIRECTORY + event.getData().getImageName()));
After this, the avatar image is removed:

Any help will be greatly appreciated!