Search in sources :

Example 1 with AlbumInfoListener

use of com.naman14.timber.lastfmapi.callbacks.AlbumInfoListener in project Timber by naman14.

the class ImageUtils method loadAlbumArtFromLastfm.

private static void loadAlbumArtFromLastfm(long albumId, final ImageView albumArt, final ImageLoadingListener listener) {
    Album album = AlbumLoader.getAlbum(albumArt.getContext(), albumId);
    LastFmClient.getInstance(albumArt.getContext()).getAlbumInfo(new AlbumQuery(album.title, album.artistName), new AlbumInfoListener() {

        @Override
        public void albumInfoSuccess(final LastfmAlbum album) {
            if (album != null) {
                ImageLoader.getInstance().displayImage(album.mArtwork.get(4).mUrl, albumArt, lastfmDisplayImageOptions, new SimpleImageLoadingListener() {

                    @Override
                    public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
                        listener.onLoadingComplete(imageUri, view, loadedImage);
                    }

                    @Override
                    public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
                        listener.onLoadingFailed(imageUri, view, failReason);
                    }
                });
            }
        }

        @Override
        public void albumInfoFailed() {
        }
    });
}
Also used : SimpleImageLoadingListener(com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener) AlbumInfoListener(com.naman14.timber.lastfmapi.callbacks.AlbumInfoListener) Bitmap(android.graphics.Bitmap) LastfmAlbum(com.naman14.timber.lastfmapi.models.LastfmAlbum) AlbumQuery(com.naman14.timber.lastfmapi.models.AlbumQuery) Album(com.naman14.timber.models.Album) LastfmAlbum(com.naman14.timber.lastfmapi.models.LastfmAlbum) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) ImageView(android.widget.ImageView) View(android.view.View)

Aggregations

Bitmap (android.graphics.Bitmap)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 AlbumInfoListener (com.naman14.timber.lastfmapi.callbacks.AlbumInfoListener)1 AlbumQuery (com.naman14.timber.lastfmapi.models.AlbumQuery)1 LastfmAlbum (com.naman14.timber.lastfmapi.models.LastfmAlbum)1 Album (com.naman14.timber.models.Album)1 FailReason (com.nostra13.universalimageloader.core.assist.FailReason)1 SimpleImageLoadingListener (com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener)1