I want to specify view reference as atribute to ImageView
@BindingAdapter(value = {"imageUrl", "progressView"}, requireAll = false)
public static void setImageUrl(ImageView imageView, String url, @IdRes int progressBar) {
Context context = imageView.getContext();
View progressView = imageView.getRootView().findViewById(progressBar);
progressView.setVisibility(View.VISIBLE);
Glide.with(context).load(url).listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
if (progressView!= null) {
progressView.setVisibility.setVisibility(View.GONE);
}
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
if (progressView!= null) {
progressView.setVisibility(View.GONE);
}
return false;
}
}).crossFade().into(imageView);
}
however my progress view is null.
I tried cast context to activity and findViewById
also null
Another solution is just add progress view below Image and when it loads successfully it should be overlayed bt image