Search in sources :

Example 1 with LastFmArtist

use of com.kabouzeid.gramophone.lastfm.rest.model.LastFmArtist in project Phonograph by kabouzeid.

the class ArtistImageFetcher method loadData.

@Override
public InputStream loadData(Priority priority) throws Exception {
    if (!MusicUtil.isArtistNameUnknown(model.artistName) && Util.isAllowedToDownloadMetadata(context)) {
        Response<LastFmArtist> response = lastFMRestClient.getApiService().getArtistInfo(model.artistName, null, model.skipOkHttpCache ? "no-cache" : null).execute();
        if (!response.isSuccessful()) {
            throw new IOException("Request failed with code: " + response.code());
        }
        LastFmArtist lastFmArtist = response.body();
        if (isCancelled)
            return null;
        GlideUrl url = new GlideUrl(LastFMUtil.getLargestArtistImageUrl(lastFmArtist.getArtist().getImage()));
        urlFetcher = urlLoader.getResourceFetcher(url, width, height);
        return urlFetcher.loadData(priority);
    }
    return null;
}
Also used : LastFmArtist(com.kabouzeid.gramophone.lastfm.rest.model.LastFmArtist) IOException(java.io.IOException) GlideUrl(com.bumptech.glide.load.model.GlideUrl)

Aggregations

GlideUrl (com.bumptech.glide.load.model.GlideUrl)1 LastFmArtist (com.kabouzeid.gramophone.lastfm.rest.model.LastFmArtist)1 IOException (java.io.IOException)1