Try to optimize image loading for AlbumView
This commit is contained in:
parent
bc114521c4
commit
900e009ed6
|
@ -149,7 +149,7 @@ public class ImageLoader implements Runnable
|
|||
|
||||
if (bitmap != null)
|
||||
{
|
||||
setImageBitmap(view, bitmap, crossFade);
|
||||
setImageBitmap(view, entry, bitmap, crossFade);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -193,12 +193,20 @@ public class ImageLoader implements Runnable
|
|||
return null;
|
||||
}
|
||||
|
||||
private void setImageBitmap(View view, Bitmap bitmap, boolean crossFade)
|
||||
private void setImageBitmap(View view, MusicDirectory.Entry entry, Bitmap bitmap, boolean crossFade)
|
||||
{
|
||||
if (view instanceof ImageView)
|
||||
{
|
||||
ImageView imageView = (ImageView) view;
|
||||
|
||||
MusicDirectory.Entry tagEntry = (MusicDirectory.Entry) view.getTag();
|
||||
|
||||
if (entry != null && tagEntry != null && !entry.equals(tagEntry))
|
||||
{
|
||||
Log.i(TAG, "Skipping entry");
|
||||
return;
|
||||
}
|
||||
|
||||
if (crossFade)
|
||||
{
|
||||
Drawable existingDrawable = imageView.getDrawable();
|
||||
|
@ -227,7 +235,7 @@ public class ImageLoader implements Runnable
|
|||
{
|
||||
if (large)
|
||||
{
|
||||
setImageBitmap(view, largeUnknownImage, false);
|
||||
setImageBitmap(view, null, largeUnknownImage, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -308,7 +316,7 @@ public class ImageLoader implements Runnable
|
|||
@Override
|
||||
public void run()
|
||||
{
|
||||
setImageBitmap(view, bitmap, crossFade);
|
||||
setImageBitmap(view, entry, bitmap, crossFade);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -96,6 +96,8 @@ public class AlbumView extends UpdateView
|
|||
|
||||
public void setAlbum(final MusicDirectory.Entry album)
|
||||
{
|
||||
viewHolder.cover_art.setTag(album);
|
||||
imageLoader.loadImage(viewHolder.cover_art, album, false, 0, false, true);
|
||||
this.entry = album;
|
||||
|
||||
String title = album.getTitle();
|
||||
|
@ -106,7 +108,6 @@ public class AlbumView extends UpdateView
|
|||
viewHolder.artist.setText(artist);
|
||||
viewHolder.artist.setVisibility(artist == null ? View.GONE : View.VISIBLE);
|
||||
viewHolder.star.setImageDrawable(starred ? starDrawable : starHollowDrawable);
|
||||
imageLoader.loadImage(viewHolder.cover_art, album, false, 0, false, true);
|
||||
|
||||
if (Util.isOffline(this.context) || "-1".equals(album.getId()))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue