|
1 | 1 | package com.bumptech.glide;
|
2 | 2 |
|
| 3 | +import static com.bumptech.glide.request.RequestOptions.diskCacheStrategyOf; |
3 | 4 | import static com.bumptech.glide.request.RequestOptions.signatureOf;
|
4 | 5 |
|
5 | 6 | import android.content.Context;
|
| 7 | +import android.graphics.Bitmap; |
| 8 | +import android.graphics.drawable.Drawable; |
6 | 9 | import android.net.Uri;
|
7 | 10 | import android.support.annotation.CheckResult;
|
8 | 11 | import android.support.annotation.DrawableRes;
|
@@ -317,7 +320,58 @@ private RequestBuilder<TranscodeType> loadGeneric(@Nullable Object model) {
|
317 | 320 | }
|
318 | 321 |
|
319 | 322 | /**
|
320 |
| - * Returns a request builder to load the given {@link java.lang.String}. signature. |
| 323 | + * Returns a request builder to load the given {@link Bitmap}. |
| 324 | + * |
| 325 | + * <p>{@link Bitmap}s provided to this method become owned by Glide. The {@link Bitmap} may be |
| 326 | + * recycled or re-used at any time. If you do not own the Bitmap or you need to continue to use |
| 327 | + * the {@link Bitmap} after passing it in to Glide, consider passing a copy of the {@link Bitmap} |
| 328 | + * to Glide instead. It's almost always better to allow Glide to load {@link Bitmap}s than |
| 329 | + * pass {@link Bitmap}s into Glide. If you have a custom way to obtain {@link Bitmap}s that is |
| 330 | + * not supported by Glide, consider registering a custom |
| 331 | + * {@link com.bumptech.glide.load.model.ModelLoader} or |
| 332 | + * {@link com.bumptech.glide.load.ResourceDecoder} instead. |
| 333 | + * |
| 334 | + * <p>The {@link DiskCacheStrategy} is set to {@link DiskCacheStrategy#NONE}. Using other |
| 335 | + * strategies may result in undefined behavior. |
| 336 | + * |
| 337 | + * <p>In memory caching relies on Object equality. The contents of the {@link Bitmap}s are not |
| 338 | + * compared. |
| 339 | + * |
| 340 | + * @see #load(Object) |
| 341 | + */ |
| 342 | + @CheckResult |
| 343 | + public RequestBuilder<TranscodeType> load(@Nullable Bitmap bitmap) { |
| 344 | + return loadGeneric(bitmap) |
| 345 | + .apply(diskCacheStrategyOf(DiskCacheStrategy.NONE)); |
| 346 | + } |
| 347 | + |
| 348 | + /** |
| 349 | + * Returns a request builder to load the given {@link Drawable}. |
| 350 | + * |
| 351 | + * <p>{@link Drawable}s provided to this method become owned by Glide. They or {@link Bitmap}s |
| 352 | + * they contain may be recycled or re-used at any time. If you do not own the {@link Drawable}, |
| 353 | + * do not pass it in to Glide. It's almost always better to allow Glide to load {@link Bitmap}s |
| 354 | + * than pass {@link Bitmap}s into Glide. If you have a custom way to obtain {@link Bitmap}s that |
| 355 | + * is not supported by Glide, consider registering a custom |
| 356 | + * {@link com.bumptech.glide.load.model.ModelLoader} or |
| 357 | + * {@link com.bumptech.glide.load.ResourceDecoder} instead. |
| 358 | + * |
| 359 | + * <p>The {@link DiskCacheStrategy} is set to {@link DiskCacheStrategy#NONE}. Using other |
| 360 | + * strategies may result in undefined behavior. |
| 361 | + * |
| 362 | + * <p>In memory caching relies on Object equality. The contents of the {@link Drawable}s are not |
| 363 | + * compared. |
| 364 | + * |
| 365 | + * @see #load(Object) |
| 366 | + */ |
| 367 | + @CheckResult |
| 368 | + public RequestBuilder<TranscodeType> load(@Nullable Drawable drawable) { |
| 369 | + return loadGeneric(drawable) |
| 370 | + .apply(diskCacheStrategyOf(DiskCacheStrategy.NONE)); |
| 371 | + } |
| 372 | + |
| 373 | + /** |
| 374 | + * Returns a request builder to load the given {@link java.lang.String}. |
321 | 375 | *
|
322 | 376 | * <p> Note - this method caches data using only the given String as the cache key. If the data is
|
323 | 377 | * a Uri outside of your control, or you otherwise expect the data represented by the given String
|
|
0 commit comments