singletonList(new BitmapImageDecoder())));
+ }
+
+ @NonNull
+ public Builder imageDecoderFactory(@NonNull ImageDecoderFactory factory) {
+ decoderFactory = factory;
+ return this;
+ }
+
/**
* Add a custom transformation to be applied to the image.
*
@@ -657,6 +677,10 @@ public Request build() {
if (priority == null) {
priority = Priority.NORMAL;
}
+ if (decoderFactory == null) {
+ decoderFactory = new ImageDecoderFactory(
+ Collections.singletonList(new BitmapImageDecoder()));
+ }
return new Request(this);
}
diff --git a/picasso/src/main/java/com/squareup/picasso3/RequestCreator.java b/picasso/src/main/java/com/squareup/picasso3/RequestCreator.java
index 9d686a8692..4acf1b3f36 100644
--- a/picasso/src/main/java/com/squareup/picasso3/RequestCreator.java
+++ b/picasso/src/main/java/com/squareup/picasso3/RequestCreator.java
@@ -32,6 +32,7 @@
import androidx.core.content.ContextCompat;
import com.squareup.picasso3.RemoteViewsAction.RemoteViewsTarget;
import java.io.IOException;
+import java.util.Collections;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
@@ -74,13 +75,14 @@ public class RequestCreator {
"Picasso instance already shut down. Cannot submit new requests.");
}
this.picasso = picasso;
- this.data = new Request.Builder(uri, resourceId, picasso.defaultBitmapConfig);
+ this.data = new Request.Builder(uri, resourceId, picasso.imageDecoderFactory,
+ picasso.defaultBitmapConfig);
}
@SuppressWarnings("NullAway")
@VisibleForTesting RequestCreator() {
this.picasso = null;
- this.data = new Request.Builder(null, 0, null);
+ this.data = new Request.Builder(null, 0, null, null);
}
/**
@@ -334,6 +336,21 @@ public RequestCreator priority(@NonNull Priority priority) {
return this;
}
+ /**
+ * Specify that the image should be decoded as a bitmap.
+ */
+ @NonNull
+ public RequestCreator asBitmap() {
+ return imageDecoderFactory(new ImageDecoderFactory(
+ Collections.singletonList(new BitmapImageDecoder())));
+ }
+
+ @NonNull
+ public RequestCreator imageDecoderFactory(@NonNull ImageDecoderFactory imageDecoderFactory) {
+ this.data.imageDecoderFactory(imageDecoderFactory);
+ return this;
+ }
+
/**
* Add a custom transformation to be applied to the image.
*
diff --git a/picasso/src/main/java/com/squareup/picasso3/RequestHandler.java b/picasso/src/main/java/com/squareup/picasso3/RequestHandler.java
index f6c94765af..9257757a8f 100644
--- a/picasso/src/main/java/com/squareup/picasso3/RequestHandler.java
+++ b/picasso/src/main/java/com/squareup/picasso3/RequestHandler.java
@@ -68,7 +68,7 @@ public Result(@NonNull Drawable drawable, @NonNull Picasso.LoadedFrom loadedFrom
this(null, checkNotNull(drawable, "drawable == null"), loadedFrom, 0);
}
- private Result(
+ Result(
@Nullable Bitmap bitmap,
@Nullable Drawable drawable,
@NonNull Picasso.LoadedFrom loadedFrom,
diff --git a/picasso/src/main/java/com/squareup/picasso3/ResourceDrawableRequestHandler.java b/picasso/src/main/java/com/squareup/picasso3/ResourceDrawableRequestHandler.java
index cee2beaa91..110400e501 100644
--- a/picasso/src/main/java/com/squareup/picasso3/ResourceDrawableRequestHandler.java
+++ b/picasso/src/main/java/com/squareup/picasso3/ResourceDrawableRequestHandler.java
@@ -61,4 +61,5 @@ public static ResourceDrawableRequestHandler create(@NonNull final Context conte
}
});
}
+
}
diff --git a/picasso/src/main/java/com/squareup/picasso3/StatsSnapshot.java b/picasso/src/main/java/com/squareup/picasso3/StatsSnapshot.java
index 3cf4ff1015..5bca870e75 100644
--- a/picasso/src/main/java/com/squareup/picasso3/StatsSnapshot.java
+++ b/picasso/src/main/java/com/squareup/picasso3/StatsSnapshot.java
@@ -17,7 +17,6 @@
import android.util.Log;
import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import java.io.IOException;
import okio.Buffer;
import okio.BufferedSink;
@@ -129,7 +128,7 @@ public void dump(@NonNull BufferedSink sink) throws IOException {
sink.writeUtf8("\n");
}
- @Nullable
+ @NonNull
@Override public String toString() {
return "StatsSnapshot{"
+ "maxSize="
diff --git a/picasso/src/test/java/com/squareup/picasso3/BitmapHunterTest.java b/picasso/src/test/java/com/squareup/picasso3/BitmapHunterTest.java
index 696fe935fd..ad7e47b8f1 100644
--- a/picasso/src/test/java/com/squareup/picasso3/BitmapHunterTest.java
+++ b/picasso/src/test/java/com/squareup/picasso3/BitmapHunterTest.java
@@ -60,6 +60,7 @@
import static com.squareup.picasso3.TestUtils.CONTENT_KEY_1;
import static com.squareup.picasso3.TestUtils.CUSTOM_URI;
import static com.squareup.picasso3.TestUtils.CUSTOM_URI_KEY;
+import static com.squareup.picasso3.TestUtils.DEFAULT_DECODERS;
import static com.squareup.picasso3.TestUtils.FILE_1_URL;
import static com.squareup.picasso3.TestUtils.FILE_KEY_1;
import static com.squareup.picasso3.TestUtils.MEDIA_STORE_CONTENT_1_URL;
@@ -371,8 +372,9 @@ public final class BitmapHunterTest {
List handlers = Collections.singletonList(handler);
// Must use non-mock constructor because that is where Picasso's list of handlers is created.
Picasso picasso =
- new Picasso(context, dispatcher, UNUSED_CALL_FACTORY, null, cache, null, NO_TRANSFORMERS,
- handlers, stats, ARGB_8888, false, false);
+ new Picasso(context, dispatcher, UNUSED_CALL_FACTORY, null, cache, null,
+ DEFAULT_DECODERS, NO_TRANSFORMERS, handlers, stats, ARGB_8888, false,
+ false);
BitmapHunter hunter = forRequest(picasso, dispatcher, cache, stats, action);
assertThat(hunter.requestHandler).isEqualTo(handler);
}
diff --git a/picasso/src/test/java/com/squareup/picasso3/BitmapTargetActionTest.java b/picasso/src/test/java/com/squareup/picasso3/BitmapTargetActionTest.java
index 105b5b24a7..ace6a7a61f 100644
--- a/picasso/src/test/java/com/squareup/picasso3/BitmapTargetActionTest.java
+++ b/picasso/src/test/java/com/squareup/picasso3/BitmapTargetActionTest.java
@@ -25,6 +25,7 @@
import static android.graphics.Bitmap.Config.ARGB_8888;
import static com.squareup.picasso3.Picasso.LoadedFrom.MEMORY;
+import static com.squareup.picasso3.TestUtils.DEFAULT_DECODERS;
import static com.squareup.picasso3.TestUtils.NO_HANDLERS;
import static com.squareup.picasso3.TestUtils.NO_TRANSFORMERS;
import static com.squareup.picasso3.TestUtils.RESOURCE_ID_1;
@@ -77,8 +78,9 @@ public void invokesOnBitmapFailedIfTargetIsNotNullWithErrorResourceId() {
Dispatcher dispatcher = mock(Dispatcher.class);
PlatformLruCache cache = new PlatformLruCache(0);
Picasso picasso =
- new Picasso(context, dispatcher, UNUSED_CALL_FACTORY, null, cache, null, NO_TRANSFORMERS,
- NO_HANDLERS, mock(Stats.class), ARGB_8888, false, false);
+ new Picasso(context, dispatcher, UNUSED_CALL_FACTORY, null, cache,
+ null, DEFAULT_DECODERS, NO_TRANSFORMERS, NO_HANDLERS, mock(Stats.class),
+ ARGB_8888, false, false);
Resources res = mock(Resources.class);
BitmapTargetAction request = new BitmapTargetAction(picasso, target, null, null, RESOURCE_ID_1);
diff --git a/picasso/src/test/java/com/squareup/picasso3/ImageViewActionTest.java b/picasso/src/test/java/com/squareup/picasso3/ImageViewActionTest.java
index cc74d5abe0..f93a7228f8 100644
--- a/picasso/src/test/java/com/squareup/picasso3/ImageViewActionTest.java
+++ b/picasso/src/test/java/com/squareup/picasso3/ImageViewActionTest.java
@@ -26,6 +26,7 @@
import static com.google.common.truth.Truth.assertThat;
import static com.squareup.picasso3.Picasso.LoadedFrom.MEMORY;
+import static com.squareup.picasso3.TestUtils.DEFAULT_DECODERS;
import static com.squareup.picasso3.TestUtils.NO_HANDLERS;
import static com.squareup.picasso3.TestUtils.NO_TRANSFORMERS;
import static com.squareup.picasso3.TestUtils.RESOURCE_ID_1;
@@ -56,7 +57,7 @@ public void invokesTargetAndCallbackSuccessIfTargetIsNotNull() {
PlatformLruCache cache = new PlatformLruCache(0);
Picasso picasso =
new Picasso(RuntimeEnvironment.application, dispatcher, UNUSED_CALL_FACTORY, null, cache,
- null, NO_TRANSFORMERS, NO_HANDLERS, mock(Stats.class), Bitmap.Config.ARGB_8888, false,
+ null, DEFAULT_DECODERS, NO_TRANSFORMERS, NO_HANDLERS, mock(Stats.class), Bitmap.Config.ARGB_8888, false,
false);
ImageView target = mockImageViewTarget();
Callback callback = mockCallback();
diff --git a/picasso/src/test/java/com/squareup/picasso3/MediaStoreRequestHandlerTest.java b/picasso/src/test/java/com/squareup/picasso3/MediaStoreRequestHandlerTest.java
index 025da393ff..848c371232 100644
--- a/picasso/src/test/java/com/squareup/picasso3/MediaStoreRequestHandlerTest.java
+++ b/picasso/src/test/java/com/squareup/picasso3/MediaStoreRequestHandlerTest.java
@@ -21,6 +21,7 @@
import static com.squareup.picasso3.MediaStoreRequestHandler.PicassoKind.MICRO;
import static com.squareup.picasso3.MediaStoreRequestHandler.PicassoKind.MINI;
import static com.squareup.picasso3.MediaStoreRequestHandler.getPicassoKind;
+import static com.squareup.picasso3.TestUtils.DEFAULT_DECODERS;
import static com.squareup.picasso3.TestUtils.MEDIA_STORE_CONTENT_1_URL;
import static com.squareup.picasso3.TestUtils.MEDIA_STORE_CONTENT_KEY_1;
import static com.squareup.picasso3.TestUtils.makeBitmap;
@@ -45,7 +46,7 @@ public class MediaStoreRequestHandlerTest {
@Test public void decodesVideoThumbnailWithVideoMimeType() {
final Bitmap bitmap = makeBitmap();
Request request =
- new Request.Builder(MEDIA_STORE_CONTENT_1_URL, 0, ARGB_8888)
+ new Request.Builder(MEDIA_STORE_CONTENT_1_URL, 0, DEFAULT_DECODERS, ARGB_8888)
.stableKey(MEDIA_STORE_CONTENT_KEY_1).resize(100, 100).build();
Action action = mockAction(request);
MediaStoreRequestHandler requestHandler = create("video/");
@@ -63,7 +64,7 @@ public class MediaStoreRequestHandlerTest {
@Test public void decodesImageThumbnailWithImageMimeType() {
final Bitmap bitmap = makeBitmap(20, 20);
Request request =
- new Request.Builder(MEDIA_STORE_CONTENT_1_URL, 0, ARGB_8888)
+ new Request.Builder(MEDIA_STORE_CONTENT_1_URL, 0, DEFAULT_DECODERS, ARGB_8888)
.stableKey(MEDIA_STORE_CONTENT_KEY_1).resize(100, 100).build();
Action action = mockAction(request);
MediaStoreRequestHandler requestHandler = create("image/png");
diff --git a/picasso/src/test/java/com/squareup/picasso3/PicassoTest.java b/picasso/src/test/java/com/squareup/picasso3/PicassoTest.java
index e5f22b1c0c..0dc825d8c6 100644
--- a/picasso/src/test/java/com/squareup/picasso3/PicassoTest.java
+++ b/picasso/src/test/java/com/squareup/picasso3/PicassoTest.java
@@ -23,8 +23,10 @@
import androidx.annotation.NonNull;
import com.squareup.picasso3.Picasso.RequestTransformer;
import java.io.File;
+import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
+import okio.BufferedSource;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -42,6 +44,7 @@
import static com.squareup.picasso3.Picasso.Listener;
import static com.squareup.picasso3.Picasso.LoadedFrom.MEMORY;
import static com.squareup.picasso3.RemoteViewsAction.RemoteViewsTarget;
+import static com.squareup.picasso3.TestUtils.DEFAULT_DECODERS;
import static com.squareup.picasso3.TestUtils.NOOP_REQUEST_HANDLER;
import static com.squareup.picasso3.TestUtils.NOOP_TRANSFORMER;
import static com.squareup.picasso3.TestUtils.NO_HANDLERS;
@@ -88,7 +91,7 @@ public final class PicassoTest {
@Before public void setUp() {
initMocks(this);
picasso = new Picasso(context, dispatcher, UNUSED_CALL_FACTORY, null, cache, listener,
- NO_TRANSFORMERS, NO_HANDLERS, stats, ARGB_8888, false, false);
+ DEFAULT_DECODERS, NO_TRANSFORMERS, NO_HANDLERS, stats, ARGB_8888, false, false);
}
@Test public void submitWithTargetInvokesDispatcher() {
@@ -192,7 +195,7 @@ public final class PicassoTest {
}
@Test public void resumeActionTriggersSubmitOnPausedAction() {
- Request request = new Request.Builder(URI_1, 0, ARGB_8888).build();
+ Request request = new Request.Builder(URI_1, 0, DEFAULT_DECODERS, ARGB_8888).build();
Action action =
new Action(mockPicasso(), request) {
@Override void complete(RequestHandler.Result result) {
@@ -213,7 +216,7 @@ public final class PicassoTest {
@Test public void resumeActionImmediatelyCompletesCachedRequest() {
cache.set(URI_KEY_1, bitmap);
- Request request = new Request.Builder(URI_1, 0, ARGB_8888).build();
+ Request request = new Request.Builder(URI_1, 0, DEFAULT_DECODERS, ARGB_8888).build();
Action action =
new Action(mockPicasso(), request) {
@Override void complete(RequestHandler.Result result) {
@@ -371,7 +374,7 @@ public final class PicassoTest {
okhttp3.Cache cache = new okhttp3.Cache(temporaryFolder.getRoot(), 100);
Picasso picasso =
new Picasso(context, dispatcher, UNUSED_CALL_FACTORY, cache, this.cache, listener,
- NO_TRANSFORMERS, NO_HANDLERS, stats, ARGB_8888, false, false);
+ DEFAULT_DECODERS, NO_TRANSFORMERS, NO_HANDLERS, stats, ARGB_8888, false, false);
picasso.shutdown();
assertThat(cache.isClosed()).isTrue();
}
@@ -403,7 +406,8 @@ public final class PicassoTest {
}
};
Picasso picasso = new Picasso(context, dispatcher, UNUSED_CALL_FACTORY, null, cache, listener,
- Collections.singletonList(brokenTransformer), NO_HANDLERS, stats, ARGB_8888, false, false);
+ DEFAULT_DECODERS, Collections.singletonList(brokenTransformer), NO_HANDLERS, stats,
+ ARGB_8888, false, false);
Request request = new Request.Builder(URI_1).build();
try {
picasso.transformRequest(request);
@@ -557,6 +561,31 @@ public final class PicassoTest {
assertThat(original.requestHandlers).hasSize(NUM_BUILTIN_HANDLERS);
}
+ @Test public void clonedImageDecodersAreRetained() {
+ Picasso parent = defaultPicasso(RuntimeEnvironment.application, false, false);
+
+ ImageDecoder newDecoder = new ImageDecoder() {
+ @Override public boolean canHandleSource(@NonNull BufferedSource source) {
+ return false;
+ }
+
+ @NonNull @Override
+ public Image decodeImage(@NonNull BufferedSource source, @NonNull Request request)
+ throws IOException {
+ return null;
+ }
+ };
+
+ Picasso child = parent.newBuilder()
+ .addImageDecoder(newDecoder)
+ .build();
+
+ assertThat(child.imageDecoderFactory.decoders).hasSize(3);
+ ImageDecoder parentCustomDecoder = parent.imageDecoderFactory.decoders.get(0);
+ assertThat(child.imageDecoderFactory.decoders).contains(parentCustomDecoder);
+ assertThat(child.imageDecoderFactory.decoders).contains(newDecoder);
+ }
+
@Test public void cloneSharesStatefulInstances() {
Picasso parent = defaultPicasso(RuntimeEnvironment.application, true, true);
@@ -576,6 +605,9 @@ public final class PicassoTest {
parent.requestHandlers.get(i).getClass());
}
+ assertThat(child.imageDecoderFactory.decoders).hasSize(
+ parent.imageDecoderFactory.decoders.size());
+
assertThat(child.defaultBitmapConfig).isEqualTo(parent.defaultBitmapConfig);
assertThat(child.indicatorsEnabled).isEqualTo(parent.indicatorsEnabled);
assertThat(child.loggingEnabled).isEqualTo(parent.loggingEnabled);
diff --git a/picasso/src/test/java/com/squareup/picasso3/RemoteViewsActionTest.java b/picasso/src/test/java/com/squareup/picasso3/RemoteViewsActionTest.java
index f96753da52..e311e8a11a 100644
--- a/picasso/src/test/java/com/squareup/picasso3/RemoteViewsActionTest.java
+++ b/picasso/src/test/java/com/squareup/picasso3/RemoteViewsActionTest.java
@@ -30,6 +30,7 @@
import static android.graphics.Bitmap.Config.ARGB_8888;
import static com.google.common.truth.Truth.assertThat;
import static com.squareup.picasso3.Picasso.LoadedFrom.NETWORK;
+import static com.squareup.picasso3.TestUtils.DEFAULT_DECODERS;
import static com.squareup.picasso3.TestUtils.NO_HANDLERS;
import static com.squareup.picasso3.TestUtils.NO_TRANSFORMERS;
import static com.squareup.picasso3.TestUtils.UNUSED_CALL_FACTORY;
@@ -102,8 +103,9 @@ private TestableRemoteViewsAction createAction(int errorResId, Callback callback
private Picasso createPicasso() {
Dispatcher dispatcher = mock(Dispatcher.class);
PlatformLruCache cache = new PlatformLruCache(0);
- return new Picasso(RuntimeEnvironment.application, dispatcher, UNUSED_CALL_FACTORY, null, cache,
- null, NO_TRANSFORMERS, NO_HANDLERS, mock(Stats.class), ARGB_8888, false, false);
+ return new Picasso(RuntimeEnvironment.application, dispatcher, UNUSED_CALL_FACTORY,
+ null, cache, null, DEFAULT_DECODERS, NO_TRANSFORMERS, NO_HANDLERS,
+ mock(Stats.class), ARGB_8888, false, false);
}
static class TestableRemoteViewsAction extends RemoteViewsAction {
diff --git a/picasso/src/test/java/com/squareup/picasso3/RequestCreatorTest.java b/picasso/src/test/java/com/squareup/picasso3/RequestCreatorTest.java
index 636b7f6474..46ddd67ba3 100644
--- a/picasso/src/test/java/com/squareup/picasso3/RequestCreatorTest.java
+++ b/picasso/src/test/java/com/squareup/picasso3/RequestCreatorTest.java
@@ -42,6 +42,7 @@
import static com.squareup.picasso3.Picasso.Priority.NORMAL;
import static com.squareup.picasso3.RemoteViewsAction.AppWidgetAction;
import static com.squareup.picasso3.RemoteViewsAction.NotificationAction;
+import static com.squareup.picasso3.TestUtils.DEFAULT_DECODERS;
import static com.squareup.picasso3.TestUtils.NO_HANDLERS;
import static com.squareup.picasso3.TestUtils.NO_TRANSFORMERS;
import static com.squareup.picasso3.TestUtils.STABLE_1;
@@ -273,8 +274,8 @@ public void intoImageViewWithQuickMemoryCacheCheckDoesNotSubmit() {
PlatformLruCache cache = new PlatformLruCache(0);
Picasso picasso =
spy(new Picasso(RuntimeEnvironment.application, mock(Dispatcher.class), UNUSED_CALL_FACTORY,
- null, cache, null, NO_TRANSFORMERS, NO_HANDLERS, mock(Stats.class), ARGB_8888, false,
- false));
+ null, cache, null, DEFAULT_DECODERS, NO_TRANSFORMERS, NO_HANDLERS,
+ mock(Stats.class), ARGB_8888, false, false));
doReturn(bitmap).when(picasso).quickMemoryCacheCheck(URI_KEY_1);
ImageView target = mockImageViewTarget();
Callback callback = mockCallback();
@@ -290,8 +291,8 @@ public void intoImageViewSetsPlaceholderDrawable() {
PlatformLruCache cache = new PlatformLruCache(0);
Picasso picasso =
spy(new Picasso(RuntimeEnvironment.application, mock(Dispatcher.class), UNUSED_CALL_FACTORY,
- null, cache, null, NO_TRANSFORMERS, NO_HANDLERS, mock(Stats.class), ARGB_8888, false,
- false));
+ null, cache, null, DEFAULT_DECODERS, NO_TRANSFORMERS, NO_HANDLERS,
+ mock(Stats.class), ARGB_8888, false, false));
ImageView target = mockImageViewTarget();
Drawable placeHolderDrawable = mock(Drawable.class);
new RequestCreator(picasso, URI_1, 0).placeholder(placeHolderDrawable).into(target);
@@ -305,8 +306,8 @@ public void intoImageViewNoPlaceholderDrawable() {
PlatformLruCache cache = new PlatformLruCache(0);
Picasso picasso =
spy(new Picasso(RuntimeEnvironment.application, mock(Dispatcher.class), UNUSED_CALL_FACTORY,
- null, cache, null, NO_TRANSFORMERS, NO_HANDLERS, mock(Stats.class), ARGB_8888, false,
- false));
+ null, cache, null, DEFAULT_DECODERS, NO_TRANSFORMERS, NO_HANDLERS,
+ mock(Stats.class), ARGB_8888, false, false));
ImageView target = mockImageViewTarget();
new RequestCreator(picasso, URI_1, 0).noPlaceholder().into(target);
verifyNoMoreInteractions(target);
@@ -319,8 +320,8 @@ public void intoImageViewSetsPlaceholderWithResourceId() {
PlatformLruCache cache = new PlatformLruCache(0);
Picasso picasso =
spy(new Picasso(RuntimeEnvironment.application, mock(Dispatcher.class), UNUSED_CALL_FACTORY,
- null, cache, null, NO_TRANSFORMERS, NO_HANDLERS, mock(Stats.class), ARGB_8888, false,
- false));
+ null, cache, null, DEFAULT_DECODERS, NO_TRANSFORMERS, NO_HANDLERS,
+ mock(Stats.class), ARGB_8888, false, false));
ImageView target = mockImageViewTarget();
new RequestCreator(picasso, URI_1, 0).placeholder(android.R.drawable.picture_frame)
.into(target);
diff --git a/picasso/src/test/java/com/squareup/picasso3/TestUtils.java b/picasso/src/test/java/com/squareup/picasso3/TestUtils.java
index 00d5faf341..ecd138843c 100644
--- a/picasso/src/test/java/com/squareup/picasso3/TestUtils.java
+++ b/picasso/src/test/java/com/squareup/picasso3/TestUtils.java
@@ -34,10 +34,12 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import okhttp3.Call;
import okhttp3.Response;
+import okio.BufferedSource;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -166,7 +168,7 @@ static Action mockAction(String key, Uri uri, Object target, int resourceId) {
static Action mockAction(String key, Uri uri, Object target, int resourceId, Priority priority,
String tag) {
- Request.Builder builder = new Request.Builder(uri, resourceId, DEFAULT_CONFIG).stableKey(key);
+ Request.Builder builder = new Request.Builder(uri, resourceId, DEFAULT_DECODERS, DEFAULT_CONFIG).stableKey(key);
if (priority != null) {
builder.priority(priority);
}
@@ -337,6 +339,20 @@ static DrawableLoader makeLoaderWithDrawable(final Drawable drawable) {
}
};
+ static final ImageDecoder NOOP_IMAGE_DECODER = new ImageDecoder() {
+ @Override public boolean canHandleSource(@NonNull BufferedSource source) {
+ return false;
+ }
+
+ @NonNull @Override
+ public Image decodeImage(@NonNull BufferedSource source, @NonNull Request request)
+ throws IOException {
+ return null;
+ }
+ };
+
+ static final ImageDecoderFactory DEFAULT_DECODERS = new ImageDecoderFactory(
+ Collections.singletonList(new BitmapImageDecoder()));
static final List NO_TRANSFORMERS = Collections.emptyList();
static final List NO_HANDLERS = Collections.emptyList();
@@ -353,6 +369,7 @@ static Picasso defaultPicasso(Context context, boolean hasRequestHandlers,
return builder
.callFactory(UNUSED_CALL_FACTORY)
.defaultBitmapConfig(DEFAULT_CONFIG)
+ .addImageDecoder(NOOP_IMAGE_DECODER)
.executor(new PicassoExecutorService(new PicassoThreadFactory()))
.indicatorsEnabled(true)
.listener(NOOP_LISTENER)
diff --git a/settings.gradle b/settings.gradle
index 94c282c758..875720cb7b 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -4,3 +4,4 @@ include 'picasso'
include 'picasso-pollexor'
include 'picasso-provider'
include 'picasso-sample'
+include 'decoders:svg'