本文整理汇总了Java中com.bumptech.glide.load.model.stream.StreamModelLoader类的典型用法代码示例。如果您正苦于以下问题:Java StreamModelLoader类的具体用法?Java StreamModelLoader怎么用?Java StreamModelLoader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StreamModelLoader类属于com.bumptech.glide.load.model.stream包,在下文中一共展示了StreamModelLoader类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadCache
import com.bumptech.glide.load.model.stream.StreamModelLoader; //导入依赖的package包/类
/**
* 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());
}
示例2: clearCacheSyncAndHackNetwork
import com.bumptech.glide.load.model.stream.StreamModelLoader; //导入依赖的package包/类
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() {
}
});
}
示例3: build
import com.bumptech.glide.load.model.stream.StreamModelLoader; //导入依赖的package包/类
@Override
public StreamModelLoader<DecryptableUri> build(Context context, GenericLoaderFactory factories) {
return new DecryptableStreamUriLoader(context);
}
示例4: build
import com.bumptech.glide.load.model.stream.StreamModelLoader; //导入依赖的package包/类
@Override
public StreamModelLoader<AttachmentModel> build(Context context, GenericLoaderFactory factories) {
return new AttachmentStreamUriLoader(context);
}
示例5: build
import com.bumptech.glide.load.model.stream.StreamModelLoader; //导入依赖的package包/类
@Override
public StreamModelLoader<ContactPhotoUri> build(Context context, GenericLoaderFactory factories) {
return new ContactPhotoUriLoader(context);
}
示例6: build
import com.bumptech.glide.load.model.stream.StreamModelLoader; //导入依赖的package包/类
@Override public StreamModelLoader<Attachment> build(Context context, GenericLoaderFactory factories) {
return new AttachmentLoader(context);
}
示例7: using
import com.bumptech.glide.load.model.stream.StreamModelLoader; //导入依赖的package包/类
/**
* 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);
}