我使用滑翔加載圖像和我添加了一個監聽器知道什麼時候資源是準備好或者是否有任何類型的錯誤:滑翔監聽器不工作
Glide.with(mContext)
.load(url)
.placeholder(R.drawable.glide_placeholder)
// use dontAnimate and not crossFade to avoid a bug with custom views
.dontAnimate()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
// do something
return true;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
// do something
return true;
}
})
.into(mCustomImageView);
應用始終運行中onResourceReady
或onException
但如果我刪除偵聽器,並讓異步下載沒有回調,它正確地運行:
Glide.with(mContext)
.load(url)
.placeholder(R.drawable.glide_placeholder)
// use dontAnimate and not crossFade to avoid a bug with custom views
.dontAnimate()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(mCustomImageView);
我也試圖與GlideDrawableImageViewTarget
代替監聽器接收回調,但應用程序運行內部onLoadStarted
但從來沒有運行insid e onLoadCleared
,onLoadFailed
和onResourceReady
。
你說聽者的onException的和onResourceReady方法不叫?從這些方法返回true將阻止目標被調用,但無論如何都應該始終爲它們調用它們。 –
我想你需要調用'submit'才能啓動它以開始加載 –