进度条可见性设置了图像加载完成后使用滑翔库 [英] Set visibility of progress bar gone on completion of image loading using Glide library
问题描述
您好我想有这将同时显示图像加载,但是当图像加载将完成我想将它设置为走了图像的进度条。早些时候,我是用毕加索库这一点。但我不知道如何使用它的滑翔库。我有想法,一些资源准备功能是有,但我不知道如何使用它。谁能帮助我?
Hi I want to have a progress bar for image which will shown while image loading but when image loading will be completed I want to set it to gone. Earlier I was using Picasso library for this. But I don't know how to use it with Glide library. I have idea that some resource ready function is there but I don't know how to use it. Can anyone help me?
code毕加索库
Picasso.with(mcontext).load(imgLinkArray.get(position).mUrlLink)
.into(imageView, new Callback() {
@Override
public void onSuccess() {
progressBar.setVisibility(View.GONE);
}
@Override
public void onError() {
}
})
;
现在我怎么可以这样跟滑翔?
Now How Can I do this with Glide?
Glide.with(mcontext).load(imgLinkArray.get(position).mUrlLink)
.into(imageView);
我能够通过这个加载图像滑翔,但我怎么能写 progressBar.setVisibility(View.GONE);
介于code如果图像获取装?
I am able to load image by this with Glide but how can I write progressBar.setVisibility(View.GONE);
somewhere in code if image get loaded?
推荐答案
问题是相当老了,我不知道什么是与滑行在那个时代的情况,但现在它可以很容易地与听众进行(而不是在选择作为正确答案)提出的。
Question is rather old, and I don't know what was the situation with glide in those times, but now it can be easily done with listener (not as proposed in the answer chosen as correct).
progressBar.setVisibility(View.VISIBLE);
Glide.with(getActivity())
.load(args.getString(IMAGE_TO_SHOW))
.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(imageFrame)
;
如果要处理的事情喜欢自己和虚假的动画,如果想要滑行来处理他们为你你返回true。
You return true if want to handle things like animations yourself and false if want glide to handle them for you.
这篇关于进度条可见性设置了图像加载完成后使用滑翔库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!