Java 类com.bumptech.glide.load.model.stream.StreamModelLoader 实例源码

项目:LLApp    文件:GlideImageLoaderStrategy.java   
/**
 * 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());
}
项目:glide-support    文件:TestActivity.java   
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() {
        }
    });
}
项目:PeSanKita-android    文件:DecryptableStreamUriLoader.java   
@Override
public StreamModelLoader<DecryptableUri> build(Context context, GenericLoaderFactory factories) {
  return new DecryptableStreamUriLoader(context);
}
项目:PeSanKita-android    文件:AttachmentStreamUriLoader.java   
@Override
public StreamModelLoader<AttachmentModel> build(Context context, GenericLoaderFactory factories) {
  return new AttachmentStreamUriLoader(context);
}
项目:PeSanKita-android    文件:ContactPhotoUriLoader.java   
@Override
public StreamModelLoader<ContactPhotoUri> build(Context context, GenericLoaderFactory factories) {
  return new ContactPhotoUriLoader(context);
}
项目:Cable-Android    文件:DecryptableStreamUriLoader.java   
@Override
public StreamModelLoader<DecryptableUri> build(Context context, GenericLoaderFactory factories) {
  return new DecryptableStreamUriLoader(context);
}
项目:Cable-Android    文件:AttachmentStreamUriLoader.java   
@Override
public StreamModelLoader<AttachmentModel> build(Context context, GenericLoaderFactory factories) {
  return new AttachmentStreamUriLoader(context);
}
项目:Cable-Android    文件:ContactPhotoUriLoader.java   
@Override
public StreamModelLoader<ContactPhotoUri> build(Context context, GenericLoaderFactory factories) {
  return new ContactPhotoUriLoader(context);
}
项目:TextSecureSMP    文件:DecryptableStreamUriLoader.java   
@Override
public StreamModelLoader<DecryptableUri> build(Context context, GenericLoaderFactory factories) {
  return new DecryptableStreamUriLoader(context);
}
项目:Silence    文件:DecryptableStreamUriLoader.java   
@Override
public StreamModelLoader<DecryptableUri> build(Context context, GenericLoaderFactory factories) {
  return new DecryptableStreamUriLoader(context);
}
项目:Silence    文件:AttachmentStreamUriLoader.java   
@Override
public StreamModelLoader<AttachmentModel> build(Context context, GenericLoaderFactory factories) {
  return new AttachmentStreamUriLoader(context);
}
项目:Silence    文件:ContactPhotoUriLoader.java   
@Override
public StreamModelLoader<ContactPhotoUri> build(Context context, GenericLoaderFactory factories) {
  return new ContactPhotoUriLoader(context);
}
项目:mage-android    文件:AttachmentLoader.java   
@Override public StreamModelLoader<Attachment> build(Context context, GenericLoaderFactory factories) {
    return new AttachmentLoader(context);
}
项目:saarang-iosched    文件:ModelRequest.java   
/**
 * Set the {@link ModelLoader} to use for for a new load where the model loader translates from a model to an
 * {@link InputStream} resource for loading images.
 *
 * @param modelLoader The model loader to use.
 * @param <T> The type of the model.
 * @return A new {@link ImageModelRequest}.
 */
public <T> ImageModelRequest<T> using(final StreamModelLoader<T> modelLoader) {
    return new ImageModelRequest<T>(context, modelLoader, glide);
}
项目:AppDevFestSudeste2015    文件:ModelRequest.java   
/**
 * Set the {@link ModelLoader} to use for for a new load where the model loader translates from a model to an
 * {@link InputStream} resource for loading images.
 *
 * @param modelLoader The model loader to use.
 * @param <T> The type of the model.
 * @return A new {@link ImageModelRequest}.
 */
public <T> ImageModelRequest<T> using(final StreamModelLoader<T> modelLoader) {
    return new ImageModelRequest<T>(context, modelLoader, glide);
}
项目:devfestnorte-app    文件:ModelRequest.java   
/**
 * Set the {@link ModelLoader} to use for for a new load where the model loader translates from a model to an
 * {@link InputStream} resource for loading images.
 *
 * @param modelLoader The model loader to use.
 * @param <T> The type of the model.
 * @return A new {@link ImageModelRequest}.
 */
public <T> ImageModelRequest<T> using(final StreamModelLoader<T> modelLoader) {
    return new ImageModelRequest<T>(context, modelLoader, glide);
}
项目:saarang-iosched    文件:ModelRequest.java   
/**
 * Set the {@link ModelLoader} to use for for a new load where the model loader translates from a model to an
 * {@link InputStream} resource for loading images.
 *
 * @param modelLoader The model loader to use.
 * @param <T> The type of the model.
 * @return A new {@link ImageModelRequest}.
 */
public <T> ImageModelRequest<T> using(final StreamModelLoader<T> modelLoader) {
    return new ImageModelRequest<T>(context, modelLoader, glide);
}