@Override public LoadData<Data> buildLoadData(@NonNull Uri model, int width, int height, @NonNull Options options) { String assetPath = model.toString().substring(ASSET_PREFIX_LENGTH); return new LoadData<>(new ObjectKey(model), factory.buildFetcher(assetManager, assetPath)); }
@SuppressWarnings("deprecation") @Override public LoadData<InputStream> buildLoadData(@NonNull GlideUrl model, int width, int height, @NonNull Options options) { return new LoadData<>(model, new OkHttpStreamFetcher(client, model)); }
@Override public LoadData<InputStream> buildLoadData(@NonNull GlideUrl model, int width, int height, @NonNull Options options) { return new LoadData<>(model, new OkHttpStreamFetcher(client, model)); }
@Override public LoadData<InputStream> buildLoadData(@NonNull GlideUrl url, int width, int height, @NonNull Options options) { return new LoadData<>(url, new VolleyStreamFetcher(requestQueue, url, requestFactory)); }
@Test public void testHandlesResourceUris() { Uri resourceUri = Uri.parse("android.resource://com.bumptech.glide.tests/raw/ic_launcher"); when(uriLoader.buildLoadData(eq(resourceUri), eq(IMAGE_SIDE), eq(IMAGE_SIDE), eq(options))) .thenReturn(new ModelLoader.LoadData<>(key, fetcher)); assertTrue(loader.handles(resourceUri.toString())); assertEquals( fetcher, Preconditions.checkNotNull( loader.buildLoadData(resourceUri.toString(), IMAGE_SIDE, IMAGE_SIDE, options)).fetcher); }
@Test public void testHandlesFileUris() { File f = RuntimeEnvironment.application.getCacheDir(); Uri expected = Uri.fromFile(f); when(uriLoader.buildLoadData(eq(expected), eq(IMAGE_SIDE), eq(IMAGE_SIDE), eq(options))) .thenReturn(new ModelLoader.LoadData<>(key, fetcher)); assertTrue(loader.handles(f.getAbsolutePath())); assertEquals( fetcher, Preconditions.checkNotNull( loader.buildLoadData(expected.toString(), IMAGE_SIDE, IMAGE_SIDE, options)).fetcher); }
@Override @Nullable public LoadData<InputStream> buildLoadData(@NonNull Uri model, int width, int height, @NonNull Options options) { if (MediaStoreUtil.isThumbnailSize(width, height) && isRequestingDefaultFrame(options)) { return new LoadData<>(new ObjectKey(model), ThumbFetcher.buildVideoFetcher(context, model)); } else { return null; } }
@Override public LoadData<DataT> buildLoadData(@NonNull ModelT modelT, int width, int height, @NonNull Options options) { return new LoadData<>(new ObjectKey(modelT), new MockDataFetcher<>(data)); }
@Override public LoadData<InputStream> buildLoadData(@NonNull Uri model, int width, int height, @NonNull Options options) { if (MediaStoreUtil.isThumbnailSize(width, height)) { return new LoadData<>(new ObjectKey(model), ThumbFetcher.buildImageFetcher(context, model)); } else { return null; } }
@Override public LoadData<Data> buildLoadData(@NonNull Uri model, int width, int height, @NonNull Options options) { return new LoadData<>(new ObjectKey(model), factory.build(model)); }
@android.support.annotation.Nullable @Override public LoadData<InputStream> buildLoadData(@NonNull Object o, int width, int height, @NonNull Options options) { return new LoadData<>(new ObjectKey(o), new Fetcher()); }
@Test public void testCanHandleId() { int id = android.R.drawable.star_off; Uri contentUri = Uri.parse("android.resource://android/drawable/star_off"); when(uriLoader.buildLoadData(eq(contentUri), anyInt(), anyInt(), any(Options.class))) .thenReturn(new ModelLoader.LoadData<>(key, fetcher)); assertTrue(loader.handles(id)); assertEquals( fetcher, Preconditions.checkNotNull(loader.buildLoadData(id, 100, 100, new Options())).fetcher); }
@Override public LoadData<File> buildLoadData(@NonNull Uri uri, int width, int height, @NonNull Options options) { return new LoadData<>(new ObjectKey(uri), new FilePathFetcher(context, uri)); }
@Override public LoadData<Model> buildLoadData(@NonNull Model model, int width, int height, @NonNull Options options) { return new LoadData<>(new ObjectKey(model), new UnitFetcher<>(model)); }
@Test public void testHandlesContent() { String content = "content://com.bumptech.glide"; Uri expected = Uri.parse(content); when(uriLoader.buildLoadData(eq(expected), eq(IMAGE_SIDE), eq(IMAGE_SIDE), eq(options))) .thenReturn(new ModelLoader.LoadData<>(key, fetcher)); assertTrue(loader.handles(content)); assertEquals( fetcher, Preconditions.checkNotNull( loader.buildLoadData(content, IMAGE_SIDE, IMAGE_SIDE, options)).fetcher); }
@Test public void testHandlesHttp() { String url = "http://www.google.com"; Uri expected = Uri.parse(url); when(uriLoader.buildLoadData(eq(expected), eq(IMAGE_SIDE), eq(IMAGE_SIDE), eq(options))) .thenReturn(new ModelLoader.LoadData<>(key, fetcher)); assertTrue(loader.handles(url)); assertEquals( fetcher, Preconditions.checkNotNull( loader.buildLoadData(url, IMAGE_SIDE, IMAGE_SIDE, options)).fetcher); }
@Nullable @Override public LoadData<Data> buildLoadData( @NonNull WaitModel<Model> waitModel, int width, int height, @NonNull Options options) { LoadData<Data> wrappedLoadData = wrapped .buildLoadData(waitModel.wrapped, width, height, options); if (wrappedLoadData == null) { return null; } return new LoadData<>( wrappedLoadData.sourceKey, new WaitFetcher<>(wrappedLoadData.fetcher, waitModel.latch)); }
@Test public void testHandlesHttps() { String url = "https://www.google.com"; Uri expected = Uri.parse(url); when(uriLoader.buildLoadData(eq(expected), eq(IMAGE_SIDE), eq(IMAGE_SIDE), eq(options))) .thenReturn(new ModelLoader.LoadData<>(key, fetcher)); assertTrue(loader.handles(url)); assertEquals( fetcher, Preconditions.checkNotNull( loader.buildLoadData(url, IMAGE_SIDE, IMAGE_SIDE, options)).fetcher); }
@Override public LoadData<ByteBuffer> buildLoadData(@NonNull File file, int width, int height, @NonNull Options options) { return new LoadData<>(new ObjectKey(file), new ByteBufferFetcher(file)); }
@Override public LoadData<Data> buildLoadData(@NonNull Model model, int width, int height, @NonNull Options options) { return new LoadData<>( new ObjectKey(model), new DataUriFetcher<>(model.toString(), dataDecoder)); }