/** * Equivalent to calling {@link #asDrawable()} and then {@link RequestBuilder#load(Drawable)}. * * @return A new request builder for loading a {@link Drawable} using the given model. */ @NonNull @CheckResult @Override public RequestBuilder<Drawable> load(@Nullable Drawable drawable) { return asDrawable().load(drawable); }
/** * A helper method equivalent to calling {@link #downloadOnly()} ()} and then {@link * RequestBuilder#load(Object)} with the given model. * * @return A new request builder for loading a {@link Drawable} using the given model. */ @NonNull @CheckResult public RequestBuilder<File> download(@Nullable Object model) { return downloadOnly().load(model); }
/** * Equivalent to calling {@link #asDrawable()} and then {@link RequestBuilder#load(File)}. * * @return A new request builder for loading a {@link Drawable} using the given model. */ @NonNull @CheckResult @Override public RequestBuilder<Drawable> load(@Nullable File file) { return asDrawable().load(file); }
/** * Equivalent to calling {@link #asDrawable()} and then {@link RequestBuilder#load(URL)}. * * @return A new request builder for loading a {@link Drawable} using the given model. */ @SuppressWarnings("deprecation") @CheckResult @Override @Deprecated public RequestBuilder<Drawable> load(@Nullable URL url) { return asDrawable().load(url); }
/** * Equivalent to calling {@link #asDrawable()} and then {@link RequestBuilder#load(Uri)}. * * @return A new request builder for loading a {@link Drawable} using the given model. */ @NonNull @CheckResult @Override public RequestBuilder<Drawable> load(@Nullable Uri uri) { return asDrawable().load(uri); }
/** * Equivalent to calling {@link #asDrawable()} and then {@link RequestBuilder#load(Integer)}. * * @return A new request builder for loading a {@link Drawable} using the given model. */ @SuppressWarnings("deprecation") @NonNull @CheckResult @Override public RequestBuilder<Drawable> load(@RawRes @DrawableRes @Nullable Integer resourceId) { return asDrawable().load(resourceId); }
@Override protected void onAttachedToWindow() { super.onAttachedToWindow(); Glide.with(getContext()).asDrawable().load(android.R.drawable.ic_menu_rotate).into(this); } }
@Test public void loadBitmap_asBytes_providesBytesOfBitmap() { Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), ResourceIds.raw.canonical); byte[] data = concurrency.get( Glide.with(context) .as(byte[].class) .load(bitmap) .submit()); assertThat(data).isNotNull(); assertThat(BitmapFactory.decodeByteArray(data, 0, data.length)).isNotNull(); }
private RequestBuilder<Object> getNullModelRequest() { when(glideContext.buildImageViewTarget(isA(ImageView.class), isA(Class.class))) .thenReturn(mock(ViewTarget.class)); when(glideContext.getDefaultRequestOptions()).thenReturn(new RequestOptions()); when(requestManager.getDefaultRequestOptions()) .thenReturn(new RequestOptions()); when(requestManager.getDefaultTransitionOptions(any(Class.class))) .thenReturn(new GenericTransitionOptions<>()); return new RequestBuilder<>(glide, requestManager, Object.class, context) .load((Object) null); } }
@Test public void load_withWideGamutImage_returnsWideGamutBitmap() { Bitmap bitmap = concurrency.get( Glide.with(context) .asBitmap() .load(ResourceIds.raw.webkit_logo_p3) .submit()); assertThat(bitmap.getConfig()).isEqualTo(Bitmap.Config.RGBA_F16); }
@Test public void loadVideoFilePath_asBytes_providesByteOfFrame() throws IOException { byte[] data = concurrency.get( Glide.with(context) .as(byte[].class) .load(writeVideoToFile().getAbsolutePath()) .submit()); assertThat(data).isNotNull(); assertThat(BitmapFactory.decodeByteArray(data, 0, data.length)).isNotNull(); }
@Test public void load_withBitmapResourceId_asBitmap_producesNonNullBitmap() throws ExecutionException, InterruptedException { Bitmap bitmap = Glide.with(context) .asBitmap() .load(android.R.drawable.star_big_off) .submit() .get(); assertThat(bitmap).isNotNull(); }
@Test public void load_withVectorDrawableResourceId_asBitmap_producesNonNullBitmap() throws ExecutionException, InterruptedException { Bitmap bitmap = Glide.with(context) .asBitmap() .load(ResourceIds.drawable.vector_drawable) .submit() .get(); assertThat(bitmap).isNotNull(); }
@Test public void load_withBitmapAliasResourceId_asBitmap_producesNonNullBitmap() throws ExecutionException, InterruptedException { Bitmap bitmap = Glide.with(context) .asBitmap() .load(ResourceIds.drawable.bitmap_alias) .submit() .get(); assertThat(bitmap).isNotNull(); }
@Test public void loadVideoResourceId_asBitmap_decodesFrame() { Bitmap frame = concurrency.get( Glide.with(context) .asBitmap() .load(ResourceIds.raw.video) .submit()); assertThat(frame).isNotNull(); }
@Test public void load_withJpegAsDataUri_returnsBitmap() { Bitmap bitmap = concurrency.get( Glide.with(context) .asBitmap() .load(getDataUri(CompressFormat.JPEG)) .submit()); assertThat(bitmap).isNotNull(); }
@Test public void loadTransparentGifResource_withNoOtherLoaders_fromBytes_decodesResource() { byte[] data = getBytes(ResourceIds.raw.transparent_gif); Bitmap bitmap = concurrency.get( Glide.with(context) .asBitmap() .load(data) .submit()); assertThat(bitmap).isNotNull(); }
@Test public void load_withPngDataUriString_returnsBitmap() { Bitmap bitmap = concurrency.get( Glide.with(context) .asBitmap() .load(getDataUriString(CompressFormat.PNG)) .submit()); assertThat(bitmap).isNotNull(); }
@Test public void load_withJpegAsDataUriString_returnsBitmap() { Bitmap bitmap = concurrency.get( Glide.with(context) .asBitmap() .load(getDataUriString(CompressFormat.JPEG)) .submit()); assertThat(bitmap).isNotNull(); }
@Test public void load_withPngAsDataUri_returnsBitmap() { Bitmap bitmap = concurrency.get( Glide.with(context) .asBitmap() .load(getDataUri(CompressFormat.PNG)) .submit()); assertThat(bitmap).isNotNull(); }