如何使用Glide Library按图像加载图像? [英] How to load image by image using Glide Library?
本文介绍了如何使用Glide Library按图像加载图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个应用程序包含使用滑动库链接显示的一系列图像,我的应用程序需要很长时间才能加载所有图像,因此可以逐个图像加载图像(逐个)。
I have an application contains a range of image appears by links using glide library, my app takes a long time to load all images so is it possible to load image by image ( one by one ).
Glide.with(context)
.load(imageId.get(position))
.diskCacheStrategy(DiskCacheStrategy.ALL)
.priority(Priority.HIGH)
.listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
progressBar.setVisibility(View.GONE);
return false;
}
})
.into(holder.CategoryImage);
推荐答案
试试这个
Glide.with(context)
.load(imageId.get(position))
.diskCacheStrategy(DiskCacheStrategy.ALL)
.priority(Priority.HIGH)
.listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
progressBar.setVisibility(View.GONE);
return false;
}
})
.thumbnail(0.1f) // this will do the trick
.into(holder.CategoryImage);
如果不起作用,请尝试这种方式,
if it does not work, Try this way,
Glide.with(context)
.load(imageId.get(position))
.diskCacheStrategy(DiskCacheStrategy.ALL)
.priority(Priority.HIGH)
.override(100,100)
.listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
progressBar.setVisibility(View.GONE);
Glide.with(context).load(imageId.get(position))
.diskCacheStrategy(DiskCacheStrategy.ALL)
.priority(Priority.HIGH)
.into(holder.CategoryImage);
return false;
}
})
.into(holder.CategoryImage);
这篇关于如何使用Glide Library按图像加载图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文