Search in sources :

Example 11 with Request

use of com.squareup.picasso.Request in project SeriesGuide by UweTrottmann.

the class SgPicassoRequestHandler method createRequest.

private static okhttp3.Request createRequest(Uri uri, int networkPolicy) {
    CacheControl cacheControl = null;
    if (networkPolicy != 0) {
        if (NetworkPolicy.isOfflineOnly(networkPolicy)) {
            cacheControl = CacheControl.FORCE_CACHE;
        } else {
            CacheControl.Builder builder = new CacheControl.Builder();
            if (!NetworkPolicy.shouldReadFromDiskCache(networkPolicy)) {
                builder.noCache();
            }
            if (!NetworkPolicy.shouldWriteToDiskCache(networkPolicy)) {
                builder.noStore();
            }
            cacheControl = builder.build();
        }
    }
    okhttp3.Request.Builder builder = new okhttp3.Request.Builder().url(uri.toString());
    if (cacheControl != null) {
        builder.cacheControl(cacheControl);
    }
    return builder.build();
}
Also used : Request(com.squareup.picasso.Request) CacheControl(okhttp3.CacheControl)

Aggregations

Request (com.squareup.picasso.Request)11 Test (org.junit.Test)9 ThumborUrlBuilder (com.squareup.pollexor.ThumborUrlBuilder)4 Uri (android.net.Uri)1 CacheControl (okhttp3.CacheControl)1 Config (org.robolectric.annotation.Config)1