|
38 | 38 | import java.io.File;
|
39 | 39 | import java.net.URL;
|
40 | 40 | import java.util.ArrayList;
|
| 41 | +import java.util.Arrays; |
41 | 42 | import java.util.List;
|
42 | 43 | import java.util.concurrent.Executor;
|
43 | 44 |
|
@@ -286,14 +287,52 @@ public RequestBuilder<TranscodeType> thumbnail(
|
286 | 287 | return thumbnail((RequestBuilder<TranscodeType>) null);
|
287 | 288 | }
|
288 | 289 |
|
| 290 | + return thumbnail(Arrays.asList(thumbnails)); |
| 291 | + } |
| 292 | + |
| 293 | + /** |
| 294 | + * Recursively applies {@link #thumbnail(RequestBuilder)} so that the {@link RequestBuilder}s are |
| 295 | + * loaded as thumbnails in the given priority order. |
| 296 | + * |
| 297 | + * <p>{@link #thumbnail(RequestBuilder)} is applied in the order given so that the {@link |
| 298 | + * RequestBuilder} at position 0 has the {@link RequestBuilder} at position 1 applied as using its |
| 299 | + * thumbnail method, the {@link RequestBuilder} at position 1 has the {@link RequestBuilder} at |
| 300 | + * position 2 applied using its thumbnail method and so on. |
| 301 | + * |
| 302 | + * <p>Calling this method with a {@code null} list of {@link RequestBuilder} thumbnails or an |
| 303 | + * empty list of {@link RequestBuilder} thumbnails is equivalent to calling {@link |
| 304 | + * #thumbnail(RequestBuilder)} with {@code null}. |
| 305 | + * |
| 306 | + * <p>Any individual {@link RequestBuilder} in the list of thumbnails provided here may be {@code |
| 307 | + * null}. {@code null} {@link RequestBuilder}s are ignored and excluded from the recursive chain. |
| 308 | + * |
| 309 | + * <p>The {@link RequestBuilder} objects provided here may be mutated and have any previous calls |
| 310 | + * to this method or {@link #thumbnail(RequestBuilder)} methods overridden. |
| 311 | + * |
| 312 | + * <p>Overrides any previous calls to {@link #thumbnail(RequestBuilder)}, {@link |
| 313 | + * #thumbnail(float)} and this method. |
| 314 | + * |
| 315 | + * @see #thumbnail(float) |
| 316 | + * @see #thumbnail(RequestBuilder) |
| 317 | + * @return This request builder. |
| 318 | + */ |
| 319 | + @SuppressWarnings({"CheckResult", "unchecked"}) |
| 320 | + @NonNull |
| 321 | + @CheckResult |
| 322 | + public RequestBuilder<TranscodeType> thumbnail( |
| 323 | + @Nullable List<RequestBuilder<TranscodeType>> thumbnails) { |
| 324 | + if (thumbnails == null || thumbnails.isEmpty()) { |
| 325 | + return thumbnail((RequestBuilder<TranscodeType>) null); |
| 326 | + } |
| 327 | + |
289 | 328 | RequestBuilder<TranscodeType> previous = null;
|
290 | 329 |
|
291 | 330 | // Start with the lowest priority thumbnail so that we can safely handle mutations if
|
292 | 331 | // autoClone() is enabled by assigning the result of calling thumbnail() during the iteration.
|
293 | 332 | // Starting with the highest priority thumbnail would prevent us from assigning the result of
|
294 | 333 | // thumbnail because the mutated request wouldn't be used in the next iteration.
|
295 |
| - for (int i = thumbnails.length - 1; i >= 0; i--) { |
296 |
| - RequestBuilder<TranscodeType> current = thumbnails[i]; |
| 334 | + for (int i = thumbnails.size() - 1; i >= 0; i--) { |
| 335 | + RequestBuilder<TranscodeType> current = thumbnails.get(i); |
297 | 336 | // Ignore null thumbnails.
|
298 | 337 | if (current == null) {
|
299 | 338 | continue;
|
|
0 commit comments