Search in sources :

Example 1 with ArtistImageResponse

use of org.gateshipone.malp.application.artworkdatabase.network.responses.ArtistImageResponse in project malp by gateship-one.

the class ArtworkManager method fetchJSONException.

/**
 * Interface implementation to handle errors during fetching of artist images
 *
 * @param artist Artist that resulted in a fetch error
 */
public void fetchJSONException(MPDArtist artist, JSONException exception) {
    Log.e(TAG, "Error fetching artist: " + artist.getArtistName());
    ArtistImageResponse imageResponse = new ArtistImageResponse();
    imageResponse.artist = artist;
    imageResponse.image = null;
    imageResponse.url = null;
    new InsertArtistImageTask().execute(imageResponse);
}
Also used : ArtistImageResponse(org.gateshipone.malp.application.artworkdatabase.network.responses.ArtistImageResponse)

Example 2 with ArtistImageResponse

use of org.gateshipone.malp.application.artworkdatabase.network.responses.ArtistImageResponse in project malp by gateship-one.

the class ArtworkManager method fetchVolleyError.

/**
 * Called if a volley error occurs during internet communication.
 *
 * @param artist {@link MPDArtist} the error occured for.
 * @param error  {@link VolleyError} that was emitted
 */
public void fetchVolleyError(MPDArtist artist, VolleyError error) {
    Log.e(TAG, "VolleyError fetching: " + artist.getArtistName());
    if (error != null) {
        NetworkResponse networkResponse = error.networkResponse;
        /**
         * Rate limit probably reached. Discontinue downloading to prevent
         * ban on the servers.
         */
        if (networkResponse != null && networkResponse.statusCode == 503) {
            mArtistList.clear();
            cancelAllRequests();
            boolean isEmpty;
            synchronized (mAlbumList) {
                isEmpty = mAlbumList.isEmpty();
            }
            if (isEmpty && mBulkProgressCallback != null) {
                mBulkProgressCallback.finishedLoading();
            }
            return;
        }
    }
    ArtistImageResponse imageResponse = new ArtistImageResponse();
    imageResponse.artist = artist;
    imageResponse.image = null;
    imageResponse.url = null;
    new InsertArtistImageTask().execute(imageResponse);
}
Also used : NetworkResponse(com.android.volley.NetworkResponse) ArtistImageResponse(org.gateshipone.malp.application.artworkdatabase.network.responses.ArtistImageResponse)

Example 3 with ArtistImageResponse

use of org.gateshipone.malp.application.artworkdatabase.network.responses.ArtistImageResponse in project malp by gateship-one.

the class ArtistImageByteRequest method parseNetworkResponse.

@Override
protected Response<ArtistImageResponse> parseNetworkResponse(NetworkResponse response) {
    ArtistImageResponse imageResponse = new ArtistImageResponse();
    imageResponse.artist = mArtist;
    imageResponse.image = response.data;
    imageResponse.url = mUrl;
    return Response.success(imageResponse, null);
}
Also used : ArtistImageResponse(org.gateshipone.malp.application.artworkdatabase.network.responses.ArtistImageResponse)

Aggregations

ArtistImageResponse (org.gateshipone.malp.application.artworkdatabase.network.responses.ArtistImageResponse)3 NetworkResponse (com.android.volley.NetworkResponse)1