@Override public ModelLoader<Uri, AssetFileDescriptor> build(MultiModelLoaderFactory multiFactory) { return new UriLoader<>(this); }
@Override public final DataFetcher<T> getResourceFetcher(Uri model, int width, int height) { final String scheme = model.getScheme(); DataFetcher<T> result = null; if (isLocalUri(scheme)) { if (AssetUriParser.isAssetUri(model)) { String path = AssetUriParser.toAssetPath(model); result = getAssetPathFetcher(context, path); } else { result = getLocalUriFetcher(context, model); } } else if (urlLoader != null && ("http".equals(scheme) || "https".equals(scheme))) { result = urlLoader.getResourceFetcher(new GlideUrl(model.toString()), width, height); } return result; }
@Test public void testHandlesContentUris() { Uri contentUri = Uri.parse("content://com.bumptech.glide"); when(factory.build(eq(contentUri))).thenReturn(localUriFetcher); assertTrue(loader.handles(contentUri)); assertEquals( localUriFetcher, Preconditions.checkNotNull( loader.buildLoadData(contentUri, IMAGE_SIDE, IMAGE_SIDE, options)).fetcher); } }
@Test public void testHandlesResourceUris() throws IOException { Uri resourceUri = Uri.parse("android.resource://com.bumptech.glide.tests/raw/ic_launcher"); when(factory.build(eq(resourceUri))).thenReturn(localUriFetcher); assertTrue(loader.handles(resourceUri)); assertEquals( localUriFetcher, Preconditions.checkNotNull( loader.buildLoadData(resourceUri, IMAGE_SIDE, IMAGE_SIDE, options)).fetcher); }
@NonNull @Override public ModelLoader<Uri, InputStream> build(MultiModelLoaderFactory multiFactory) { return new UriLoader<>(this); }
@Test public void testHandlesFileUris() throws IOException { Uri fileUri = Uri.fromFile(new File("f")); when(factory.build(eq(fileUri))).thenReturn(localUriFetcher); assertTrue(loader.handles(fileUri)); assertEquals( localUriFetcher, Preconditions.checkNotNull( loader.buildLoadData(fileUri, IMAGE_SIDE, IMAGE_SIDE, options)).fetcher); }
@NonNull @Override public ModelLoader<Uri, ParcelFileDescriptor> build(MultiModelLoaderFactory multiFactory) { return new UriLoader<>(this); }
@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); options = new Options(); loader = new UriLoader<>(factory); }
@Override public ModelLoader<Uri, InputStream> build(MultiModelLoaderFactory multiFactory) { return new UriLoader<>(this); }
@Override public ModelLoader<Uri, ParcelFileDescriptor> build(MultiModelLoaderFactory multiFactory) { return new UriLoader<>(this); }