use of org.gateshipone.malp.application.artworkdatabase.network.responses.TrackAlbumFetchError in project malp by gateship-one.
the class ArtworkManager method fetchAlbumImage.
/**
* Starts an asynchronous fetch for the image of the given album
*
* @param track Track to be used for image fetching
*/
public void fetchAlbumImage(final MPDTrack track) {
// Create a dummy album
MPDAlbum album = new MPDAlbum(track.getTrackAlbum());
album.setMBID(track.getTrackAlbumMBID());
album.setArtistName(track.getTrackAlbumArtist());
// Check if user-specified HTTP cover download is activated
if (HTTPAlbumImageProvider.getInstance(mContext).getActive()) {
HTTPAlbumImageProvider.getInstance(mContext).fetchAlbumImage(track, response -> new InsertTrackAlbumImageTask().execute(response), new TrackAlbumFetchError() {
@Override
public void fetchJSONException(MPDTrack track, JSONException exception) {
}
@Override
public void fetchVolleyError(MPDTrack track, VolleyError error) {
Log.v(TAG, "Local HTTP download failed, try user-selected download provider");
MPDAlbum album = new MPDAlbum(track.getTrackAlbum());
album.setMBID(track.getTrackAlbumMBID());
album.setArtistName(track.getTrackAlbumArtist());
fetchAlbumImage(album);
synchronized (mTrackList) {
if (!mTrackList.isEmpty()) {
fetchNextBulkTrackAlbum();
}
}
}
});
} else {
// Use the dummy album to fetch the image
fetchAlbumImage(album);
}
}
Aggregations