use of org.gateshipone.malp.application.artworkdatabase.network.responses.FanartFetchError in project malp by gateship-one.
the class FanartActivity method syncFanart.
/**
* Checks if new fanart is available for the given artist. This ensures that the user
* gets new images from time to time if they have old images in cache.
*
* @param track Track to check for new fanart for.
*/
private void syncFanart(final MPDTrack track) {
// Get a list of fanart urls for the current artist
if (!downloadAllowed()) {
return;
}
FanartTVManager.getInstance(getApplicationContext()).getArtistFanartURLs(track.getTrackArtistMBID(), response -> {
for (final String url : response) {
// Check if the given image is in the cache already.
if (mFanartCache.inCache(track.getTrackArtistMBID(), String.valueOf(url.hashCode()))) {
continue;
}
// If not try to download the image.
FanartTVManager.getInstance(getApplicationContext()).getFanartImage(track, url, response1 -> {
mFanartCache.addFanart(track.getTrackArtistMBID(), String.valueOf(response1.url.hashCode()), response1.image);
int fanartCount = mFanartCache.getFanartCount(response1.track.getTrackArtistMBID());
if (fanartCount == 1) {
updateFanartViews();
}
if (mCurrentFanart == (fanartCount - 2)) {
mNextFanart = (mCurrentFanart + 1) % fanartCount;
}
}, error -> {
});
}
}, new FanartFetchError() {
@Override
public void imageListFetchError() {
}
@Override
public void fanartFetchError(MPDTrack track) {
}
});
}
Aggregations