com.bumptech.glide.load.model.stream.StreamModelLoader Java Examples
The following examples show how to use
com.bumptech.glide.load.model.stream.StreamModelLoader.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GlideImageLoaderStrategy.java From LLApp with Apache License 2.0 | 5 votes |
/** * load cache image with Glide */ private void loadCache(Context ctx, ImageLoader img) { Glide.with(ctx).using(new StreamModelLoader<String>() { @Override public DataFetcher<InputStream> getResourceFetcher(final String model, int i, int i1) { return new DataFetcher<InputStream>() { @Override public InputStream loadData(Priority priority) throws Exception { throw new IOException(); } @Override public void cleanup() { } @Override public String getId() { return model; } @Override public void cancel() { } }; } }).load(img.getUrl()).placeholder(img.getPlaceHolder()).diskCacheStrategy(DiskCacheStrategy.ALL).into(img.getImgView()); }
Example #2
Source File: TestActivity.java From glide-support with The Unlicense | 5 votes |
private void clearCacheSyncAndHackNetwork() { // TODO only for testing: clear all caches before anything is loaded to always have a clean slate Glide.get(TestActivity.this).clearMemory(); final CountDownLatch latch = new CountDownLatch(1); new Thread() { @Override public void run() { Glide.get(TestActivity.this).clearDiskCache(); latch.countDown(); } }.start(); try { latch.await(); // never do this in production } catch (InterruptedException e) { e.printStackTrace(); } // TODO only for debug: override default Url handler to fail sometimes (50%) Glide.get(this).register(GlideUrl.class, InputStream.class, new ModelLoaderFactory<GlideUrl, InputStream>() { Random random = new Random(0); @Override public ModelLoader<GlideUrl, InputStream> build(Context context, GenericLoaderFactory factories) { return new StreamModelLoader<GlideUrl>() { @Override public DataFetcher<InputStream> getResourceFetcher(GlideUrl url, int width, int height) { return random.nextBoolean()? new HttpUrlFetcher(url) : new NetworkDisablingFetcher(url); } }; } @Override public void teardown() { } }); }
Example #3
Source File: GlideModule.java From glide-support with The Unlicense | 4 votes |
@Override public StreamModelLoader<String> build(Context context, GenericLoaderFactory factories) { return new HeaderedLoader(context); }
Example #4
Source File: DecryptableStreamUriLoader.java From Silence with GNU General Public License v3.0 | 4 votes |
@Override public StreamModelLoader<DecryptableUri> build(Context context, GenericLoaderFactory factories) { return new DecryptableStreamUriLoader(context); }
Example #5
Source File: AttachmentStreamUriLoader.java From Silence with GNU General Public License v3.0 | 4 votes |
@Override public StreamModelLoader<AttachmentModel> build(Context context, GenericLoaderFactory factories) { return new AttachmentStreamUriLoader(context); }
Example #6
Source File: ContactPhotoUriLoader.java From Silence with GNU General Public License v3.0 | 4 votes |
@Override public StreamModelLoader<ContactPhotoUri> build(Context context, GenericLoaderFactory factories) { return new ContactPhotoUriLoader(context); }
Example #7
Source File: RequestManager.java From giffun with Apache License 2.0 | 2 votes |
/** * Returns a request builder that uses the given {@link StreamModelLoader} to * fetch an {@link InputStream} for loading images. * * @param modelLoader The model loader to use. * @param <T> The type of the model. */ public <T> ImageModelRequest<T> using(final StreamModelLoader<T> modelLoader) { return new ImageModelRequest<T>(modelLoader); }