I have started implementation of Glide in my existing project and have been going through docs and examples. I checked sample app of Flickr and am trying to preload images just like it.
I am initialising GlideRequest in fragment and then passing it to the adapter to preload images and display. But when I run my app, I am neither getting any error nor are any images displayed. I have slightly modified my code from sample app as I don't want any model loader.
This is my initialisation in fragment:
private GlideRequests instructorRequestBuilder;
instructorRequestBuilder = GlideApp.with(this);
I assign in it to
preloadRequest
Variable in adapter's constructor.
Then following is the code into bindViewHolder:
private void setImage(final String image, final ImageView imageView)
{
preloadRequest.load(image)
.centerCrop()
.placeholder(R.drawable.placeholder_explore_user)
.error(R.mipmap.ic_launcher)
.listener(new RequestListener()
{
@Override public boolean onLoadFailed(@Nullable GlideException e, Object model,
Target target, boolean isFirstResource)
{
Log.d(TAG, "onLoadFailed: " + e);
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target target,
DataSource dataSource, boolean isFirstResource)
{
Log.d(TAG, "onLoadFailed: " + isFirstResource);
Log.d(TAG, "onLoadFailed: " + dataSource);
return false;
}
})
.into(imageView);
}
My adapter implements
ListPreloader.PreloadModelProvider
And this is the code for implemented methods:
@NonNull @Override public List getPreloadItems(int position)
{
return iConnectInstructors.subList(position, position + 1);
}
@Nullable @Override
public RequestBuilder getPreloadRequestBuilder(@NonNull IConnectType item)
{
return preloadRequest.load(((User) item)
.getProfileImage250())
.placeholder(R.drawable.placeholder_explore_user)
.centerCrop()
.error(R.mipmap.ic_launcher);
}
PreloadSize and PreLoader are initialised as below:
ViewPreloadSizeProvider preloadSizeProvider = new ViewPreloadSizeProvider<>();
RecyclerViewPreloader preloader = new RecyclerViewPreloader(
GlideApp.with(this), adapter,
preloadSizeProvider, 6);
rvInstructor.addOnScrollListener(preloader);
rvInstructor.setItemViewCacheSize(0);
Why is this not showing any items in the recyclerview?
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)