there! I'm using glide to load images in my app. Previously I used Picasso and it worked but after migrating to the Glide (v4.7.1) I'm not able to use listener to get state of the resource. I attached code below please help me in this matter.
Glide.with(SlideImageActivity.this)
.load(Constant.arrayList.get(position)
.getImage())
.apply(new RequestOptions()
.placeholder(R.color.colorPrimary)
.dontAnimate().skipMemoryCache(true))
.listener(new RequestListener<String, DrawableResource>() {
public boolean onException(Exception e, String model, Target<DrawableResource> target, boolean isFirstResource) {
spinner.setVisibility(View.GONE);
return false;
}
public boolean onResourceReady(DrawableResource resource, String model, Target<DrawableResource> target, boolean isFromMemoryCache, boolean isFirstResource) {
spinner.setVisibility(View.GONE);
return false;
}
})
.into((ImageView) imageLayout.findViewById(R.id.image));
Error line shows under this
new RequestListener<String, DrawableResource>()
If I try to build apk with this then following error shows
error: wrong number of type arguments; required 1
IDE shows following
Class anonymous class derived from RequestListener must be declard either abstract or implement methods.
if I implement methods which IDE recommends me, I get following
error: wrong number of type arguments; required 1
Try this
Glide.with(this)
.load("")
.apply(new RequestOptions()
.placeholder(R.color.colorPrimary)
.dontAnimate().skipMemoryCache(true))
.listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
spinner.setVisibility(View.GONE);
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
spinner.setVisibility(View.GONE);
return false;
}
})
.into(imageView);